From 1020f70891dace9f405a9f8d15ae84e6b8384fe1 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 8 Jun 2024 23:25:36 -0700 Subject: [PATCH] CODE_OF_CONDUCT.md, CONTRIBUTING.md, .github/workflows/dist.yml: Create using pipx run cruft create https://github.com/mkoeppe/sage --checkout sagemath-environment-cookiecutter --directory="pkgs/sage-project-cookiecutter/sage_project_cookiecutter/sagemath-upstream-package-template" --overwrite-if-exists --- .cruft.json | 12 ++++ .github/workflows/dist.yml | 135 +++++++++++++++++++++++++++++++++++++ CODE_OF_CONDUCT.md | 4 ++ CONTRIBUTING.md | 9 +++ 4 files changed, 160 insertions(+) create mode 100644 .cruft.json create mode 100644 .github/workflows/dist.yml create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md diff --git a/.cruft.json b/.cruft.json new file mode 100644 index 0000000..eec12ac --- /dev/null +++ b/.cruft.json @@ -0,0 +1,12 @@ +{ + "template": "https://github.com/mkoeppe/sage", + "commit": "395ca6708b260eda0da376a1847260cf7c841ebd", + "checkout": "sagemath-environment-cookiecutter", + "context": { + "cookiecutter": { + "project_name": "cysignals", + "_template": "https://github.com/mkoeppe/sage" + } + }, + "directory": "pkgs/sage-project-cookiecutter/sage_project_cookiecutter/sagemath-upstream-package-template" +} diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml new file mode 100644 index 0000000..7aa1d37 --- /dev/null +++ b/.github/workflows/dist.yml @@ -0,0 +1,135 @@ +name: Distributions + +on: + push: + pull_request: + workflow_dispatch: + +concurrency: + # Cancel previous runs of this workflow for the same branch + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + sdists_for_pypi: + name: Build sdist (and upload to PyPI on release tags) + runs-on: ubuntu-latest + env: + CAN_DEPLOY: ${{ secrets.SAGEMATH_PYPI_API_TOKEN != '' }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + - name: make sdist + run: | + python3 -m pip install build + python3 -m build --sdist + - uses: actions/upload-artifact@v3 + with: + path: "dist/*.tar.gz" + name: dist + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.SAGEMATH_PYPI_API_TOKEN }} + skip_existing: true + verbose: true + if: env.CAN_DEPLOY == 'true' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + + build_wheels: + name: Build wheels on ${{ matrix.os }}, arch ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + needs: sdists_for_pypi + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + arch: x86_64 + - os: ubuntu-latest + arch: i686 + - os: macos-latest + arch: auto + - os: macos-14 + arch: auto + env: + # SPKGs to install as system packages + SPKGS: _bootstrap _prereq + # Non-Python packages to install as spkgs + TARGETS_PRE: cysignals-build-deps + # Disable building PyPy wheels on all platforms + # Disable musllinux until #33083 provides alpine package information + CIBW_SKIP: "pp* *-musllinux*" + # + CIBW_ARCHS: ${{ matrix.arch }} + # https://cibuildwheel.readthedocs.io/en/stable/options/#requires-python + CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9" + # Environment during wheel build + CIBW_ENVIRONMENT: "PATH=$(pwd)/local/bin:$PATH CPATH=$(pwd)/local/include:$CPATH LIBRARY_PATH=$(pwd)/local/lib:$LIBRARY_PATH LD_LIBRARY_PATH=$(pwd)/local/lib:$LD_LIBRARY_PATH PKG_CONFIG_PATH=$(pwd)/local/share/pkgconfig:$PKG_CONFIG_PATH ACLOCAL_PATH=/usr/share/aclocal" + # Use 'build', not 'pip wheel' + CIBW_BUILD_FRONTEND: build + steps: + - uses: actions/checkout@v4 + with: + repository: sagemath/sage + ref: develop + + - uses: actions/download-artifact@v3 + with: + name: dist + path: dist + + - uses: actions/setup-python@v5 + # As of 2024-02-03, the macOS M1 runners do not have preinstalled python or pipx. + # Installing pipx follows the approach of https://github.com/pypa/cibuildwheel/pull/1743 + id: python + with: + python-version: "3.8 - 3.12" + update-environment: false + + - name: Build platform wheels + # We build the wheel from the sdist. + # But we must run cibuildwheel with the unpacked source directory, not a tarball, + # so that SAGE_ROOT is copied into the build containers. + # + # In the CIBW_BEFORE_ALL phase, we install libraries using the Sage distribution. + # https://cibuildwheel.readthedocs.io/en/stable/options/#before-all + run: | + "${{ steps.python.outputs.python-path }}" -m pip install pipx + export PATH=build/bin:$PATH + export CIBW_BEFORE_ALL="( $(sage-print-system-package-command debian --yes --no-install-recommends install $(sage-get-system-packages debian $SPKGS)) || $(sage-print-system-package-command fedora --yes --no-install-recommends install $(sage-get-system-packages fedora $SPKGS | sed s/pkg-config/pkgconfig/)) || ( $(sage-print-system-package-command homebrew --yes --no-install-recommends install $(sage-get-system-packages homebrew $SPKGS)) || echo error ignored) ) && ./bootstrap && ./configure --enable-build-as-root --enable-fat-binary && MAKE=\"make -j6\" make V=0 $TARGETS_PRE" + mkdir -p unpacked + for pkg in cysignals; do + (cd unpacked && tar xfz - ) < dist/$pkg*.tar.gz + "${{ steps.python.outputs.python-path }}" -m pipx run cibuildwheel==2.17.0 unpacked/$pkg* + done + + - uses: actions/upload-artifact@v3 + with: + name: wheels + path: ./wheelhouse/*.whl + + pypi-publish: + # https://github.com/pypa/gh-action-pypi-publish + name: Upload wheels to PyPI + needs: build_wheels + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + runs-on: ubuntu-latest + env: + CAN_DEPLOY: ${{ secrets.SAGEMATH_PYPI_API_TOKEN != '' }} + steps: + + - uses: actions/download-artifact@v3 + with: + name: wheels + path: wheelhouse + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.SAGEMATH_PYPI_API_TOKEN }} + packages_dir: wheelhouse/ + skip_existing: true + verbose: true + if: env.CAN_DEPLOY == 'true' diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..fcbba0a --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,4 @@ +This is an open-source project maintained by the SageMath community. + +The [Code of Conduct](https://github.com/sagemath/sage/blob/develop/CODE_OF_CONDUCT.md) +of the Sage community applies. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..9b416b5 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,9 @@ +This is an open-source project maintained by the SageMath community. + +Contributions of all sorts are heartily welcomed. + +See https://github.com/sagemath/sage/blob/develop/CONTRIBUTING.md for general +guidance on how to contribute. + +Open issues or submit pull requests at https://github.com/sagemath/cysignals +and join https://groups.google.com/group/sage-devel to discuss.