summaryrefslogtreecommitdiff
path: root/cffi/setuptools_ext.py
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2018-09-09 12:11:23 +0200
committerArmin Rigo <arigo@tunes.org>2018-09-09 12:11:23 +0200
commit518702892d8709d52453f1102d633d0c38a0af5e (patch)
treeeea722848037eb039b50332cce69866fd600af61 /cffi/setuptools_ext.py
parent01408ed73c4fb7112e17355d46068a5bc3e420ed (diff)
downloadcffi-518702892d8709d52453f1102d633d0c38a0af5e.tar.gz
"python setup.py sdist" should not list the generated ABI module.
See ``"python3 setup.py sdist" wrongly packages auto-generated file (out-of-line ABI-mode)`` on the mailing list.
Diffstat (limited to 'cffi/setuptools_ext.py')
-rw-r--r--cffi/setuptools_ext.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/cffi/setuptools_ext.py b/cffi/setuptools_ext.py
index 477ac43..a6eb8b8 100644
--- a/cffi/setuptools_ext.py
+++ b/cffi/setuptools_ext.py
@@ -162,6 +162,17 @@ def _add_py_module(dist, ffi, module_name):
module_path = module_name.split('.')
module_path[-1] += '.py'
generate_mod(os.path.join(self.build_lib, *module_path))
+ def get_source_files(self):
+ # This is called from 'setup.py sdist' only. Exclude
+ # the generate .py module in this case.
+ saved_py_modules = self.py_modules
+ try:
+ if saved_py_modules:
+ self.py_modules = [m for m in saved_py_modules
+ if m != module_name]
+ return base_class.get_source_files(self)
+ finally:
+ self.py_modules = saved_py_modules
dist.cmdclass['build_py'] = build_py_make_mod
# distutils and setuptools have no notion I could find of a
@@ -171,6 +182,7 @@ def _add_py_module(dist, ffi, module_name):
# the module. So we add it here, which gives a few apparently
# harmless warnings about not finding the file outside the
# build directory.
+ # Then we need to hack more in get_source_files(); see above.
if dist.py_modules is None:
dist.py_modules = []
dist.py_modules.append(module_name)