diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 593d9c9f24..76b3b34181 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -17,27 +17,53 @@ concurrency: cancel-in-progress: true jobs: - # The job to build pypi wheels users can installed precompiled for them. - # At the moment only linux wheels are build, Windows and MacOS will compile on installation - # Before prebuilds all users had to compile code anyway. - build: + # The job to build precompiled pypi wheels. + make_sdist: + name: Make SDist + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Build SDist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v3 + with: + path: dist/*.tar.gz + + build_wheels: + name: Build ${{ matrix.python-version }} wheels on ${{ matrix.platform }} + runs-on: ${{ matrix.platform }} strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] - name: Build source distribution - runs-on: ubuntu-latest + platform: + - macos-12 + - windows-2022 + - ubuntu-20.04 steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions/setup-python@v4 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.11.4 + + - uses: actions/upload-artifact@v3 with: - python-version: ${{ matrix.python-version }} - - name: Build the sdist and the wheel - run: | - pip install build - python -m build - - name: Check the sdist installs and imports + path: ./wheelhouse/*.whl + + check_dist: + name: Check dist + needs: [make_sdist,build_wheels] + runs-on: ubuntu-22.04 + steps: + - uses: actions/download-artifact@v3 + with: + name: artifact + path: dist + - name: Check SDist run: | mkdir -p test-sdist cd test-sdist @@ -47,32 +73,21 @@ jobs: venv-sdist/bin/python -c "import pytensor;print(pytensor.__version__)" # check import cython module venv-sdist/bin/python -c 'from pytensor.scan import scan_perform; print(scan_perform.get_version())' - - name: Check the bdist installs and imports - run: | - mkdir -p test-bdist - cd test-bdist - python -m venv venv-bdist - venv-bdist/bin/python -m pip install ../dist/pytensor-*.whl - # check import - venv-bdist/bin/python -c "import pytensor;print(pytensor.__version__)" - # check import cython module - venv-bdist/bin/python -c 'from pytensor.scan import scan_perform; print(scan_perform.get_version())' - - uses: actions/upload-artifact@v3 - with: - name: artifact - path: dist/* + + - run: pipx run twine check --strict dist/* upload_pypi: name: Upload to PyPI on release - needs: [build] + needs: [check_dist] runs-on: ubuntu-latest if: github.event_name == 'release' && github.event.action == 'published' steps: - - uses: actions/download-artifact@v3 - with: - name: artifact - path: dist - - uses: pypa/gh-action-pypi-publish@v1.6.4 - with: - user: __token__ - password: ${{ secrets.pypi_secret }} + - uses: actions/download-artifact@v3 + with: + name: artifact + path: dist + + - uses: pypa/gh-action-pypi-publish@v1.5.0 + with: + user: __token__ + password: ${{ secrets.pypi_password }} diff --git a/pyproject.toml b/pyproject.toml index d1e96bbe44..0efa066d72 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ authors = [ ] description = "Optimizing compiler for evaluating mathematical expressions on CPUs and GPUs." readme = "README.rst" -license = {file = "LICENCE.txt"} +license = {file = "LICENSE.txt"} classifiers = [ "Development Status :: 6 - Mature", "Intended Audience :: Education", @@ -206,3 +206,18 @@ show_error_codes = true allow_redefinition = false files = ["pytensor", "tests"] plugins = ["numpy.typing.mypy_plugin"] + +[tool.cibuildwheel] +build = "*" +# Uncomment to skip builds that compile but fail when trying to test (maybe due to incompatibility with runner) +# archs = ["auto64"] +# Disable any-platform (pp*), and 32-bit builds. +# Additional options to consider: "*musllinux*" +skip = ["pp*", "*-win32", "*-manylinux_i686"] +build-frontend = "build" +test-command = 'python -c "import pytensor; print(pytensor.__version__); from pytensor.scan import scan_perform; print(scan_perform.get_version())"' +test-skip = ["cp37*", "*musllinux*", "*win32*", "*i686*"] + +# Testing seems to be running into issues locating libs where expected +# test-requires = ["pytest", "numba", "jax", "jaxlib"] +# test-command = "pytest {package}/tests"