Skip to content

Fix nightly upload pypi error #5563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: nightly

on:
schedule:
- cron: "0 0 * * *"

jobs:
build-and-publish-nightly:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install build
- name: Build the sdist
run: python -m build --sdist .
env:
BUILD_PYMC_NIGHTLY: true
- name: Publish to PyPI
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN_PYMC_NIGHTLY }}
test-install-job:
needs: build-and-publish-nightly
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Give PyPI a chance to update the index
run: sleep 240
- name: Install from PyPI
run: |
pip install pymc-nightly==${GITHUB_REF:11}.dev$(date +"%Y%m%d")
33 changes: 25 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import re

from codecs import open
from datetime import datetime, timezone
from os.path import dirname, join, realpath

from setuptools import find_packages, setup

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

classifiers = [
"Development Status :: 5 - Production/Stable",
Expand Down Expand Up @@ -54,21 +56,36 @@
test_reqs = ["pytest", "pytest-cov"]


def get_version():
VERSIONFILE = join("pymc", "__init__.py")
lines = open(VERSIONFILE).readlines()
def get_distname(nightly_build=False):
distname = "pymc"
if nightly_build:
distname = f"{distname}-nightly"

return distname


def get_version(nightly_build=False):
version_file = join("pymc", "__init__.py")
lines = open(version_file).readlines()
version_regex = r"^__version__ = ['\"]([^'\"]*)['\"]"
for line in lines:
mo = re.search(version_regex, line, re.M)
if mo:
return mo.group(1)
raise RuntimeError(f"Unable to find version in {VERSIONFILE}.")
version = mo.group(1)

if nightly_build:
suffix = datetime.now(timezone.utc).strftime(r".dev%Y%m%d")
version = f"{version}{suffix}"

return version

raise RuntimeError(f"Unable to find version in {version_file}.")


if __name__ == "__main__":
setup(
name=DISTNAME,
version=get_version(),
name=get_distname(NIGHLTY),
version=get_version(NIGHLTY),
maintainer=AUTHOR,
maintainer_email=AUTHOR_EMAIL,
description=DESCRIPTION,
Expand Down