URL: https://github.com/freeipa/freeipa/pull/132
Author: tiran
 Title: #132: Draft for a new setup.py (WIP)
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/132/head:pr132
git checkout pr132
From 6a6cdf9a01c7d042c881edd54afc354de96c0247 Mon Sep 17 00:00:00 2001
From: Christian Heimes <chei...@redhat.com>
Date: Tue, 4 Oct 2016 13:23:22 +0200
Subject: [PATCH] Draft for a new setup.py

Signed-off-by: Christian Heimes <chei...@redhat.com>
---
 .gitignore              | 11 ++----
 MANIFEST.in             |  2 -
 Makefile                | 57 +++++++++++++++++------------
 ipaclient/setup.cfg     |  5 +++
 ipaclient/setup.py      | 44 ++++++++++++++++++++++
 ipaclient/setup.py.in   | 80 ----------------------------------------
 ipalib/Makefile         |  2 +-
 ipalib/setup.cfg        |  5 +++
 ipalib/setup.py         | 38 +++++++++++++++++++
 ipalib/setup.py.in      | 71 ------------------------------------
 ipaplatform/setup.cfg   |  5 +++
 ipaplatform/setup.py    | 42 +++++++++++++++++++++
 ipaplatform/setup.py.in | 79 ----------------------------------------
 ipapython/MANIFEST.in   |  2 -
 ipapython/Makefile      |  2 +-
 ipapython/setup.cfg     |  5 +++
 ipapython/setup.py      | 44 ++++++++++++++++++++++
 ipapython/setup.py.in   | 79 ----------------------------------------
 ipasetup.py.in          | 71 ++++++++++++++++++++++++++++++++++++
 ipatests/setup.cfg      |  5 +++
 ipatests/setup.py       | 60 ++++++++++++++++++++++++++++++
 ipatests/setup.py.in    | 97 -------------------------------------------------
 setup.cfg               |  5 +++
 setup.py                |  8 ++--
 24 files changed, 373 insertions(+), 446 deletions(-)
 delete mode 100644 MANIFEST.in
 create mode 100644 ipaclient/setup.cfg
 create mode 100644 ipaclient/setup.py
 delete mode 100644 ipaclient/setup.py.in
 create mode 100644 ipalib/setup.cfg
 create mode 100644 ipalib/setup.py
 delete mode 100644 ipalib/setup.py.in
 create mode 100644 ipaplatform/setup.cfg
 create mode 100644 ipaplatform/setup.py
 delete mode 100644 ipaplatform/setup.py.in
 delete mode 100644 ipapython/MANIFEST.in
 create mode 100644 ipapython/setup.cfg
 create mode 100755 ipapython/setup.py
 delete mode 100755 ipapython/setup.py.in
 create mode 100644 ipasetup.py.in
 create mode 100644 ipatests/setup.cfg
 create mode 100644 ipatests/setup.py
 delete mode 100644 ipatests/setup.py.in
 create mode 100644 setup.cfg

diff --git a/.gitignore b/.gitignore
index 9b15475..e471371 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,8 +39,12 @@ freeipa2-dev-doc
 /freeipa.spec
 !/Makefile
 /dist/
+/*/dist/
 /RELEASE
 /rpmbuild/
+# Build
+/ipasetup.py
+*.egg-info
 
 # Subdirectories
 /daemons/ipa-otpd/ipa-otpd
@@ -64,16 +68,9 @@ freeipa2-dev-doc
 /client/ipa-join
 /client/ipa-rmkeytab
 
-/ipatests/setup.py
-
-/ipaclient/setup.py
-
-/ipalib/setup.py
 !/ipalib/Makefile
 
-/ipapython/setup.py
 /ipapython/version.py
 !/ipapython/Makefile
 
 /ipaplatform/__init__.py
-/ipaplatform/setup.py
diff --git a/MANIFEST.in b/MANIFEST.in
deleted file mode 100644
index dd76e10..0000000
--- a/MANIFEST.in
+++ /dev/null
@@ -1,2 +0,0 @@
-include COPYING TODO lite-server.py
-include tests/*/*.py
diff --git a/Makefile b/Makefile
index 0435fe9..2c3c325 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@ include VERSION
 SUBDIRS=asn1 daemons install ipapython ipalib
 CLIENTDIRS=ipapython ipalib client asn1
 CLIENTPYDIRS=ipaclient ipaplatform
+PYPKGDIRS=$(CLIENTPYDIRS) ipalib ipapython ipatests
 
 PRJ_PREFIX=freeipa
 
@@ -74,6 +75,10 @@ all: bootstrap-autogen server tests
 		(cd $$subdir && $(MAKE) $@) || exit 1; \
 	done
 
+# empty target to force executation
+.PHONY=FORCE
+FORCE:
+
 client: client-autogen
 	@for subdir in $(CLIENTDIRS); do \
 		(cd $$subdir && $(MAKE) all) || exit 1; \
@@ -161,31 +166,41 @@ test:
 release-update:
 	if [ ! -e RELEASE ]; then echo 0 > RELEASE; fi
 
-version-update: release-update
+ipapython/version.py: ipapython/version.py.in FORCE
+	sed -e s/__VERSION__/$(IPA_VERSION)/ $< > $@
+	sed -i -e "s:__NUM_VERSION__:$(IPA_NUM_VERSION):" $@
+	sed -i -e "s:__VENDOR_VERSION__:$(IPA_VENDOR_VERSION):" $@
+	sed -i -e "s:__API_VERSION__:$(IPA_API_VERSION_MAJOR).$(IPA_API_VERSION_MINOR):" $@
+	grep -Po '(?<=default: ).*' API.txt | sed -n -i -e "/__DEFAULT_PLUGINS__/!{p;b};r /dev/stdin" $@
+	touch -r $< $@
+
+ipasetup.py: ipasetup.py.in FORCE
+	sed -e s/__VERSION__/$(IPA_VERSION)/ $< > $@
+
+ipaplatform/__init__.py: ipaplatform/__init__.py.in FORCE
+	if [ "$(SUPPORTED_PLATFORM)" != "" ]; then \
+	    sed -e s/__PLATFORM__/$(SUPPORTED_PLATFORM)/ \
+	        $< > $@; \
+	    rm -f ipaplatform/constants.py ipaplatform/paths.py ipaplatform/services.py ipaplatform/tasks.py ; \
+	fi
+
+.PHONY: egg_info
+egg_info: ipapython/version.py ipaplatform/__init__.py ipasetup.py
+	$(PYTHON) setup.py egg_info $(EXTRA_SETUP)
+	for directory in $(PYPKGDIRS); do \
+	    pushd $${directory} ; \
+	    $(PYTHON) setup.py egg_info $(EXTRA_SETUP); \
+	    popd ; \
+	done
+
+version-update: release-update ipapython/version.py ipaplatform/__init__.py ipasetup.py egg_info
 	sed -e s/__VERSION__/$(IPA_VERSION)/ -e s/__RELEASE__/$(IPA_RPM_RELEASE)/ \
 		freeipa.spec.in > freeipa.spec
 	sed -e s/__VERSION__/$(IPA_VERSION)/ version.m4.in \
 		> version.m4
-	sed -e s/__VERSION__/$(IPA_VERSION)/ ipapython/setup.py.in \
-		> ipapython/setup.py
-	sed -e s/__VERSION__/$(IPA_VERSION)/ ipaplatform/setup.py.in \
-		> ipaplatform/setup.py
-	sed -e s/__VERSION__/$(IPA_VERSION)/ ipalib/setup.py.in \
-		> ipalib/setup.py
-	sed -e s/__VERSION__/$(IPA_VERSION)/ ipapython/version.py.in \
-		> ipapython/version.py
-	sed -e s/__VERSION__/$(IPA_VERSION)/ ipatests/setup.py.in \
-		> ipatests/setup.py
-	sed -e s/__VERSION__/$(IPA_VERSION)/ ipaclient/setup.py.in \
-		> ipaclient/setup.py
 	sed -e s/__NUM_VERSION__/$(IPA_NUM_VERSION)/ install/ui/src/libs/loader.js.in \
 		> install/ui/src/libs/loader.js
 	sed -i -e "s:__API_VERSION__:$(IPA_API_VERSION_MAJOR).$(IPA_API_VERSION_MINOR):" install/ui/src/libs/loader.js
-	sed -i -e "s:__NUM_VERSION__:$(IPA_NUM_VERSION):" ipapython/version.py
-	sed -i -e "s:__VENDOR_VERSION__:$(IPA_VENDOR_VERSION):" ipapython/version.py
-	sed -i -e "s:__API_VERSION__:$(IPA_API_VERSION_MAJOR).$(IPA_API_VERSION_MINOR):" ipapython/version.py
-	grep -Po '(?<=default: ).*' API.txt | sed -n -i -e "/__DEFAULT_PLUGINS__/!{p;b};r /dev/stdin" ipapython/version.py
-	touch -r ipapython/version.py.in ipapython/version.py
 	sed -e s/__VERSION__/$(IPA_VERSION)/ daemons/ipa-version.h.in \
 		> daemons/ipa-version.h
 	sed -i -e "s:__NUM_VERSION__:$(IPA_NUM_VERSION):" daemons/ipa-version.h
@@ -194,11 +209,6 @@ version-update: release-update
 	sed -e s/__VERSION__/$(IPA_VERSION)/ client/version.m4.in \
 		> client/version.m4
 
-	if [ "$(SUPPORTED_PLATFORM)" != "" ]; then \
-		sed -e s/__PLATFORM__/$(SUPPORTED_PLATFORM)/ \
-			ipaplatform/__init__.py.in > ipaplatform/__init__.py; \
-	fi
-
 	if [ "$(SKIP_API_VERSION_CHECK)" != "yes" ]; then \
 		./makeapi --validate && \
 		./makeaci --validate; \
@@ -296,6 +306,7 @@ clean: version-update
 	@for subdir in $(SUBDIRS); do \
 		(cd $$subdir && $(MAKE) $@) || exit 1; \
 	done
+	rm -rf ipasetup.py ipasetup.py?
 	rm -f *~
 
 distclean: version-update
diff --git a/ipaclient/setup.cfg b/ipaclient/setup.cfg
new file mode 100644
index 0000000..34abb12
--- /dev/null
+++ b/ipaclient/setup.cfg
@@ -0,0 +1,5 @@
+[bdist_wheel]
+universal = 1
+
+[metadata]
+license_file = ../COPYING
diff --git a/ipaclient/setup.py b/ipaclient/setup.py
new file mode 100644
index 0000000..932d192
--- /dev/null
+++ b/ipaclient/setup.py
@@ -0,0 +1,44 @@
+#!/usr/bin/python2
+# Copyright (C) 2007  Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+"""FreeIPA client library
+
+FreeIPA is a server for identity, policy, and audit.
+"""
+import os
+import sys
+
+# include ../ for ipasetup.py
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+from ipasetup import ipasetup  # noqa: E402
+
+ipasetup(
+    name="ipaclient",
+    doc=__doc__,
+    package_dir={'ipaclient': ''},
+    packages=[
+        "ipaclient",
+        "ipaclient.plugins",
+        "ipaclient.remote_plugins",
+        "ipaclient.remote_plugins.2_49",
+        "ipaclient.remote_plugins.2_114",
+        "ipaclient.remote_plugins.2_156",
+        "ipaclient.remote_plugins.2_164",
+    ],
+)
diff --git a/ipaclient/setup.py.in b/ipaclient/setup.py.in
deleted file mode 100644
index d1fdd3e..0000000
--- a/ipaclient/setup.py.in
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/usr/bin/python2
-# Copyright (C) 2007  Red Hat
-# see file 'COPYING' for use and warranty information
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-
-"""FreeIPA client library
-
-FreeIPA is a server for identity, policy, and audit.
-"""
-
-DOCLINES = __doc__.split("\n")
-
-import os
-import sys
-
-CLASSIFIERS = """\
-Intended Audience :: System Environment/Base
-License :: GPL
-Programming Language :: Python
-Operating System :: POSIX
-Operating System :: Unix
-"""
-
-# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
-# update it when the contents of directories change.
-if os.path.exists('MANIFEST'):
-    os.remove('MANIFEST')
-
-def setup_package():
-
-    from distutils.core import setup
-
-    old_path = os.getcwd()
-    local_path = os.path.dirname(os.path.abspath(sys.argv[0]))
-    os.chdir(local_path)
-    sys.path.insert(0,local_path)
-
-    try:
-        setup(
-            name = "ipaclient",
-            version = "__VERSION__",
-            license = "GPL",
-            url = "http://www.freeipa.org/";,
-            description = DOCLINES[0],
-            long_description = "\n".join(DOCLINES[2:]),
-            download_url = "http://www.freeipa.org/page/Downloads";,
-            classifiers=[line for line in CLASSIFIERS.split('\n') if line],
-            platforms = ["Linux", "Solaris", "Unix"],
-            package_dir = {'ipaclient': ''},
-            packages = [
-                "ipaclient",
-                "ipaclient.plugins",
-                "ipaclient.remote_plugins",
-                "ipaclient.remote_plugins.2_49",
-                "ipaclient.remote_plugins.2_114",
-                "ipaclient.remote_plugins.2_156",
-                "ipaclient.remote_plugins.2_164",
-            ],
-            scripts=['../ipa'],
-        )
-    finally:
-        del sys.path[0]
-        os.chdir(old_path)
-    return
-
-if __name__ == '__main__':
-    setup_package()
diff --git a/ipalib/Makefile b/ipalib/Makefile
index 5bd84fa..135a03a 100644
--- a/ipalib/Makefile
+++ b/ipalib/Makefile
@@ -16,7 +16,7 @@ install:
 	fi
 
 clean:
-	rm -f *~ *.pyc __pycache__/
+	rm -rf *~ *.pyc __pycache__/
 
 distclean: clean
 	rm -f setup.py
diff --git a/ipalib/setup.cfg b/ipalib/setup.cfg
new file mode 100644
index 0000000..34abb12
--- /dev/null
+++ b/ipalib/setup.cfg
@@ -0,0 +1,5 @@
+[bdist_wheel]
+universal = 1
+
+[metadata]
+license_file = ../COPYING
diff --git a/ipalib/setup.py b/ipalib/setup.py
new file mode 100644
index 0000000..62a4499
--- /dev/null
+++ b/ipalib/setup.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python2
+# Copyright (C) 2007  Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+"""FreeIPA common python library
+
+FreeIPA is a server for identity, policy, and audit.
+"""
+import os
+import sys
+
+# include ../ for ipasetup.py
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+from ipasetup import ipasetup  # noqa: E402
+
+ipasetup(
+    name="ipalib",
+    doc=__doc__,
+    package_dir={'ipalib': ''},
+    packages=[
+        "ipalib",
+    ],
+)
diff --git a/ipalib/setup.py.in b/ipalib/setup.py.in
deleted file mode 100644
index 2af0834..0000000
--- a/ipalib/setup.py.in
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/usr/bin/python2
-# Copyright (C) 2007  Red Hat
-# see file 'COPYING' for use and warranty information
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-
-"""FreeIPA common python library
-
-FreeIPA is a server for identity, policy, and audit.
-"""
-
-DOCLINES = __doc__.split("\n")
-
-import os
-import sys
-
-CLASSIFIERS = """\
-Intended Audience :: System Environment/Base
-License :: GPL
-Programming Language :: Python
-Operating System :: POSIX
-Operating System :: Unix
-"""
-
-# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
-# update it when the contents of directories change.
-if os.path.exists('MANIFEST'):
-    os.remove('MANIFEST')
-
-def setup_package():
-
-    from distutils.core import setup
-
-    old_path = os.getcwd()
-    local_path = os.path.dirname(os.path.abspath(sys.argv[0]))
-    os.chdir(local_path)
-    sys.path.insert(0,local_path)
-
-    try:
-        setup(
-            name = "ipalib",
-            version = "__VERSION__",
-            license = "GPL",
-            url = "http://www.freeipa.org/";,
-            description = DOCLINES[0],
-            long_description = "\n".join(DOCLINES[2:]),
-            download_url = "http://www.freeipa.org/page/Downloads";,
-            classifiers=[line for line in CLASSIFIERS.split('\n') if line],
-            platforms = ["Linux", "Solaris", "Unix"],
-            package_dir = {'ipalib': ''},
-            packages = ["ipalib"],
-        )
-    finally:
-        del sys.path[0]
-        os.chdir(old_path)
-    return
-
-if __name__ == '__main__':
-    setup_package()
diff --git a/ipaplatform/setup.cfg b/ipaplatform/setup.cfg
new file mode 100644
index 0000000..34abb12
--- /dev/null
+++ b/ipaplatform/setup.cfg
@@ -0,0 +1,5 @@
+[bdist_wheel]
+universal = 1
+
+[metadata]
+license_file = ../COPYING
diff --git a/ipaplatform/setup.py b/ipaplatform/setup.py
new file mode 100644
index 0000000..8b2d75d
--- /dev/null
+++ b/ipaplatform/setup.py
@@ -0,0 +1,42 @@
+#!/usr/bin/python2
+# Copyright (C) 2014  Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+"""FreeIPA platform
+
+FreeIPA is a server for identity, policy, and audit.
+"""
+import os
+import sys
+
+# include ../ for ipasetup.py
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+from ipasetup import ipasetup  # noqa: E402
+
+ipasetup(
+    name="ipaplatform",
+    doc=__doc__,
+    package_dir={'ipaplatform': ''},
+    packages=[
+        "ipaplatform",
+        "ipaplatform.base",
+        "ipaplatform.fedora",
+        "ipaplatform.redhat",
+        "ipaplatform.rhel"
+    ],
+)
diff --git a/ipaplatform/setup.py.in b/ipaplatform/setup.py.in
deleted file mode 100644
index 11bb757..0000000
--- a/ipaplatform/setup.py.in
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/python2
-# Copyright (C) 2014  Red Hat
-# see file 'COPYING' for use and warranty information
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-
-"""FreeIPA platform
-
-FreeIPA is a server for identity, policy, and audit.
-"""
-
-DOCLINES = __doc__.split("\n")
-
-import os
-import sys
-
-CLASSIFIERS = """\
-Development Status :: 4 - Beta
-Intended Audience :: System Environment/Base
-License :: GPL
-Programming Language :: Python
-Operating System :: POSIX
-Operating System :: Unix
-"""
-
-# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
-# update it when the contents of directories change.
-if os.path.exists('MANIFEST'):
-    os.remove('MANIFEST')
-
-def setup_package():
-
-    from distutils.core import setup
-
-    old_path = os.getcwd()
-    local_path = os.path.dirname(os.path.abspath(sys.argv[0]))
-    os.chdir(local_path)
-    sys.path.insert(0, local_path)
-
-    try:
-        setup(
-            name = "ipaplatform",
-            version = "__VERSION__",
-            license = "GPL",
-            author = "FreeIPA Developers",
-            author_email = "freeipa-devel@redhat.com",
-            maintainer = "FreeIPA Developers",
-            maintainer_email = "freeipa-devel@redhat.com",
-            url = "http://www.freeipa.org/";,
-            description = DOCLINES[0],
-            long_description = "\n".join(DOCLINES[2:]),
-            download_url = "http://www.freeipa.org/page/Downloads";,
-            classifiers=[line for line in CLASSIFIERS.split('\n') if line],
-            package_dir = {'ipaplatform': ''},
-            packages = ["ipaplatform",
-                        "ipaplatform.base",
-                        "ipaplatform.fedora",
-                        "ipaplatform.redhat",
-                        "ipaplatform.rhel"],
-        )
-    finally:
-        del sys.path[0]
-        os.chdir(old_path)
-    return
-
-if __name__ == '__main__':
-    setup_package()
diff --git a/ipapython/MANIFEST.in b/ipapython/MANIFEST.in
deleted file mode 100644
index d178f08..0000000
--- a/ipapython/MANIFEST.in
+++ /dev/null
@@ -1,2 +0,0 @@
-include *.conf
-
diff --git a/ipapython/Makefile b/ipapython/Makefile
index d262439..562d927 100644
--- a/ipapython/Makefile
+++ b/ipapython/Makefile
@@ -20,7 +20,7 @@ install:
 	done
 
 clean:
-	rm -f *~ *.pyc __pycache__/
+	rm -rf *~ *.pyc __pycache__/
 	@for subdir in $(SUBDIRS); do \
 		(cd $$subdir && $(MAKE) $@) || exit 1; \
 	done
diff --git a/ipapython/setup.cfg b/ipapython/setup.cfg
new file mode 100644
index 0000000..34abb12
--- /dev/null
+++ b/ipapython/setup.cfg
@@ -0,0 +1,5 @@
+[bdist_wheel]
+universal = 1
+
+[metadata]
+license_file = ../COPYING
diff --git a/ipapython/setup.py b/ipapython/setup.py
new file mode 100755
index 0000000..dd87e4b
--- /dev/null
+++ b/ipapython/setup.py
@@ -0,0 +1,44 @@
+#!/usr/bin/python2
+# Copyright (C) 2007  Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+"""FreeIPA python support library
+
+FreeIPA is a server for identity, policy, and audit.
+"""
+import os
+import sys
+
+# include ../ for ipasetup.py
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+from ipasetup import ipasetup  # noqa: E402
+
+ipasetup(
+    name="ipapython",
+    doc=__doc__,
+    package_dir={'ipapython': ''},
+    packages=[
+        "ipapython",
+        "ipapython.dnssec",
+        "ipapython.secrets",
+        "ipapython.install"
+    ],
+    package_data={
+        'ipapython': ['*.conf'],
+    },
+)
diff --git a/ipapython/setup.py.in b/ipapython/setup.py.in
deleted file mode 100755
index 3a4d126..0000000
--- a/ipapython/setup.py.in
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/python2
-# Copyright (C) 2007  Red Hat
-# see file 'COPYING' for use and warranty information
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-
-"""FreeIPA python support library
-
-FreeIPA is a server for identity, policy, and audit.
-"""
-
-DOCLINES = __doc__.split("\n")
-
-import os
-import sys
-
-CLASSIFIERS = """\
-Development Status :: 4 - Beta
-Intended Audience :: System Environment/Base
-License :: GPL
-Programming Language :: Python
-Operating System :: POSIX
-Operating System :: Unix
-"""
-
-# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
-# update it when the contents of directories change.
-if os.path.exists('MANIFEST'):
-    os.remove('MANIFEST')
-
-def setup_package():
-
-    from distutils.core import setup
-
-    old_path = os.getcwd()
-    local_path = os.path.dirname(os.path.abspath(sys.argv[0]))
-    os.chdir(local_path)
-    sys.path.insert(0,local_path)
-
-    try:
-        setup(
-            name = "ipapython",
-            version = "__VERSION__",
-            license = "GPL",
-            author = "Karl MacMillan, et.al.",
-            author_email = "kmacm...@redhat.com",
-            maintainer = "freeIPA Developers",
-            maintainer_email = "freeipa-devel@redhat.com",
-            url = "http://www.freeipa.org/";,
-            description = DOCLINES[0],
-            long_description = "\n".join(DOCLINES[2:]),
-            download_url = "http://www.freeipa.org/page/Downloads";,
-            classifiers=[line for line in CLASSIFIERS.split('\n') if line],
-            platforms = ["Linux", "Solaris", "Unix"],
-            package_dir = {'ipapython': ''},
-            packages = ["ipapython",
-                        "ipapython.dnssec",
-                        "ipapython.secrets",
-                        "ipapython.install"],
-        )
-    finally:
-        del sys.path[0]
-        os.chdir(old_path)
-    return
-
-if __name__ == '__main__':
-    setup_package()
diff --git a/ipasetup.py.in b/ipasetup.py.in
new file mode 100644
index 0000000..f291d22
--- /dev/null
+++ b/ipasetup.py.in
@@ -0,0 +1,71 @@
+#!/usr/bin/python2
+# Copyright (C) 2014  Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+import os
+import sys
+
+common_args = dict(
+    version="__VERSION__",
+    license="GPL",
+    author="FreeIPA Developers",
+    author_email="freeipa-devel@redhat.com",
+    maintainer="FreeIPA Developers",
+    maintainer_email="freeipa-devel@redhat.com",
+    url="http://www.freeipa.org/";,
+    download_url="http://www.freeipa.org/page/Downloads";,
+    platforms=["Linux", "Solaris", "Unix"],
+    classifiers=[
+        "Development Status :: 5 - Production/Stable",
+        ("Topic :: System :: Systems Administration :: "
+         "Authentication/Directory :: LDAP"),
+        "Topic :: Internet :: Name Service (DNS)",
+        "Intended Audience :: System Environment/Base",
+        "License :: GPL",
+        "Programming Language :: Python",
+        "Operating System :: POSIX",
+        "Operating System :: Unix",
+    ],
+)
+
+local_path = os.path.dirname(os.path.abspath(sys.argv[0]))
+old_path = os.path.abspath(os.getcwd())
+
+
+def ipasetup(name, doc, **kwargs):
+    doclines = doc.split("\n")
+
+    setup_kwargs = common_args.copy()
+    setup_kwargs.update(
+        name=name,
+        description=doclines[0],
+        long_description="\n".join(doclines[:2]),
+        **kwargs
+    )
+    # exclude setup helpers from getting installed
+    epd = setup_kwargs.setdefault('exclude_package_data', {})
+    epd.setdefault('', []).extend(['*/setup.py', '*/ipasetup.py'])
+
+    os.chdir(local_path)
+    try:
+        # BEFORE importing distutils, remove MANIFEST. distutils doesn't
+        # properly update it when the contents of directories change.
+        if os.path.isfile('MANIFEST'):
+            os.unlink('MANIFEST')
+        from setuptools import setup
+        return setup(**setup_kwargs)
+    finally:
+        os.chdir(old_path)
diff --git a/ipatests/setup.cfg b/ipatests/setup.cfg
new file mode 100644
index 0000000..34abb12
--- /dev/null
+++ b/ipatests/setup.cfg
@@ -0,0 +1,5 @@
+[bdist_wheel]
+universal = 1
+
+[metadata]
+license_file = ../COPYING
diff --git a/ipatests/setup.py b/ipatests/setup.py
new file mode 100644
index 0000000..86ee912
--- /dev/null
+++ b/ipatests/setup.py
@@ -0,0 +1,60 @@
+#!/usr/bin/python2
+# Copyright (C) 2007  Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+"""FreeIPA tests
+
+FreeIPA is a server for identity, policy, and audit.
+"""
+import os
+import sys
+
+# include ../ for ipasetup.py
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+from ipasetup import ipasetup  # noqa: E402
+
+ipasetup(
+    name="ipatests",
+    doc=__doc__,
+    package_dir={'ipatests': ''},
+    packages=[
+        "ipatests",
+        "ipatests.pytest_plugins",
+        "ipatests.test_cmdline",
+        "ipatests.test_install",
+        "ipatests.test_integration",
+        "ipatests.test_ipalib",
+        "ipatests.test_ipapython",
+        "ipatests.test_ipaserver",
+        "ipatests.test_ipaserver.test_install",
+        "ipatests.test_pkcs10",
+        "ipatests.test_webui",
+        "ipatests.test_xmlrpc",
+        "ipatests.test_xmlrpc.tracker"
+    ],
+    scripts=['ipa-run-tests', 'ipa-test-config', 'ipa-test-task'],
+    package_data={
+        'ipatests': ['pytest.ini'],
+        'ipatests.test_install': ['*.update'],
+        'ipatests.test_integration': ['scripts/*'],
+        'ipatests.test_ipalib': ['data/*'],
+        'ipatests.test_pkcs10': ['*.csr'],
+        "ipatests.test_ipaserver": ['data/*'],
+        'ipatests.test_xmlrpc': ['data/*'],
+    }
+)
diff --git a/ipatests/setup.py.in b/ipatests/setup.py.in
deleted file mode 100644
index 18483b0..0000000
--- a/ipatests/setup.py.in
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/usr/bin/python2
-# Copyright (C) 2007  Red Hat
-# see file 'COPYING' for use and warranty information
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-
-"""FreeIPA tests
-
-FreeIPA is a server for identity, policy, and audit.
-"""
-
-DOCLINES = __doc__.split("\n")
-
-import os
-import sys
-
-CLASSIFIERS = """\
-Development Status :: 4 - Beta
-Intended Audience :: System Environment/Base
-License :: GPL
-Programming Language :: Python
-Operating System :: POSIX
-Operating System :: Unix
-"""
-
-# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
-# update it when the contents of directories change.
-if os.path.exists('MANIFEST'):
-    os.remove('MANIFEST')
-
-def setup_package():
-
-    from distutils.core import setup
-
-    old_path = os.getcwd()
-    local_path = os.path.dirname(os.path.abspath(sys.argv[0]))
-    os.chdir(local_path)
-    sys.path.insert(0, local_path)
-
-    try:
-        setup(
-            name = "ipatests",
-            version = "__VERSION__",
-            license = "GPL",
-            author = "FreeIPA Developers",
-            author_email = "freeipa-devel@redhat.com",
-            maintainer = "FreeIPA Developers",
-            maintainer_email = "freeipa-devel@redhat.com",
-            url = "http://www.freeipa.org/";,
-            description = DOCLINES[0],
-            long_description = "\n".join(DOCLINES[2:]),
-            download_url = "http://www.freeipa.org/page/Downloads";,
-            classifiers=[line for line in CLASSIFIERS.split('\n') if line],
-            package_dir = {'ipatests': ''},
-            packages = ["ipatests",
-                        "ipatests.pytest_plugins",
-                        "ipatests.test_cmdline",
-                        "ipatests.test_install",
-                        "ipatests.test_integration",
-                        "ipatests.test_ipalib",
-                        "ipatests.test_ipapython",
-                        "ipatests.test_ipaserver",
-                        "ipatests.test_ipaserver.test_install",
-                        "ipatests.test_pkcs10",
-                        "ipatests.test_webui",
-                        "ipatests.test_xmlrpc",
-                        "ipatests.test_xmlrpc.tracker"],
-            scripts=['ipa-run-tests', 'ipa-test-config', 'ipa-test-task'],
-            package_data = {
-                'ipatests': ['pytest.ini'],
-                'ipatests.test_install': ['*.update'],
-                'ipatests.test_integration': ['scripts/*'],
-                'ipatests.test_ipalib': ['data/*'],
-                'ipatests.test_pkcs10': ['*.csr'],
-                "ipatests.test_ipaserver": ['data/*'],
-                'ipatests.test_xmlrpc': ['data/*'],
-            }
-        )
-    finally:
-        del sys.path[0]
-        os.chdir(old_path)
-    return
-
-if __name__ == '__main__':
-    setup_package()
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..472423d
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,5 @@
+[bdist_wheel]
+universal = 1
+
+[metadata]
+license_file = COPYING
diff --git a/setup.py b/setup.py
index 66bf7df..ec3c5db 100755
--- a/setup.py
+++ b/setup.py
@@ -23,15 +23,15 @@
 Python-level packaging using distutils.
 """
 
-from distutils.core import setup
 import ipalib
+from ipasetup import ipasetup  # pylint: disable=relative-import
 
 
-setup(
+ipasetup(
     name='freeipa',
+    doc=__doc__,
     version=ipalib.__version__,
-    license='GPLv3+',
-    url='http://freeipa.org/',
+    scripts=['ipa'],
     packages=[
         'ipaserver',
         'ipaserver.advise',
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to