diff --git a/.git_archival.txt b/.git_archival.txt index 95cb3eea4e33..3994ec0a83ea 100644 --- a/.git_archival.txt +++ b/.git_archival.txt @@ -1 +1,4 @@ +node: $Format:%H$ +node-date: $Format:%cI$ +describe-name: $Format:%(describe:tags=true)$ ref-names: $Format:%D$ diff --git a/.github/workflows/cibuildsdist.yml b/.github/workflows/cibuildsdist.yml new file mode 100644 index 000000000000..4e1d9085f5be --- /dev/null +++ b/.github/workflows/cibuildsdist.yml @@ -0,0 +1,64 @@ +name: Build CI sdist and wheel + +on: + # Save CI by only running this on release branches or tags. + push: + branches: + - main + - v[0-9]+.[0-9]+.x + tags: + - v* + # Also allow running this action on PRs if requested by applying the + # "Run cibuildwheel" label. + pull_request: + types: + - opened + - synchronize + - reopened + - labeled + +jobs: + build_sdist: + if: | + github.event_name == 'push' || + github.event_name == 'pull_request' && ( + ( + github.event.action == 'labeled' && + github.event.label.name == 'Run cibuildwheel' + ) || + contains(github.event.pull_request.labels.*.name, 'Run cibuildwheel') + ) + name: Build sdist and wheel on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-20.04] + python-version: ['3.8', '3.9', '3.10', '3.11.0-alpha - 3.11'] + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: actions/setup-python@v4 + name: Install Python + with: + python-version: ${{ matrix.python-version }} + + - name: Install build + run: pip install build + + - name: Build sdist and wheel + run: python -m build . + + - name: Install built matplotlib sdist + run: pip install dist/matplotlib*.tar.gz + + - name: Check version number is not 0 + run: python ./ci/check_version_number.py + + - name: Install built matplotlib wheel + run: pip install dist/matplotlib*.whl --force-reinstall + + - name: Check version number is not 0 + run: python ./ci/check_version_number.py diff --git a/ci/check_version_number.py b/ci/check_version_number.py new file mode 100644 index 000000000000..123eb721fb59 --- /dev/null +++ b/ci/check_version_number.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +""" +Check that the version number of the install Matplotlib does not start with 0 + +To run: + $ python3 -m build . + $ pip install dist/matplotlib*.tar.gz for sdist + $ pip install dist/matplotlib*.whl for wheel + $ ./ci/check_version_number.py +""" +import matplotlib + +import sys + +EXIT_SUCCESS = 0 +EXIT_FAILURE = 1 + + +print(f"Version {matplotlib.__version__} installed") +if matplotlib.__version__[0] == "0": + sys.exit(EXIT_FAILURE) +sys.exit(EXIT_SUCCESS) diff --git a/setup.py b/setup.py index 53131df5bb6b..e848a0968d31 100644 --- a/setup.py +++ b/setup.py @@ -302,8 +302,7 @@ def make_release_tree(self, base_dir, files): setup_requires=[ "certifi>=2020.06.20", "numpy>=1.19", - "setuptools_scm>=4", - "setuptools_scm_git_archive", + "setuptools_scm>=7", ], install_requires=[ "contourpy>=1.0.1", @@ -317,7 +316,7 @@ def make_release_tree(self, base_dir, files): "python-dateutil>=2.7", ] + ( # Installing from a git checkout that is not producing a wheel. - ["setuptools_scm>=4"] if ( + ["setuptools_scm>=7"] if ( Path(__file__).with_name(".git").exists() and os.environ.get("CIBUILDWHEEL", "0") != "1" ) else []