From 01358eed96ed22e4ffc8d5e3e58459bc5b3df6f1 Mon Sep 17 00:00:00 2001 From: Patrick Hopf <> Date: Thu, 27 Jun 2024 22:27:24 +0200 Subject: [PATCH] prepare for beta release --- .github/workflows/build.yml | 211 ++++++------------------------------ MANIFEST.in | 1 + requirements.txt | 8 +- setup.cfg | 6 +- 4 files changed, 39 insertions(+), 187 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d99f56f..3db5b94 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,199 +11,50 @@ on: default: "" jobs: - # The deploy_test job is part of the test of whether we should deploy to PyPI - # or test.PyPI. The job will succeed if either the confirmation reference is - # empty, 'test' or if the confirmation is the selected branch or tag name. - # It will fail if it is nonempty and does not match. All later jobs depend - # on this job, so that they will be immediately cancelled if the confirmation - # is bad. The dependency is currently necessary (2021-03) because GitHub - # Actions does not have a simpler method of cancelling an entire workflow--- - # the normal use-case expects to try and run as much as possible despite one - # or two failures. - deploy_test: - name: Verify PyPI deployment confirmation - runs-on: ubuntu-latest - env: - GITHUB_REF: ${{ github.ref }} - CONFIRM_REF: ${{ github.event.inputs.confirm_ref }} - steps: - - name: Compare confirmation to current reference - shell: bash - run: | - [[ -z $CONFIRM_REF || $GITHUB_REF =~ ^refs/(heads|tags)/$CONFIRM_REF$ || $CONFIRM_REF == "test" ]] - if [[ $CONFIRM_REF == "test" ]]; then - echo "Build and deploy to test.pypi.org." - elif [[ -z $CONFIRM_REF ]]; then - echo "Build only. Nothing will be uploaded to PyPI." - else - echo "Full build and deploy. Wheels and source will be uploaded to PyPI." - fi - - build_sdist: - name: Build sdist on Ubuntu - needs: deploy_test - runs-on: ubuntu-latest - env: - OVERRIDE_VERSION: ${{ github.event.inputs.override_version }} - - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-python@v4 - name: Install Python - with: - # For the sdist we should be as conservative as possible with our - # Python version. This should be the lowest supported version. This - # means that no unsupported syntax can sneak through. - python-version: "3.10" - - - name: Install pip build - run: | - python -m pip install 'build' - - - name: Build sdist tarball - shell: bash - run: | - if [[ ! -z "$OVERRIDE_VERSION" ]]; then echo "$OVERRIDE_VERSION" > VERSION; fi - # The build package is the reference PEP 517 package builder. All - # dependencies are specified by our setup code. - python -m build --sdist . - - # Zip files are not part of PEP 517, so we need to make our own. - - name: Create zipfile from tarball - shell: bash - working-directory: dist - run: | - # First assert that there is exactly one tarball, and find its name. - shopt -s failglob - tarball_pattern="*.tar.gz" - tarballs=($tarball_pattern) - [[ ${#tarballs[@]} == 1 ]] - tarball="${tarballs[0]}" - # Get the stem and make the zipfile name. - stem="${tarball%.tar.gz}" - zipfile="${stem}.zip" - # Extract the tarball and rezip it. - tar -xzf "$tarball" - zip "$zipfile" -r "$stem" - rm -r "$stem" - - - uses: actions/upload-artifact@v3 - with: - name: sdist - path: | - dist/*.tar.gz - dist/*.zip - if-no-files-found: error - - build_wheels: - name: Build wheels on ${{ matrix.os }} - needs: deploy_test + build: + name: Build distribution 📦 runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - env: - # Set up wheels matrix. This is CPython 3.10--3.12 for all OS targets. - CIBW_BUILD: "cp3{10,11,12}-*" - # Numpy and SciPy do not supply wheels for i686 or win32 for - # Python 3.10+, so we skip those: - CIBW_SKIP: "*-musllinux* cp3{10,11,12}-manylinux_i686 cp3{10,11,12}-win32" - OVERRIDE_VERSION: ${{ github.event.inputs.override_version }} + os: [ubuntu-latest, windows-latest, macOS-latest] steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-python@v4 - name: Install Python + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 with: - # This is about the build environment, not the released wheel version. python-version: "3.10" - - name: Install cibuildwheel - run: | - # cibuildwheel does the heavy lifting for us. Originally tested on - # 2.11.3, but should be fine at least up to any minor new release. - python -m pip install 'cibuildwheel==2.11.*' - - - name: Build wheels - shell: bash - run: | - # If the version override was specified, then write it the VERSION - # file with it. - if [[ ! -z "$OVERRIDE_VERSION" ]]; then echo "$OVERRIDE_VERSION" > VERSION; fi - python -m cibuildwheel --output-dir wheelhouse - - - uses: actions/upload-artifact@v3 + run: >- + python3 -m + pip install + cibuildwheel + --user + - name: Build a binary wheel and a source tarball + run: python3 -m cibuildwheel --output-dir dist + - name: Store the distribution packages + uses: actions/upload-artifact@v3 with: - name: wheels - path: ./wheelhouse/*.whl + name: python-package-distributions + path: dist/ - deploy: - name: "Deploy to PyPI if desired" - # The confirmation is tested explicitly in `deploy_test`, so we know it is - # either a missing confirmation (so we shouldn't run this job), 'test' or a - # valid confirmation. We don't need to retest the value of the - # confirmation, beyond checking that one existed. + publish-to-pypi: + name: Publish Python 🐍 distribution 📦 to PyPI if: ${{ github.event.inputs.confirm_ref != '' && github.event.inputs.confirm_ref != 'test' }} - needs: [deploy_test, build_sdist, build_wheels] - runs-on: ubuntu-latest - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} - TWINE_NON_INTERACTIVE: 1 - TWINE_REPOSITORY: pypi - - steps: - - name: Download build artifacts to local runner - uses: actions/download-artifact@v3 - - - uses: actions/setup-python@v4 - name: Install Python - with: - python-version: "3.10" - - - name: Verify this is not a dev version - shell: bash - run: | - python -m pip install wheels/*-cp310-cp310-manylinux*.whl - python -c 'import qutip_qoc; print(qutip_qoc.__version__); assert "dev" not in qutip_qoc.__version__; assert "+" not in qutip_qoc.__version__' - - # We built the zipfile for convenience distributing to Windows users on - # our end, but PyPI only needs the tarball. - - name: Upload sdist and wheels to PyPI - run: | - python -m pip install "twine" - python -m twine upload --verbose wheels/*.whl sdist/*.tar.gz - - deploy_testpypi: - name: "Deploy to TestPyPI if desired" - if: ${{ github.event.inputs.confirm_ref == 'test' }} - needs: [deploy_test, build_sdist, build_wheels] + needs: + - build runs-on: ubuntu-latest - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.TESTPYPI_TOKEN }} - TWINE_NON_INTERACTIVE: 1 + environment: + name: pypi + url: https://pypi.org/p/qutip-qoc + permissions: + id-token: write steps: - - name: Download build artifacts to local runner + - name: Download all the dists uses: actions/download-artifact@v3 - - - uses: actions/setup-python@v4 - name: Install Python with: - python-version: "3.10" - - - name: Verify this is not a dev version - shell: bash - run: | - python -m pip install wheels/*-cp310-cp310-manylinux*.whl - python -c 'import qutip_qoc; print(qutip_qoc.__version__); assert "dev" not in qutip_qoc.__version__; assert "+" not in qutip_qoc.__version__' - - # We built the zipfile for convenience distributing to Windows users on - # our end, but PyPI only needs the tarball. - - name: Upload sdist and wheels to TestPyPI - run: | - python -m pip install "twine" - python -m twine upload --repository testpypi --verbose wheels/*.whl sdist/*.tar.gz + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/MANIFEST.in b/MANIFEST.in index 4681b1f..7eac3bf 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ include README.md +include VERSION include LICENSE include requirements.txt include pyproject.toml diff --git a/requirements.txt b/requirements.txt index 70eaeb7..cea30e5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,9 @@ cython>=1.0 numpy>=1.16.6 scipy>=1.10.1 -jax>=0.4.23 -jaxlib>=0.4.23 +jax==0.4.28 +jaxlib==0.4.28 qutip>=5.0.1 -qutip-qtrl @ git+https://github.com/qutip/qutip-qtrl.git@master -qutip-jax @ git+https://github.com/qutip/qutip-jax.git@master +qutip-qtrl +qutip-jax pre-commit diff --git a/setup.cfg b/setup.cfg index 1bb2a96..3d16ee1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,7 +8,7 @@ keywords = quantum, physics, dynamics license = BSD 3-Clause License license_files = LICENSE classifiers = - Development Status :: 2 - Pre-Alpha + Development Status :: 4 - Beta Intended Audience :: Science/Research License :: OSI Approved :: BSD License Programming Language :: Python @@ -32,8 +32,8 @@ install_requires = jaxlib packaging qutip - qutip-qtrl @ git+https://github.com/qutip/qutip-qtrl.git@master - qutip-jax @ git+https://github.com/qutip/qutip-jax.git@master + qutip-qtrl + qutip-jax setup_requires = cython>=1.0 packaging