Skip to content
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

scons install (python_package=full) fails on latest Ubuntu without virtual environment #1687

Closed
mefuller opened this issue Apr 2, 2024 · 2 comments

Comments

@mefuller
Copy link
Contributor

mefuller commented Apr 2, 2024

Problem description

Building and installing from source fails during the install phase on Ubuntu owing to a lack of virtual environment for pip. I think there should be a way to directly install system-wide, without a venv, from scons install.

Steps to reproduce

  1. scons build python_package=full
  2. scons test
  3. sudo scons install: fails without output provided below

Behavior

"/usr/bin/python3" -m pip install --no-build-isolation --no-deps -v --force-reinstall build/python
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.

    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.

    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.

    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
scons: *** [build/python/dummy] Error 1
scons: building terminated because of errors.

System information

  • Cantera version: ed27faf
  • OS: Ubuntu Mantic on WSL2
  • Python/MATLAB/other software versions: Python 3.11
@bryanwweber
Copy link
Member

bryanwweber commented Apr 3, 2024

Unfortunately, I don't think there's anything we can do about this. This is an error from pip, which obviously we don't control. I guess the only option is to replace pip as the installer, but I don't think there are any other installers out there and anyways this is codified in a PEP apparently so presumably other installers would have the same behavior. Frankly, I can't think of a good reason not to use a virtual environment, what's your use case here?

Edit: whoops I didn't read the error message, I guess we can add --break-system-packages to the install line. I'm not in favor of that, though, owing to not seeing a reason not to use a venv. Maybe we can add a scons option to add this option?

@speth
Copy link
Member

speth commented Apr 3, 2024

More specifically, this installation behavior is very explicitly being blocked by Debian's patched version of pip. I'm not particularly keen on adding an option just to circumvent this protection.

If you really want to specify this option, pip allows you to set this (and other arguments) via environment variables. Assuming you run scons with the env_vars=all option, I think you could specify this option by setting PIP_BREAK_SYSTEM_PACKAGES=1.

@speth speth closed this as not planned Won't fix, can't repro, duplicate, stale Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants