|
12 | 12 | # See the License for the specific language governing permissions and
|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
| 15 | +import os |
15 | 16 | import re
|
16 | 17 |
|
17 | 18 | from codecs import open
|
| 19 | +from datetime import datetime, timezone |
18 | 20 | from os.path import dirname, join, realpath
|
19 | 21 |
|
20 | 22 | from setuptools import find_packages, setup
|
21 | 23 |
|
22 |
| -DISTNAME = "pymc" |
23 | 24 | DESCRIPTION = "Probabilistic Programming in Python: Bayesian Modeling and Probabilistic Machine Learning with Aesara"
|
24 | 25 | AUTHOR = "PyMC Developers"
|
25 | 26 | AUTHOR_EMAIL = "[email protected]"
|
26 | 27 | URL = "http://github.com/pymc-devs/pymc"
|
27 | 28 | LICENSE = "Apache License, Version 2.0"
|
| 29 | +NIGHLTY = "BUILD_PYMC_NIGHTLY" in os.environ |
28 | 30 |
|
29 | 31 | classifiers = [
|
30 | 32 | "Development Status :: 5 - Production/Stable",
|
|
54 | 56 | test_reqs = ["pytest", "pytest-cov"]
|
55 | 57 |
|
56 | 58 |
|
57 |
| -def get_version(): |
58 |
| - VERSIONFILE = join("pymc", "__init__.py") |
59 |
| - lines = open(VERSIONFILE).readlines() |
| 59 | +def get_distname(nightly_build=False): |
| 60 | + distname = "pymc" |
| 61 | + if nightly_build: |
| 62 | + distname = f"{distname}-nightly" |
| 63 | + |
| 64 | + return distname |
| 65 | + |
| 66 | + |
| 67 | +def get_version(nightly_build=False): |
| 68 | + version_file = join("pymc", "__init__.py") |
| 69 | + lines = open(version_file).readlines() |
60 | 70 | version_regex = r"^__version__ = ['\"]([^'\"]*)['\"]"
|
61 | 71 | for line in lines:
|
62 | 72 | mo = re.search(version_regex, line, re.M)
|
63 | 73 | if mo:
|
64 |
| - return mo.group(1) |
65 |
| - raise RuntimeError(f"Unable to find version in {VERSIONFILE}.") |
| 74 | + version = mo.group(1) |
| 75 | + |
| 76 | + if nightly_build: |
| 77 | + suffix = datetime.now(timezone.utc).strftime(r".dev%Y%m%d") |
| 78 | + version = f"{version}{suffix}" |
| 79 | + |
| 80 | + return version |
| 81 | + |
| 82 | + raise RuntimeError(f"Unable to find version in {version_file}.") |
66 | 83 |
|
67 | 84 |
|
68 | 85 | if __name__ == "__main__":
|
69 | 86 | setup(
|
70 |
| - name=DISTNAME, |
71 |
| - version=get_version(), |
| 87 | + name=get_distname(NIGHLTY), |
| 88 | + version=get_version(NIGHLTY), |
72 | 89 | maintainer=AUTHOR,
|
73 | 90 | maintainer_email=AUTHOR_EMAIL,
|
74 | 91 | description=DESCRIPTION,
|
|
0 commit comments