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

Cannot install into user site directory with editable source. #7953

Open
agoose77 opened this issue Apr 1, 2020 · 43 comments · May be fixed by #9990
Open

Cannot install into user site directory with editable source. #7953

agoose77 opened this issue Apr 1, 2020 · 43 comments · May be fixed by #9990
Labels
C: build logic Stuff related to metadata generation / wheel generation C: editable Editable installations C: PEP 517 impact Affected by PEP 517 processing C: user scheme Handling of packages in user-specific directories type: bug A confirmed bug or unintended behavior

Comments

@agoose77
Copy link

agoose77 commented Apr 1, 2020

In build_env.py the environment variable PYTHONNOUSERSITE is set:

'PYTHONNOUSERSITE': '1',

This prevents editable installs with PYTHONUSERBASE=<some-user-base> pip3.8 install --user -e <some-file-path> from succeeding if the user does not have write access to the base-Python site-packages directory.

This is a snapshot of the error.

running develop
    WARNING: The user site-packages directory is disabled.
    error: can't create or remove files in install directory

It may be that it is a deliberate design choice to disable editable installs under a user site directory. I personally needed this feature, however, and I am therefore setting site.ENABLE_USER_SITE = True in setup.py as a workaround.

@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Apr 1, 2020
@ncoghlan
Copy link
Member

This affects the pipenv local build instructions in https://pipenv.pypa.io/en/latest/dev/contributing/#development-setup:

  • pip3 install -e . doesn't work as the global site-packages isn't writable by regular users
  • pip3 install --user -e . doesn't work due to pip indicating the user site directory is disabled

I'm adapting @agoose77's workaround into a PIPENV_BOOTSTRAP=1 environment variable.

@tristanvb
Copy link

Ran into this today on debian 9, not sure what has changed but we have been using pip3 install --user -e . for a long time for development purposes, it is strange for this to suddenly stop working.

@lpsinger
Copy link

Seeing this on macOS as well.

@tgpfeiffer
Copy link

I have seen this failing for a project that uses pyproject.toml (PEP517 install flow), where it works fine for projects without pyproject.toml. @siddalmia has described the same behavior in facebookresearch/fairseq#1977. I wonder if there is something in the PEP517 install flow that breaks this...?

@McSinyx
Copy link
Contributor

McSinyx commented Apr 23, 2020

@tgpfeiffer, please see the discussion on Discourse for more information. Aside from setup.py develop, another work around for packages with __main__.py is to run it directly, e.g. for pip: python src/pip.

@joshbode
Copy link

Following the tip from @agoose77, I'm putting this in my setup.py as a workaround:

import site
import sys
site.ENABLE_USER_SITE = "--user" in sys.argv[1:]
...

@ssbarnea
Copy link
Contributor

Nobody was able to fix this in pip? The whole idea of pep517 was to reduce use of setup.py ending in its removal, not adding more junk into to it.

ssbarnea added a commit to ssbarnea/molecule that referenced this issue Jun 19, 2020
Implements workaround for failure to install as editable on certain
cases when --user is mentioned.

Related: pypa/pip#7953
@pfmoore
Copy link
Member

pfmoore commented Jun 19, 2020

@ssbarnea PEP 517 doesn't support editable installs, so I don't see how PEP 517 is relevant here?

nebw added a commit to nebw/temporal_nmf that referenced this issue Jul 31, 2020
@maxnoe
Copy link

maxnoe commented Aug 13, 2020

@pfmoore you can support an editable install in a project using PEP 517 by adding a rather minimal setup.py.

But then, it is impossible to have -e and --user

@akaihola
Copy link
Contributor

@ssbarnea PEP 517 doesn't support editable installs, so I don't see how PEP 517 is relevant here?

I don't know, but doing a

pip install --user --no-use-pep517 -e .

succeeds, and after that a

pip install --user -e .

doesn't fail anymore. However, this still fails:

pip install --user --force-reinstall -e .

jschwartzentruber added a commit to jschwartzentruber/lithium that referenced this issue Sep 22, 2020
* Fix exception when invalid strategy is specified
ssbarnea added a commit to ansible-community/molecule-vagrant that referenced this issue Oct 10, 2020
ssbarnea added a commit to ansible-community/molecule-vagrant that referenced this issue Oct 10, 2020
jschwartzentruber added a commit to jschwartzentruber/lithium that referenced this issue Oct 21, 2020
* Fix exception when invalid strategy is specified
gberaudo added a commit to gberaudo/scrumtools that referenced this issue Dec 7, 2020
@jyn514
Copy link

jyn514 commented Feb 19, 2021

I also ran into this today. Is this intentionally not supported? I'm not sure why, I'd find it useful.

@ssbarnea
Copy link
Contributor

Apparently this is still broken at least for projects using PEP-517 (no setup.py). Tested with latest pip-22.2.2 and setuptools-65.3.0 but still reproduces.

I suspect it is related to built isolation stuff. Also worth noting another error when I tried to enforce pep517: --use-pep517 is not a valid editable requirement., same happens if I try to disable build isolation.

@tapetersen
Copy link

We had this problem on at least ubuntu 22.04 but it works with the most recent versions of pip and setuptools in the venv (which you get if you create the venv with --upgrade-deps) doesn't seem to work if you try to upgrade at least pip and setuptools after it's created though. For some reason system paths are added to the venv sys path.

@pradyunsg
Copy link
Member

That’s #11430

@kynan
Copy link
Contributor

kynan commented Oct 2, 2022

FTR: the setuptools tracking bug for this issue is pypa/setuptools#3019 and the fix (pypa/setuptools#3151) has been released in setuptools 62.0.0. Note however that you're still stuck if your system installed setuptools doesn't have this patch as upgrading your user site setuptools won't help (as that's the point of the build isolation).

@ssbarnea
Copy link
Contributor

ssbarnea commented Oct 24, 2022

Raised bugs against distros shipping outdated setuptools:

szymonlopaciuk added a commit to szymonlopaciuk/xsuite that referenced this issue Nov 2, 2022
This fixes an issue that arises due to the crossover of three
different problems:

1. Ubuntu 22.04 will be used by default on 'ubuntu' runners on GitHub runners
   (actions/runner-images#6399).

2. Ubuntu 22.04 ships with `setuptools` version 59.x.x, which has a bug that
   does not allow an `--editable` installation of packages in `--user` mode.
   The flag `--user` is presumed regardless, as the location with packages is
   not writable by normal users (see pypa/pip#7953
   and https://bugs.launchpad.net/ubuntu/+source/setuptools/+bug/1994016).

3. We need an `--editable` installation in order to run tests, as the
   `test_data` folder is loaded with respect to the package root, and
   not the test root (see for example:
   https://github.com/xsuite/xpart/blob/45d621ad060bc25d361835bde1ed985609a24c49/tests/test_single_rf_harmonic_matcher.py#L25)

Signed-off-by: Szymon Łopaciuk <[email protected]>
szymonlopaciuk added a commit to szymonlopaciuk/xsuite that referenced this issue Nov 2, 2022
Pin the GitHub runners to `ubuntu-20.04`. Long term solutions should be
explored at some point in the future.

This fixes an issue that arises due to the crossover of three different
problems:

1. Ubuntu 22.04 will be used by default on 'ubuntu' runners on GitHub runners
   (actions/runner-images#6399).

2. Ubuntu 22.04 ships with `setuptools` version 59.x.x, which has a bug that
   does not allow an `--editable` installation of packages in `--user` mode.
   The flag `--user` is presumed regardless, as the location with packages is
   not writable by normal users (see pypa/pip#7953
   and https://bugs.launchpad.net/ubuntu/+source/setuptools/+bug/1994016).

3. We need an `--editable` installation in order to run tests, as the
   `test_data` folder is loaded with respect to the package root, and
   not the test root (see for example:
   https://github.com/xsuite/xpart/blob/45d621ad060bc25d361835bde1ed985609a24c49/tests/test_single_rf_harmonic_matcher.py#L25)

Signed-off-by: Szymon Łopaciuk <[email protected]>
v3gtb added a commit to v3gtb/food-protein-chart that referenced this issue Nov 27, 2022
regisb added a commit to overhangio/openedx-release-demo that referenced this issue May 29, 2023
We are affected by this pip bug: pypa/pip#7953
The version of pip that ships with ubuntu 22.04 cannot install in
editable (-e) mode in the user directory (--user).
neilflood added a commit to neilflood/rios that referenced this issue May 27, 2024
neilflood added a commit to neilflood/rios that referenced this issue May 27, 2024
neilflood added a commit to neilflood/rios that referenced this issue May 28, 2024
neilflood added a commit to ubarsc/rios that referenced this issue May 28, 2024
* Apparently have to require the 'wheel' package be present

* setup.py: Workaround for pypa/pip#7953

* Keep flake8 happy

* Minor typos

* Comments now show only needs correct pip. The required setuptools can be specified in the requires=

* With guaranteed correct setuptools, can remove the fix for pypa/pip/issues/7953. Only need to sys.path modification to get version

* Extra github job to test on Ubuntu without conda

* Apparently need to install numpy, too

* Try without the apt-get update

* Can I sudo it?

* Remove redundant numpy install

* Rename future.pyproject.toml to pyproject.toml

* Update pyproj comments, now we have a way forward

* Just checking it fails when I think it should....

* Seems I no longer need the pip upgrade..... hmmm.....

* Update pyproj comments accordingly

* Turns out I need the pypa/pip#7953 fix for editable installs

* Turns out I need the pip>=23.0 for editable installs only. Added a note about this to pyproject.toml

* Remove old setup.py and bin/*.py

* Put back the pip upgrade, as it seems we need that when we don't have setup.py (maybe)

* Update comments about requirement for pip>=23.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: build logic Stuff related to metadata generation / wheel generation C: editable Editable installations C: PEP 517 impact Affected by PEP 517 processing C: user scheme Handling of packages in user-specific directories type: bug A confirmed bug or unintended behavior
Projects
None yet