Skip to content

Commit 24947a0

Browse files
Automate pypi release (#135)
* adapted the release setup to mimic one used in pymc-marketing * fixed naming not matching in __init__ * fixing importing error for numpy * fixing command * adding numpy dependency to fix missing numpy error * fixing self import in setup.py * including versioneer, supressing pre-commit for versionner files * fixed build
1 parent 35f8919 commit 24947a0

File tree

11 files changed

+3060
-70
lines changed

11 files changed

+3060
-70
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pymc_experimental/_version.py export-subst

.github/workflows/pypi.yml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: PyPI
2+
on:
3+
pull_request:
4+
branches: [main]
5+
push:
6+
branches: [main]
7+
release:
8+
types: [published]
9+
10+
jobs:
11+
build:
12+
name: build source distribution
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
- uses: actions/setup-python@v4
19+
with:
20+
python-version: 3.8
21+
- name: Build the sdist and the wheel
22+
run: |
23+
pip install build
24+
python3 -m build
25+
- name: Check the sdist installs and imports
26+
run: |
27+
mkdir -p test-sdist
28+
cd test-sdist
29+
python -m venv venv-sdist
30+
venv-sdist/bin/python -m pip install ../dist/pymc-experimental*.tar.gz
31+
echo "Checking import and version number (on release)"
32+
venv-sdist/bin/python -c "import pymc_experimental as pmx; assert pmx.__version__ == '${{ github.ref_name }}' if '${{ github.ref_type }}' == 'tag' else pmx.__version__; print(pmx.__version__)"
33+
cd ..
34+
- name: Check the bdist installs and imports
35+
run: |
36+
mkdir -p test-bdist
37+
cd test-bdist
38+
python -m venv venv-bdist
39+
venv-bdist/bin/python -m pip install ../dist/pymc_experimental*.whl
40+
echo "Checking import and version number (on release)"
41+
venv-bdist/bin/python -c "import pymc_experimental as pmx; assert pmx.__version__ == '${{ github.ref_name }}' if '${{ github.ref_type }}' == 'tag' else pmx.__version__; print(pmx.__version__)"
42+
cd ..
43+
- uses: actions/upload-artifact@v3
44+
with:
45+
name: artifact
46+
path: dist/*
47+
test:
48+
name: upload to test PyPI
49+
needs: [build]
50+
runs-on: ubuntu-latest
51+
if: github.event_name == 'release' && github.event.action == 'published'
52+
steps:
53+
- uses: actions/download-artifact@v3
54+
with:
55+
name: artifact
56+
path: dist
57+
- uses: pypa/gh-action-pypi-publish@release/v1
58+
with:
59+
skip_existing: true
60+
user: __token__
61+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
62+
repository_url: https://test.pypi.org/legacy/
63+
- uses: actions/setup-python@v4
64+
with:
65+
python-version: 3.8
66+
- name: Test pip install from test.pypi
67+
run: |
68+
python -m venv venv-test-pypi
69+
venv-test-pypi/bin/python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple pymc-experimental
70+
echo "Checking import and version number"
71+
venv-test-pypi/bin/python -c "import pymc_experimental; assert pymc_experimental.__version__ == '${{ github.ref_name }}'"
72+
73+
publish:
74+
name: upload release to PyPI
75+
needs: [build, test]
76+
runs-on: ubuntu-latest
77+
if: github.event_name == 'release' && github.event.action == 'published'
78+
steps:
79+
- uses: actions/download-artifact@v3
80+
with:
81+
name: artifact
82+
path: dist
83+
- uses: pypa/gh-action-pypi-publish@release/v1
84+
with:
85+
user: __token__
86+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/release.yml

-48
This file was deleted.

.pre-commit-config.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,19 @@ repos:
2929
rev: v2.14.5
3030
hooks:
3131
- id: pylint
32+
exclude: versioneer.py
3233
args: [--rcfile=.pylintrc]
3334
files: ^pymc_experimental/
3435
- repo: https://github.com/MarcoGorelli/madforhooks
3536
rev: 0.3.0
3637
hooks:
3738
- id: no-print-statements
39+
exclude: _version.py
3840
files: ^pymc_experimental/
3941
- repo: local
4042
hooks:
4143
- id: no-relative-imports
44+
exclude: versioneer.py
4245
name: No relative imports
4346
entry: from \.[\.\w]* import
4447
types: [python]

MANIFEST.in

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include requirements*.txt
2+
include *.md *.rst
3+
include LICENSE
4+
include versioneer.py

docs/conf.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import os
3030
import sys
3131

32-
from pymc_experimental import __version__
32+
import pymc_experimental # isort:skip
3333

3434
sys.path.insert(0, os.path.abspath("../"))
3535

@@ -40,9 +40,9 @@
4040
author = "pymc-devs"
4141

4242
# The short X.Y version
43-
version = __version__
43+
version = pymc_experimental.__version__
4444
# The full version, including alpha/beta/rc tags
45-
release = __version__
45+
release = version
4646

4747

4848
# -- General configuration ---------------------------------------------------

pymc_experimental/__init__.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
15-
16-
__version__ = "0.0.2"
17-
1814
import logging
1915

2016
_log = logging.getLogger("pmx")
@@ -25,7 +21,8 @@
2521
handler = logging.StreamHandler()
2622
_log.addHandler(handler)
2723

28-
29-
from pymc_experimental import distributions, gp, utils
24+
from pymc_experimental import _version, distributions, gp, utils
3025
from pymc_experimental.inference.fit import fit
3126
from pymc_experimental.marginal_model import MarginalModel
27+
28+
__version__ = _version.get_versions()["version"]

0 commit comments

Comments
 (0)