setup.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import re
  2. import sys
  3. from setuptools import setup
  4. from setuptools.command.test import test as TestCommand
  5. # Parse the version from the file.
  6. verstrline = open('git_archive_all.py', "rt").read()
  7. VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
  8. mo = re.search(VSRE, verstrline, re.M)
  9. if mo:
  10. verstr = mo.group(1)
  11. else:
  12. raise RuntimeError("Unable to find version string in git_archive_all.py")
  13. class PyTest(TestCommand):
  14. user_options = [("pytest-args=", "a", "Arguments to pass to pytest")]
  15. def initialize_options(self):
  16. TestCommand.initialize_options(self)
  17. self.pytest_args = ""
  18. def run_tests(self):
  19. import shlex
  20. # import here, cause outside the eggs aren't loaded
  21. import pytest
  22. errno = pytest.main(shlex.split(self.pytest_args))
  23. sys.exit(errno)
  24. setup(
  25. version=verstr,
  26. py_modules=['git_archive_all'],
  27. package_data={'git_archive_all': ['py.typed', '*.pyi']},
  28. entry_points={'console_scripts': 'git-archive-all=git_archive_all:main'},
  29. cmdclass={"test": PyTest},
  30. )