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.

pip option to install PEP518 build dependencies to current environment

See original GitHub issue

What’s the problem this feature will solve?

This is to address three problems, one of which has been raised here before.

  1. You have a mixed Python/Cython project that you want to work on - this project lists its build dependencies (e.g. Cython) in pyproject.toml. You clone and install it with pip install -e ..

    Now, you make some changes to the project and want to recompile the cython files. So you try python setup.py build_ext --inplace. But that fails with e.g. ModuleNotFoundError: No module named 'Cython' because Cython was not installed to your current environment - it was only installed temporarily to the isolated environment when the project was initially installed.

    Other than manually installing the dependencies listed in pyproject.toml, which would be a little annoying, what can you do?

  2. Say you have project foo with a pyproject.toml that lists bar and other packages as build time dependencies. So now you make some changes to bar and install foo to see if foo still builds/works with the new bar changes. Unfortunately, because of build isolation, the last published bar package from pypi is used when you install foo.

    What you’d have liked instead is for you to be able to make pip use the newly generated wheel for bar when installing to the isolated build env.

    Again, other than turning off build isolation and manually installing all the pyproject.toml deps and bar, I don’t see a way around this.

  3. Optional dependencies. This has been brought up before here so I’ll quickly summarize it. They wanted a way to use pyproject.toml but also use whatever packages is installed in the current environment. The additional packages in the current environment would determine which optional dependencies are supported by the wheel being built.

Describe the solution you’d like

I’d like to request a new pip option where in addition to the --no-build-isolation option, we also have something like --install-build-deps. Also, maybe, when making an editable install it should default to using this option. What it does is it installs the build-time pyproject.toml listed dependencies to the current environment, rather than installing it into a isolated environment.

An alternate solution that was presented for #3 was a new --system-site-packages flag to be added so that whatever you have installed in the current environment is visible in the isolated build environment. While it does solve #3 and possibly #2, I think --install-build-deps is a better solution overall and resolves all three issues.

Specifically it’ll allow you to install all the build time dependencies to the current environment so that you can later manually install/build the project as you like with e.g. --no-build-isolation.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
uranusjrcommented, Jan 12, 2020

The tool needs to be installed on 3.7 (I lowered the requirements due to toolchain support), but can be used to develop a project against with older versions by using the --python option. I wrote some documentation around this. https://setl.readthedocs.io/en/latest/cmds.html#the-global-python-option

0reactions
pradyunsgcommented, Dec 16, 2022

Closing this out since I agree that this is not a role that pip needs to file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pip install - pip documentation v22.3.1
This section is only about installation order of runtime dependencies, and does not apply to build dependencies (those are specified using PEP 518)....
Read more >
pip documentation v21.1.dev0
As of version 10.0, pip supports projects declaring dependencies that are required at install time using a pyproject.toml file, in the form described...
Read more >
Dependency Management With Python Poetry
Use Poetry's Virtual Environment; Declare Your Dependencies; Install a ... When your Python project relies on external packages, you need to make sure ......
Read more >
Installing Python package in offline environment does not find ...
You need to add the install option --no-build-isolation when installing from source and you want to tell Pip to make use of already ......
Read more >
pip-install command man page - python3-pip | ManKier
python -m pip install [options] <requirement specifier> ... Build dependencies specified by PEP 518 must be already installed if this option is used....
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