diff options
author | Konrad Weihmann <kweihmann@outlook.com> | 2020-07-10 18:58:04 +0200 |
---|---|---|
committer | Konrad Weihmann <kweihmann@outlook.com> | 2020-07-12 15:39:53 +0200 |
commit | c7e09792a392eeed4d712b40978b1b91b751a6d6 (patch) | |
tree | d48eb27de455cdb3ac2b183c9d0e9fc414c460c1 /setup.py | |
parent | 0374d7cf84ecd8182b74a639fcfdb9eafddcfd15 (diff) | |
download | gitpython-c7e09792a392eeed4d712b40978b1b91b751a6d6.tar.gz |
setup.py: exclude all test files
by using exclude feature of find_packages.
py_modules are determined by new function, which
recursively scans the base dir but omits the
external modules.
Plus remove now obselete package_data setting
Signed-off-by: Konrad Weihmann <kweihmann@outlook.com>
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 25 |
1 files changed, 22 insertions, 3 deletions
@@ -9,6 +9,7 @@ except ImportError: from distutils.command.build_py import build_py as _build_py from setuptools.command.sdist import sdist as _sdist +import fnmatch import os import sys from os import path @@ -66,6 +67,24 @@ def _stamp_version(filename): print("WARNING: Couldn't find version line in file %s" % filename, file=sys.stderr) +def build_py_modules(basedir, excludes=[]): + # create list of py_modules from tree + res = set() + _prefix = os.path.basename(basedir) + for root, _, files in os.walk(basedir): + for f in files: + _f, _ext = os.path.splitext(f) + if _ext not in [".py"]: + continue + _f = os.path.join(root, _f) + _f = os.path.relpath(_f, basedir) + _f = "{}.{}".format(_prefix, _f.replace(os.sep, ".")) + if any(fnmatch.fnmatch(_f, x) for x in excludes): + continue + res.add(_f) + return list(res) + + setup( name="GitPython", cmdclass={'build_py': build_py, 'sdist': sdist}, @@ -74,9 +93,9 @@ setup( author="Sebastian Thiel, Michael Trier", author_email="byronimo@gmail.com, mtrier@gmail.com", url="https://github.com/gitpython-developers/GitPython", - packages=find_packages('.'), - py_modules=['git.' + f[:-3] for f in os.listdir('./git') if f.endswith('.py')], - package_data={'git.test': ['fixtures/*']}, + packages=find_packages(exclude=("test.*")), + include_package_data=True, + py_modules=build_py_modules("./git", excludes=["git.ext.*"]), package_dir={'git': 'git'}, python_requires='>=3.4', install_requires=requirements, |