Skip to content

Commit

Permalink
update [pypi]
Browse files Browse the repository at this point in the history
  • Loading branch information
cmbant committed Jun 6, 2024
1 parent 4f63e9b commit 20d72d8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Wheels

on: [ push, pull_request ]

if: ${{ startsWith(github.ref, 'refs/tags/') || contains(github.event.commits.*.message, '[pypi]') }}

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
Expand Down Expand Up @@ -39,8 +41,6 @@ jobs:
MACOSX_DEPLOYMENT_TARGET: 13
CIBW_BUILD: cp311-*
CIBW_SKIP: pp*
#CIBW_TEST_REQUIRES: scipy sympy
#CIBW_TEST_COMMAND: python -m unittest camb.tests.camb_test
CIBW_BUILD_VERBOSITY: 1
run: python -m cibuildwheel --output-dir wheelhouse

Expand Down Expand Up @@ -109,13 +109,25 @@ jobs:
twine check --strict dist/*
twine check --strict dist-wheels/*
- name: Publish wheels to PyPI
- name: Publish wheels to PyPI Test
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: dist-wheels/

- name: Publish sdist to PyPI
- name: Publish sdist to PyPI Test
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

- name: Publish wheels to PyPI
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist-wheels/

- name: Publish sdist to PyPI
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: pypa/gh-action-pypi-publish@release/v1
11 changes: 9 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def make_library(cluster=False):
get_forutils()
print("Compiling source...")
subprocess.call("make python PYCAMB_OUTPUT_DIR=%s/camb/ CLUSTER_SAFE=%d" %
(pycamb_path, int(cluster)), shell=True)
(pycamb_path, int(cluster if not os.getenv("GITHUB_ACTIONS") else 1)), shell=True)
subprocess.call("chmod 755 %s" % lib_file, shell=True)

if not os.path.isfile(os.path.join(pycamb_path, 'camb', DLLNAME)):
Expand Down Expand Up @@ -276,7 +276,14 @@ def run(self):

def find_version():
version_file = open(os.path.join(file_dir, 'camb', '__init__.py')).read()
return re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M).group(1)
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
if version_match:
version = version_match.group(1)
commit = os.getenv('GITHUB_RUN_NUMBER')
if commit and not os.getenv('TRAVIS_TAG'):
version += '.' + commit
return version
raise RuntimeError("Unable to find version string.")


if __name__ == "__main__":
Expand Down

0 comments on commit 20d72d8

Please sign in to comment.