Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Simplest pyproject.toml containing build-system only #24102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,13 @@ jobs:

cat mplsetup.cfg

# 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
# 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 [[ "${{ runner.os }}" != 'macOS' ]]; then
unset CPPFLAGS
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = [
"certifi>=2020.06.20",
"numpy>=1.19",
"setuptools_scm>=7",
]
19 changes: 12 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
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
from setupext import print_raw, print_status

Expand Down Expand Up @@ -68,6 +71,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 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
Expand Down Expand Up @@ -208,8 +217,9 @@ def update_matplotlibrc(path):
class BuildPy(setuptools.command.build_py.build_py):
def run(self):
super().run()
update_matplotlibrc(
Path(self.build_lib, "matplotlib/mpl-data/matplotlibrc"))
if not self.editable_mode:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It surprised me to discover that when you build the main branch in editable mode this run function is not called. This branch does call the run function so here I am explicitly avoiding the update_matplotlibrc call when in editable mode to give the same behaviour as main branch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Editable (via pip/setuptools) is quite different from a regular build. I'm not an expert there, but have the feeling that if in doubt expectations on editable installs do not hold. Possibly pep660 will change that.

update_matplotlibrc(
Path(self.build_lib, "matplotlib/mpl-data/matplotlibrc"))


class Sdist(setuptools.command.sdist.sdist):
Expand Down Expand Up @@ -300,11 +310,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",
Expand Down