From c127355d1fef8e076f68bf57a126f95489fc7e75 Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Wed, 5 Oct 2022 21:33:54 +0100 Subject: [PATCH 1/7] Simplest pyproject.toml containing [build-system] only --- pyproject.toml | 7 +++++++ setup.py | 7 ++----- 2 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000000..ef70e1893299 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,7 @@ +[build-system] +build-backend = "setuptools.build_meta" +requires = [ + "certifi>=2020.06.20", + "numpy>=1.19", + "setuptools_scm>=7", +] diff --git a/setup.py b/setup.py index d1f1de7078ff..fc1f31e66a51 100644 --- a/setup.py +++ b/setup.py @@ -34,6 +34,8 @@ import setuptools.command.build_py import setuptools.command.sdist +sys.path.append(str(Path(__file__).resolve().parent)) + import setupext from setupext import print_raw, print_status @@ -300,11 +302,6 @@ def make_release_tree(self, base_dir, files): package_data=package_data, python_requires='>={}'.format('.'.join(str(n) for n in py_min_version)), - setup_requires=[ - "certifi>=2020.06.20", - "numpy>=1.19", - "setuptools_scm>=7", - ], install_requires=[ "contourpy>=1.0.1", "cycler>=0.10", From 54efcaebaad7c5cc4de3bc96655d72af9a2c6ecc Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Fri, 7 Oct 2022 17:44:47 +0100 Subject: [PATCH 2/7] Don't use build isolation on minimum versions CI run --- .github/workflows/tests.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0c5b7a08ced5..a564aa7af54f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -224,8 +224,9 @@ jobs: git describe # Set flag in a delayed manner to avoid issues with installing other - # packages - if [[ "${{ runner.os }}" != 'macOS' ]]; then + # packages. Only enabling coverage on minimum versions run as both + # need building using --no-build-isolation. + if [[ "${{ matrix.name-suffix }}" == '(Minimum Versions)' ]]; then if [[ "$(lsb_release -r -s)" == "20.04" ]]; then export CPPFLAGS='--coverage -fprofile-abs-path' else @@ -242,9 +243,13 @@ jobs: # All dependencies must have been pre-installed, so that the minver # constraints are held. - python -m pip install --no-deps -ve . + if [[ "${{ matrix.name-suffix }}" == '(Minimum Versions)' ]]; then + python -m pip install --no-deps --no-build-isolation -ve . + else + python -m pip install --no-deps -ve . + fi - if [[ "${{ runner.os }}" != 'macOS' ]]; then + if [[ "${{ matrix.name-suffix }}" == '(Minimum Versions)' ]]; then unset CPPFLAGS fi @@ -266,7 +271,7 @@ jobs: --extract coverage.info $PWD/src/'*' $PWD/lib/'*' lcov --list coverage.info find . -name '*.gc*' -delete - if: ${{ runner.os != 'macOS' }} + if: ${{ matrix.name-suffix == '(Minimum Versions)' }} - name: Upload code coverage uses: codecov/codecov-action@v3 From b06715aa39e454e6bc4abb981ff2c037567325e6 Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Sat, 8 Oct 2022 20:10:40 +0100 Subject: [PATCH 3/7] Temporarily pin setuptools in GHA --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a564aa7af54f..04e34df999ea 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -155,7 +155,7 @@ jobs: run: | # Upgrade pip and setuptools and wheel to get as clean an install as # possible. - python -m pip install --upgrade pip setuptools wheel + python -m pip install --upgrade pip 'setuptools<64' wheel # Install dependencies from PyPI. python -m pip install --upgrade $PRE \ From bdfd2ff043029078a46fd1f31e0ec95bce1c3409 Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Sun, 9 Oct 2022 17:08:49 +0100 Subject: [PATCH 4/7] Use local dir for build_temp if coverage enabled --- .github/workflows/tests.yml | 15 +++++++-------- setup.py | 6 ++++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 04e34df999ea..fd6eac7ce279 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -155,7 +155,7 @@ jobs: run: | # Upgrade pip and setuptools and wheel to get as clean an install as # possible. - python -m pip install --upgrade pip 'setuptools<64' wheel + python -m pip install --upgrade pip setuptools wheel # Install dependencies from PyPI. python -m pip install --upgrade $PRE \ @@ -224,9 +224,8 @@ jobs: git describe # Set flag in a delayed manner to avoid issues with installing other - # packages. Only enabling coverage on minimum versions run as both - # need building using --no-build-isolation. - if [[ "${{ matrix.name-suffix }}" == '(Minimum Versions)' ]]; then + # packages + if [[ "${{ runner.os }}" != 'macOS' ]]; then if [[ "$(lsb_release -r -s)" == "20.04" ]]; then export CPPFLAGS='--coverage -fprofile-abs-path' else @@ -241,15 +240,15 @@ jobs: cat mplsetup.cfg - # All dependencies must have been pre-installed, so that the minver - # constraints are held. if [[ "${{ matrix.name-suffix }}" == '(Minimum Versions)' ]]; then + # Minimum versions run does not use build isolation so that it + # builds against the pre-installed minver dependencies. python -m pip install --no-deps --no-build-isolation -ve . else python -m pip install --no-deps -ve . fi - if [[ "${{ matrix.name-suffix }}" == '(Minimum Versions)' ]]; then + if [[ "${{ runner.os }}" != 'macOS' ]]; then unset CPPFLAGS fi @@ -271,7 +270,7 @@ jobs: --extract coverage.info $PWD/src/'*' $PWD/lib/'*' lcov --list coverage.info find . -name '*.gc*' -delete - if: ${{ matrix.name-suffix == '(Minimum Versions)' }} + if: ${{ runner.os != 'macOS' }} - name: Upload code coverage uses: codecov/codecov-action@v3 diff --git a/setup.py b/setup.py index fc1f31e66a51..5d14be85f6e9 100644 --- a/setup.py +++ b/setup.py @@ -70,6 +70,12 @@ def has_flag(self, flagname): class BuildExtraLibraries(setuptools.command.build_ext.build_ext): def finalize_options(self): + # If coverage is enabled then need to keep the .o and .gcno files in a + # non-temporary directory otherwise coverage info is not collected. + cppflags = os.getenv('CPPFLAGS') + if cppflags and '--coverage' in cppflags: + self.build_temp = 'build' + self.distribution.ext_modules[:] = [ ext for package in good_packages From ff16e05bbdf45ca797b5daeaa436ae86fc772ea1 Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Sun, 9 Oct 2022 21:10:41 +0100 Subject: [PATCH 5/7] Edit matplotlibrc in place if editable mode install --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5d14be85f6e9..115e949e7293 100644 --- a/setup.py +++ b/setup.py @@ -216,8 +216,9 @@ def update_matplotlibrc(path): class BuildPy(setuptools.command.build_py.build_py): def run(self): super().run() + base_dir = "lib" if self.editable_mode else self.build_lib update_matplotlibrc( - Path(self.build_lib, "matplotlib/mpl-data/matplotlibrc")) + Path(base_dir, "matplotlib/mpl-data/matplotlibrc")) class Sdist(setuptools.command.sdist.sdist): From a925f0431f31a06097e6ed293af1d9ca45248152 Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Mon, 10 Oct 2022 21:50:24 +0100 Subject: [PATCH 6/7] Don't update matplotlibrc at all if editable_mode --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 115e949e7293..c642d1224a1c 100644 --- a/setup.py +++ b/setup.py @@ -216,9 +216,9 @@ def update_matplotlibrc(path): class BuildPy(setuptools.command.build_py.build_py): def run(self): super().run() - base_dir = "lib" if self.editable_mode else self.build_lib - update_matplotlibrc( - Path(base_dir, "matplotlib/mpl-data/matplotlibrc")) + if not self.editable_mode: + update_matplotlibrc( + Path(self.build_lib, "matplotlib/mpl-data/matplotlibrc")) class Sdist(setuptools.command.sdist.sdist): From 0e97a90a9c415c24186595ca1f5ed7c32f481a50 Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Tue, 11 Oct 2022 09:58:58 +0100 Subject: [PATCH 7/7] Improved comments --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c642d1224a1c..a460718684a8 100644 --- a/setup.py +++ b/setup.py @@ -34,6 +34,7 @@ import setuptools.command.build_py import setuptools.command.sdist +# sys.path modified to find setupext.py during pyproject.toml builds. sys.path.append(str(Path(__file__).resolve().parent)) import setupext @@ -71,7 +72,7 @@ def has_flag(self, flagname): class BuildExtraLibraries(setuptools.command.build_ext.build_ext): def finalize_options(self): # If coverage is enabled then need to keep the .o and .gcno files in a - # non-temporary directory otherwise coverage info is not collected. + # non-temporary directory otherwise coverage info not collected. cppflags = os.getenv('CPPFLAGS') if cppflags and '--coverage' in cppflags: self.build_temp = 'build'