Skip to content

Commit 999160a

Browse files
authored
adding nightly builds (#5490)
* this isn't aesara anymore * release-job didn't exist * remove get_versions() * more functions, less faff * nicer f string * NIGHTLY is a global variable * testing nightly install with date in workflow
1 parent a0e43da commit 999160a

File tree

2 files changed

+68
-8
lines changed

2 files changed

+68
-8
lines changed

.github/workflows/nightly.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: nightly
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *"
6+
7+
jobs:
8+
build-and-publish-nightly:
9+
name: Build source distribution
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
- uses: actions/setup-python@v2
16+
with:
17+
python-version: 3.9
18+
- name: Install dependencies
19+
run: |
20+
python -m pip install -U pip
21+
python -m pip install build
22+
- name: Build the sdist
23+
run: python -m build --sdist .
24+
env:
25+
BUILD_PYMC_NIGHTLY: true
26+
- name: Publish to PyPI
27+
uses: pypa/[email protected]
28+
with:
29+
user: __token__
30+
password: ${{ secrets.nightly_pypi_secret }}
31+
test-install-job:
32+
needs: build-and-publish-nightly
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Set up Python
36+
uses: actions/setup-python@v2
37+
with:
38+
python-version: 3.9
39+
- name: Give PyPI a chance to update the index
40+
run: sleep 240
41+
- name: Install from PyPI
42+
run: |
43+
pip install pymc-nightly==${GITHUB_REF:11}.dev$(date +"%Y%m%d")

setup.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,21 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import os
1516
import re
1617

1718
from codecs import open
19+
from datetime import datetime, timezone
1820
from os.path import dirname, join, realpath
1921

2022
from setuptools import find_packages, setup
2123

22-
DISTNAME = "pymc"
2324
DESCRIPTION = "Probabilistic Programming in Python: Bayesian Modeling and Probabilistic Machine Learning with Aesara"
2425
AUTHOR = "PyMC Developers"
2526
AUTHOR_EMAIL = "[email protected]"
2627
URL = "http://github.com/pymc-devs/pymc"
2728
LICENSE = "Apache License, Version 2.0"
29+
NIGHLTY = "BUILD_PYMC_NIGHTLY" in os.environ
2830

2931
classifiers = [
3032
"Development Status :: 5 - Production/Stable",
@@ -54,21 +56,36 @@
5456
test_reqs = ["pytest", "pytest-cov"]
5557

5658

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()
6070
version_regex = r"^__version__ = ['\"]([^'\"]*)['\"]"
6171
for line in lines:
6272
mo = re.search(version_regex, line, re.M)
6373
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}.")
6683

6784

6885
if __name__ == "__main__":
6986
setup(
70-
name=DISTNAME,
71-
version=get_version(),
87+
name=get_distname(NIGHLTY),
88+
version=get_version(NIGHLTY),
7289
maintainer=AUTHOR,
7390
maintainer_email=AUTHOR_EMAIL,
7491
description=DESCRIPTION,

0 commit comments

Comments
 (0)