Skip to content

Commit 9a2c5ba

Browse files
author
Pan
committed
Add bdist_ext functionality to versioneer. Resolves #17
1 parent 923d4fe commit 9a2c5ba

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
cpython = platform.python_implementation() == 'CPython'
1313

1414
try:
15-
from Cython.Build import cythonize
1615
from Cython.Distutils.extension import Extension
1716
from Cython.Distutils import build_ext
1817
except ImportError:

versioneer.py

+26-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# Version: 0.18
2+
# Version: 0.18-1
33

44
"""The Versioneer - like a rocketeer, but for versions.
55
@@ -1559,6 +1559,31 @@ def run(self):
15591559
write_to_version_file(target_versionfile, versions)
15601560
cmds["build_py"] = cmd_build_py
15611561

1562+
if "setuptools" in sys.modules:
1563+
from setuptools.command.build_ext import build_ext as _build_ext
1564+
else:
1565+
from distutils.command.build_ext import build_ext as _build_ext
1566+
1567+
class cmd_build_ext(_build_ext):
1568+
def run(self):
1569+
root = get_root()
1570+
cfg = get_config_from_root(root)
1571+
versions = get_versions()
1572+
_build_ext.run(self)
1573+
if self.inplace:
1574+
# build_ext --inplace will only build modules in
1575+
# build/lib<..> dir with no _version.py to write to.
1576+
# As in place builds will already have a _version.py
1577+
# in the module dir, we do not need to write one.
1578+
return
1579+
# now locate _version.py in the new build/ directory and replace
1580+
# it with an updated value
1581+
target_versionfile = os.path.join(self.build_lib,
1582+
cfg.versionfile_source)
1583+
print("UPDATING %s" % target_versionfile)
1584+
write_to_version_file(target_versionfile, versions)
1585+
cmds["build_ext"] = cmd_build_ext
1586+
15621587
if "cx_Freeze" in sys.modules: # cx_freeze enabled?
15631588
from cx_Freeze.dist import build_exe as _build_exe
15641589
# nczeczulin reports that py2exe won't like the pep440-style string

0 commit comments

Comments
 (0)