diff options
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -1,5 +1,10 @@ | |||
1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
2 | 2 | ||
3 | import os | ||
4 | import shutil | ||
5 | import subprocess | ||
6 | from distutils import log | ||
7 | from distutils.core import Command | ||
3 | from setuptools.command.test import test | 8 | from setuptools.command.test import test |
4 | from setuptools import setup, find_packages | 9 | from setuptools import setup, find_packages |
5 | 10 | ||
@@ -21,6 +26,41 @@ class TestsWithCoverage(test): | |||
21 | cov.html_report() | 26 | cov.html_report() |
22 | 27 | ||
23 | 28 | ||
29 | class PyPiReleaseCommand(Command): | ||
30 | |||
31 | user_options = [] | ||
32 | description = "build and release artifacts to pypi" | ||
33 | |||
34 | def initialize_options(self): | ||
35 | pass | ||
36 | |||
37 | def finalize_options(self): | ||
38 | pass | ||
39 | |||
40 | def pip_install(self, *pkgs): | ||
41 | subprocess.check_call((".release/py3/bin/pip", "install", "-U") + pkgs) | ||
42 | |||
43 | def run(self): | ||
44 | if not os.path.exists(".release"): | ||
45 | log.info("Creating temp release tree") | ||
46 | os.mkdir(".release") | ||
47 | |||
48 | subprocess.check_call(["python3", "-m", "venv", ".release/py3"]) | ||
49 | self.pip_install("pip", "setuptools", "virtualenv", "twine") | ||
50 | |||
51 | log.info("Building Python 3 Artifact") | ||
52 | subprocess.check_call([ | ||
53 | ".release/py3/bin/python", | ||
54 | "setup.py", "release", "bdist_wheel", "--python-tag", "py3"]) | ||
55 | |||
56 | log.info("Building Source Dist Artifact") | ||
57 | subprocess.check_call([".release/py3/bin/python", "setup.py", "sdist"]) | ||
58 | subprocess.check_call([".release/py3/bin/twine", "upload", "dist/*"]) | ||
59 | |||
60 | log.info("Cleaning up temp release tree") | ||
61 | shutil.rmtree(".release") | ||
62 | |||
63 | |||
24 | setup( | 64 | setup( |
25 | name="pydora", | 65 | name="pydora", |
26 | version="2.0.0", | 66 | version="2.0.0", |
@@ -33,6 +73,7 @@ setup( | |||
33 | packages=find_packages(exclude=["tests", "tests.*"]), | 73 | packages=find_packages(exclude=["tests", "tests.*"]), |
34 | cmdclass={ | 74 | cmdclass={ |
35 | "test": TestsWithCoverage, | 75 | "test": TestsWithCoverage, |
76 | "pypi_release": PyPiReleaseCommand, | ||
36 | }, | 77 | }, |
37 | entry_points={ | 78 | entry_points={ |
38 | "console_scripts": [ | 79 | "console_scripts": [ |