Add hook in setup.py to update version string.
[crypto-install.git] / setup.py
1 #!/usr/bin/env python
2
3 import sys
4
5 from distutils.command.build import build
6 from distutils.core import setup
7 from setuptools import find_packages
8 from setuptools.command.test import test as TestCommand
9 from subprocess import call
10
11
12 class PyTest (TestCommand):
13     user_options = [("pytest-args=", "a", "Arguments to pass to py.test")]
14
15     def initialize_options (self):
16         TestCommand.initialize_options (self)
17         self.pytest_args = []
18
19     def finalize_options (self):
20         TestCommand.finalize_options (self)
21         self.test_args = []
22         self.test_suite = True
23
24     def run_tests (self):
25         # import here, cause outside the eggs aren't loaded
26         import pytest
27         sys.exit (pytest.main (self.pytest_args))
28
29
30 class UpdateVersion (build):
31     def run (self):
32         build.run (self)
33
34         def compile ():
35             call (["make", "build/crypto-install"])
36
37         self.execute (compile, [], "Updating version")
38
39
40 setup (name = "crypto_install",
41        version = "0.0.1",
42        scripts = ["crypto-install"],
43        install_requires = [],
44        tests_require = ["pytest"],
45        cmdclass = {
46            "test": PyTest,
47            "build": UpdateVersion
48        })