summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2016-12-05 13:49:57 -0500
committerEli Collins <elic@assurancetechnologies.com>2016-12-05 13:49:57 -0500
commita5b216324dc843d7d46692baeea885fa47b1bdc1 (patch)
treeba99cc2ed6d7806ec8345e6908a38b067b1842a3
parent33d9acbbc4973f40d1dd04011fe5e8a24abab92e (diff)
downloadpasslib-a5b216324dc843d7d46692baeea885fa47b1bdc1.tar.gz
setup.py: exclude passlib._setup from bdists, only needed for sdists.
-rw-r--r--passlib/_setup/stamp.py43
-rw-r--r--setup.py10
2 files changed, 46 insertions, 7 deletions
diff --git a/passlib/_setup/stamp.py b/passlib/_setup/stamp.py
index 3140e5d..2ce3eb3 100644
--- a/passlib/_setup/stamp.py
+++ b/passlib/_setup/stamp.py
@@ -23,6 +23,15 @@ __all__ = [
def get_command_class(opts, name):
return opts['cmdclass'].get(name) or Distribution().get_command_class(name)
+def get_command_options(opts, command):
+ return opts.setdefault("command_options", {}).setdefault(command, {})
+
+def set_command_options(opts, command, _source_="setup.py", **kwds):
+ target = get_command_options(opts, command)
+ target.update(
+ (key, (_source_, value))
+ for key, value in kwds.items()
+ )
def _get_file(path):
with open(path, "r") as fh:
@@ -57,13 +66,15 @@ def stamp_source(base_dir, version, dry_run=False):
#
# update flag in setup.py
+ # (not present when called from bdist_wheel, etc)
#
path = os.path.join(base_dir, "setup.py")
- content = _get_file(path)
- content, count = re.subn('(?m)^stamp_build\s*=.*$',
- 'stamp_build = False', content)
- assert count == 1, "failed to update 'stamp_build' flag"
- _replace_file(path, content, dry_run=dry_run)
+ if os.path.exists(path):
+ content = _get_file(path)
+ content, count = re.subn('(?m)^stamp_build\s*=.*$',
+ 'stamp_build = False', content)
+ assert count == 1, "failed to update 'stamp_build' flag"
+ _replace_file(path, content, dry_run=dry_run)
def stamp_distutils_output(opts, version):
@@ -112,6 +123,28 @@ def append_hg_revision(version):
return version
+def install_build_py_exclude(opts):
+
+ _build_py = get_command_class(opts, "build_py")
+
+ class build_py(_build_py):
+
+ user_options = _build_py.user_options + [
+ ("exclude-packages=", None,
+ "exclude packages from builds"),
+ ]
+
+ exclude_packages = None
+
+ def finalize_options(self):
+ _build_py.finalize_options(self)
+ target = self.packages
+ for package in self.exclude_packages or []:
+ if package in target:
+ target.remove(package)
+
+ opts['cmdclass']['build_py'] = build_py
+
#=============================================================================
# eof
#=============================================================================
diff --git a/setup.py b/setup.py
index 1cf9598..9d7a13a 100644
--- a/setup.py
+++ b/setup.py
@@ -26,7 +26,6 @@ opts = dict(
#==================================================================
# sources
#==================================================================
- # XXX: could omit 'passlib._setup' for bdist_wheel & eggs
packages=setuptools.find_packages(root_dir),
package_data={
"passlib.tests": ["*.cfg"],
@@ -142,7 +141,8 @@ from passlib import __version__ as version
stamp_build = True # NOTE: modified by stamp_distutils_output()
if stamp_build:
from passlib._setup.stamp import (
- as_bool, append_hg_revision, stamp_distutils_output
+ as_bool, append_hg_revision, stamp_distutils_output,
+ install_build_py_exclude, set_command_options
)
# add HG revision to end of version
@@ -153,6 +153,12 @@ if stamp_build:
# and clears stamp_build flag so this doesn't run again.
stamp_distutils_output(opts, version)
+ # exclude 'passlib._setup' from builds, only needed for sdist
+ install_build_py_exclude(opts)
+ set_command_options(opts, "build_py",
+ exclude_packages=["passlib._setup"],
+ )
+
opts['version'] = version
#=============================================================================