question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pyproject.toml (PEP518), build isolation (PEP517) and optional build dependencies

See original GitHub issue

What’s the problem this feature will solve?

Projects that have build requirements and optional build requirements can not use pyproject.toml because of the build isolation.

Example (https://bitbucket.org/fluiddyn/fluidfft): depending if mpi4py is installed, MPI extensions are built or not. It’s very important to be able to install/use the package without MPI so mpi4py can not be added in build-system.requires.

If a pyproject.toml is used, we get ImportError when importing mpi4py in the setup.py even when mpi4py is installed because of the isolation! So the MPI extensions are never build.

Describe the solution you’d like

Something like this could work:

[build-system]
# Minimum requirements for the build system to execute.
requires = [
    "setuptools", "wheel", "numpy", "cython", "jinja2", "fluidpythran>=0.1.7"
]
# packages that are used during the build only if they are installed
optional = ["mpi4py", "pythran"]

Then mpi4py would be available during the build only if it is installed. We keep the advantages of the isolation (discussed in https://www.python.org/dev/peps/pep-0517/) but optional build dependencies are allowed.

Alternative Solutions

[build-system]
# Minimum requirements for the build system to execute.
requires = [
    "setuptools", "wheel", "numpy", "cython", "jinja2", "fluidpythran>=0.1.7"
]
isolation = False

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:48 (29 by maintainers)

github_iconTop GitHub Comments

5reactions
paugiercommented, Jan 17, 2019

Really, this option --no-isolation is not a solution for us.

  1. I’d like to use the build-system.requires option of pyproject.toml. It would allow users to just do pip install fluidfft. Of course I don’t want to use --no-isolation because with this option, build-system.requires is not taken into account and we loose all the benefice of pyproject.toml.

  2. We need to be able to detect in setup.py if some packages are installed and if they are installed to use them during the build.

4reactions
paugiercommented, Jan 17, 2019

Then packages with optional build dependencies CAN NOT (and won’t be able to) use pyproject.toml ?

it is a problem! it is not something completely crazy to have a try: import ... except ImportError: in a setup.py.

Note that the solution with build-system.optional seems very simple to implement.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PEP 517 – A build-system independent format for source trees
Here we define a new style of source tree based around the pyproject.toml file defined in PEP 518, extending the [build-system] table in ......
Read more >
pyproject.toml - pip documentation v22.3.1
The overall process for building a package is: Create an isolated build environment. Populate the build environment with build dependencies. Generate the ...
Read more >
[Distutils] Re: pyproject.toml (PEP518), build isolation (PEP517) and ...
univ-grenoble-alpes.fr> wrote: > Hi, > I can't use pyproject.toml for some projects with "optional build > dependencies" because of build isolation.
Read more >
pip documentation v21.1.dev0
When PEP 517 is not used, the supported build system is setuptools . ... at install time using a pyproject.toml file, in the...
Read more >
Frequently Asked Questions - PyScaffold
... repository and tries to build it, the dependencies in pyproject.toml will be automatically pulled. This mechanism is described by PEP 517/PEP 518...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found