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

[BUG] Permission denied error to install pkg editable and user mode #3019

Closed
1 task done
jinserk opened this issue Jan 9, 2022 · 19 comments · Fixed by #3151
Closed
1 task done

[BUG] Permission denied error to install pkg editable and user mode #3019

jinserk opened this issue Jan 9, 2022 · 19 comments · Fixed by #3151
Labels

Comments

@jinserk
Copy link

jinserk commented Jan 9, 2022

setuptools version

60.5.0

Python version

3.10.1

OS

Archlinux

Additional environment information

No response

Description

When I install a custom package with pip in user mode and editable, it produces permission denied error:

$ pip install --user --no-deps --no-use-pep517 -e .
Obtaining file:///home/jinserk/public/c2tk
  Preparing metadata (setup.py) ... done
Installing collected packages: c2tk
  Running setup.py develop for c2tk
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/jinserk/public/c2tk/setup.py'"'"'; __file__='"'"'/home/jinserk/public/c2tk/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix=
         cwd: /home/jinserk/public/c2tk/
    Complete output (7 lines):
    running develop
    /home/jinserk/.local/lib/python3.10/site-packages/setuptools/command/easy_install.py:156: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    /home/jinserk/.local/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    running egg_info
    error: [Errno 13] Permission denied
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/jinserk/public/c2tk/setup.py'"'"'; __file__='"'"'/home/jinserk/public/c2tk/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix= Check the logs for full command output.

Expected behavior

Install the package into $HOME/.local/lib/python3.10/site-packages

How to Reproduce

  1. Check you're using python 3.10.1
  2. upgrade all the build env
pip install -U pip setuptools wheel
  1. clone the repo:
git clone https://github.com/jinserk/c2tk.git
  1. Install it with pip, editable and user mode
cd c2tk
pip install --user --no-deps --no-use-pep517 -e .

Output

$ pip install --user --no-deps --no-use-pep517 -e .
Obtaining file:///home/jinserk/public/c2tk
  Preparing metadata (setup.py) ... done
Installing collected packages: c2tk
  Running setup.py develop for c2tk
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/jinserk/public/c2tk/setup.py'"'"'; __file__='"'"'/home/jinserk/public/c2tk/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix=
         cwd: /home/jinserk/public/c2tk/
    Complete output (7 lines):
    running develop
    /home/jinserk/.local/lib/python3.10/site-packages/setuptools/command/easy_install.py:156: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    /home/jinserk/.local/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    running egg_info
    error: [Errno 13] Permission denied
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/jinserk/public/c2tk/setup.py'"'"'; __file__='"'"'/home/jinserk/public/c2tk/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix= Check the logs for full command output.

Code of Conduct

  • I agree to follow the PSF Code of Conduct
@jinserk jinserk added bug Needs Triage Issues that need to be evaluated for severity and status. labels Jan 9, 2022
@abravalheri
Copy link
Contributor

Hi @jinserk, thank you very much for submitting this issue.
Could you please use the verbose mode in pip (-vvv) and also send us the log (not only the output)?
(you can specify a file to collect the logs with --log).

@abravalheri
Copy link
Contributor

Also, what would be your output for the command python3 -c 'import site; print(site.USER_SITE)'?

@jinserk
Copy link
Author

jinserk commented Jan 9, 2022

Thanks @abravalheri . Here is the log file using verbose option:

2022-01-09T18:12:57,862 Using pip 21.3.1 from /home/mpiuser/.local/lib/python3.10/site-packages/pip (python 3.10)
2022-01-09T18:12:57,863 User install by explicit request
2022-01-09T18:12:57,870 Created temporary directory: /tmp/pip-ephem-wheel-cache-g0zddrcv
2022-01-09T18:12:57,870 Created temporary directory: /tmp/pip-req-tracker-7ihl3bkf
2022-01-09T18:12:57,870 Initialized build tracking at /tmp/pip-req-tracker-7ihl3bkf
2022-01-09T18:12:57,871 Created build tracker: /tmp/pip-req-tracker-7ihl3bkf
2022-01-09T18:12:57,871 Entered build tracker: /tmp/pip-req-tracker-7ihl3bkf
2022-01-09T18:12:57,871 Created temporary directory: /tmp/pip-install-1w6d8y9d
2022-01-09T18:12:57,879 Obtaining file:///home/mpiuser/c2tk
2022-01-09T18:12:57,880   Added file:///home/mpiuser/c2tk to build tracker '/tmp/pip-req-tracker-7ihl3bkf'
2022-01-09T18:12:57,880   Running setup.py (path:/home/mpiuser/c2tk/setup.py) egg_info for package from file:///home/mpiuser/c2tk
2022-01-09T18:12:57,880   Created temporary directory: /tmp/pip-pip-egg-info-qouig4uy
2022-01-09T18:12:57,880   Running command python setup.py egg_info
2022-01-09T18:12:58,140   running egg_info
2022-01-09T18:12:58,141   creating /tmp/pip-pip-egg-info-qouig4uy/c2tk.egg-info
2022-01-09T18:12:58,142   writing manifest file '/tmp/pip-pip-egg-info-qouig4uy/c2tk.egg-info/SOURCES.txt'
2022-01-09T18:12:58,144   writing manifest file '/tmp/pip-pip-egg-info-qouig4uy/c2tk.egg-info/SOURCES.txt'
2022-01-09T18:12:58,162   running egg_info
2022-01-09T18:12:58,165   writing manifest file '/tmp/pip-pip-egg-info-qouig4uy/c2tk.egg-info/SOURCES.txt'
2022-01-09T18:12:58,196   Source in /home/mpiuser/c2tk has version 0.0.1, which satisfies requirement c2tk==0.0.1 from file:///home/mpiuser/c2tk
2022-01-09T18:12:58,196   Removed c2tk==0.0.1 from file:///home/mpiuser/c2tk from build tracker '/tmp/pip-req-tracker-7ihl3bkf'
2022-01-09T18:12:58,226 Created temporary directory: /tmp/pip-unpack-0txv5pep
2022-01-09T18:12:58,226 Installing collected packages: c2tk
2022-01-09T18:12:58,227   Running setup.py develop for c2tk
2022-01-09T18:12:58,227     Running command /usr/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/mpiuser/c2tk/setup.py'"'"'; __file__='"'"'/home/mpiuser/c2tk/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix=
2022-01-09T18:12:58,510     running develop
2022-01-09T18:12:58,510     /home/mpiuser/.local/lib/python3.10/site-packages/setuptools/command/easy_install.py:156: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
2022-01-09T18:12:58,510       warnings.warn(
2022-01-09T18:12:58,513     /home/mpiuser/.local/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
2022-01-09T18:12:58,513       warnings.warn(
2022-01-09T18:12:58,604     running egg_info
2022-01-09T18:12:58,604     error: [Errno 13] Permission denied
2022-01-09T18:12:58,640 ERROR: Command errored out with exit status 1: /usr/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/mpiuser/c2tk/setup.py'"'"'; __file__='"'"'/home/mpiuser/c2tk/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix= Check the logs for full command output.
2022-01-09T18:12:58,640 Exception information:
2022-01-09T18:12:58,640 Traceback (most recent call last):
2022-01-09T18:12:58,640   File "/home/mpiuser/.local/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 164, in exc_logging_wrapper
2022-01-09T18:12:58,640     status = run_func(*args)
2022-01-09T18:12:58,640   File "/home/mpiuser/.local/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
2022-01-09T18:12:58,640     return func(self, options, args)
2022-01-09T18:12:58,640   File "/home/mpiuser/.local/lib/python3.10/site-packages/pip/_internal/commands/install.py", line 404, in run
2022-01-09T18:12:58,640     installed = install_given_reqs(
2022-01-09T18:12:58,640   File "/home/mpiuser/.local/lib/python3.10/site-packages/pip/_internal/req/__init__.py", line 73, in install_given_reqs
2022-01-09T18:12:58,640     requirement.install(
2022-01-09T18:12:58,640   File "/home/mpiuser/.local/lib/python3.10/site-packages/pip/_internal/req/req_install.py", line 776, in install
2022-01-09T18:12:58,640     install_editable_legacy(
2022-01-09T18:12:58,640   File "/home/mpiuser/.local/lib/python3.10/site-packages/pip/_internal/operations/install/editable_legacy.py", line 43, in install_editable
2022-01-09T18:12:58,640     call_subprocess(
2022-01-09T18:12:58,640   File "/home/mpiuser/.local/lib/python3.10/site-packages/pip/_internal/utils/subprocess.py", line 254, in call_subprocess
2022-01-09T18:12:58,640     raise InstallationSubprocessError(proc.returncode, command_desc)
2022-01-09T18:12:58,640 pip._internal.exceptions.InstallationSubprocessError: Command errored out with exit status 1: /usr/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/mpiuser/c2tk/setup.py'"'"'; __file__='"'"'/home/mpiuser/c2tk/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps --user --prefix= Check the logs for full command output.
2022-01-09T18:12:58,646 Removed build tracker: '/tmp/pip-req-tracker-7ihl3bkf

and the result of site.USER_SITE:

$ python
Python 3.10.1 (main, Dec 18 2021, 23:53:45) [GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import site
>>> print(site.USER_SITE)
/home/mpiuser/.local/lib/python3.10/site-packages

@abravalheri
Copy link
Contributor

abravalheri commented Jan 17, 2022

Hi @jinserk, thank you very much for providing the logs.

Unfortunately pip does not help a lot by hiding the stack trace of the error 😞
So I will have to investigate it deeper. I am afraid it might take some time.

Meanwhile if you need to carry on with your work, please consider using an editable install inside a virtual environment.

@abravalheri abravalheri removed the Needs Triage Issues that need to be evaluated for severity and status. label Jan 17, 2022
@hexagonrecursion
Copy link
Contributor

@abravalheri
Copy link
Contributor

Thank you very much for the reference @hexagonrecursion, I still haven't had the time to dive into the issue, but this link will definitely be useful!

@hexagonrecursion
Copy link
Contributor

I have found a workaround:

import site
site.ENABLE_USER_SITE=True

from setuptools import setup
setup()

I do not know why ENABLE_USER_SITE is false when setup.py develop is executed via pip. Gotta run. Will look into this later.

@hexagonrecursion
Copy link
Contributor

if site.ENABLE_USER_SITE:
self.config_vars['userbase'] = self.install_userbase
self.config_vars['usersite'] = self.install_usersite
elif self.user:
log.warn("WARNING: The user site-packages directory is disabled.")

@abravalheri
Copy link
Contributor

@hexagonrecursion thank you very much for investigating that and solving it!
Would you like to open a PR?

@hexagonrecursion
Copy link
Contributor

Would you like to open a PR?

What PR? I'll open one once I have figured out how to fix it. For now I only know how to hack around the issue and even then I am not sure that my hack works properly. I am, havever, making progress towards uncovering the root cause.

@hexagonrecursion
Copy link
Contributor

hexagonrecursion commented Feb 25, 2022

sys.flags.no_user_site is true for some reason

def check_enableusersite():
    ...
    if sys.flags.no_user_site:
        # I inserted a print statement here while debugging
        return False
    ...
...
def main():
    global ENABLE_USER_SITE
    ...
    if ENABLE_USER_SITE is None:
        ENABLE_USER_SITE = check_enableusersite()
    ...

ref https://github.com/python/cpython/blob/eb002dbe0da9622245a355db5f0cd5aa2fc70b40/Lib/site.py#L242-L243

@hexagonrecursion
Copy link
Contributor

hexagonrecursion commented Feb 25, 2022

two questions for tomorrow me:

  • why does ENABLE_USER_SITE=False cause setuptools to try installing in /usr/local? Note: I have so far been unable to reproduce this effect outside pip: somehow python -s setup.py develop still works.
  • why is sys.flags.no_user_site True?

hexagonrecursion added a commit to hexagonrecursion/borg that referenced this issue Mar 1, 2022
A bug in pip or possibly setuptools broke editable
installs into the per-user directory
for packages that have pyproject.toml

See pypa/setuptools#3019
@hexagonrecursion
Copy link
Contributor

I have excluded pip and reduced it to:

  • Fails: python -s setup.py develop --user
  • Works: python setup.py develop --user
60.9.3 ENABLE_USER_SITE=False no_user_site=1
running develop
/usr/local/lib/python3.9/site-packages/setuptools/command/easy_install.py:160: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
WARNING: The user site-packages directory is disabled.
/usr/local/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: '/usr/local/lib/python3.9/site-packages/test-easy-install-3144.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /usr/local/lib/python3.9/site-packages/

Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

  https://setuptools.pypa.io/en/latest/deprecated/easy_install.html

Please make the appropriate changes for your system and try again.

setup.py

import site
import sys
import setuptools


print(f"{setuptools.__version__} ENABLE_USER_SITE={site.ENABLE_USER_SITE!r} no_user_site={sys.flags.no_user_site!r}")


setuptools.setup()

@hexagonrecursion
Copy link
Contributor

pip does not help a lot by hiding the stack trace of the error

pip is innocent: we hide the stack ourselves:

except (OSError, IOError):
self.cant_write_to_target()

@hexagonrecursion
Copy link
Contributor

hexagonrecursion commented Mar 3, 2022

I have figured out the pip side of the equation: PYTHONNOUSERSITE is set to 1 causing sys.flags.no_user_site = 1 in setup.py

https://github.com/pypa/pip/blob/d35bedc5cbb9f19217f6a42a68ab3c7f010fe694/src/pip/_internal/build_env.py#L141-L147

        os.environ.update(
            {
                "PATH": os.pathsep.join(path),
                "PYTHONNOUSERSITE": "1",
                "PYTHONPATH": os.pathsep.join(pythonpath),
            }
        )

Note: this is only true if you have pyproject.toml. Without pyproject.toml pip install -e <mypackage> works fine.

@hexagonrecursion
Copy link
Contributor

Summary of my debugging so far:

  • Without pyproject.toml pip install -e . runs setup.py 2 times:

    1. setup.py egg_info --egg-base /tmp/pip-pip-egg-info-twrrxz0k
    2. setup.py develop --no-deps --user --prefix=

    This appears to work fine. Both times ~/.local/lib/python3.9/site-packages is in sys.path

  • With pyproject.toml pip install -e . runs setup.py 3 times:

    1. egg_info via pep517
    2. dist_info via pep517
    3. setup.py develop --no-deps --user --prefix= via pip/_internal/operations/install/editable_legacy.py:install_editable
    args = make_setuptools_develop_args(
        setup_py_path,
        global_options=global_options,
        install_options=install_options,
        no_user_config=isolated,
        prefix=prefix,
        home=home,
        use_user_site=use_user_site,
    )
    
    with indent_log():
        with build_env:
            call_subprocess(
                args,
                command_desc="python setup.py develop",
                cwd=unpacked_source_directory,
            )

    In each of this three steps ~/.local/lib/python3.9/site-packages is not in sys.path. This is probably a good thing - we want build isolation, right?

    The third steps is what causes the issue: with build_env: sets PYTHONNOUSERSITE=1. This stops ~/.local/lib/python3.9/site-packages from being added to sys.path, but also sets site.ENABLE_USER_SITE.

    setup.py develop uses setuptools/command/easy_install.py

    For some reason easy_install decides to ignore --user and install into /usr/local/lib/python3.9/site-packages/ if site.ENABLE_USER_SITE=False

pip install -e . without pyproject.toml

{
  "path": [
    "",
    "/usr/lib64/python39.zip",
    "/usr/lib64/python3.9",
    "/usr/lib64/python3.9/lib-dynload",
    "/home/user/.local/lib/python3.9/site-packages",
    "/usr/local/lib/python3.9/site-packages",
    "/usr/lib64/python3.9/site-packages",
    "/usr/lib/python3.9/site-packages",
    "/home/user/hello/no-pro"
  ],
  "argv": [
    "/home/user/hello/no-pro/setup.py",
    "egg_info",
    "--egg-base",
    "/tmp/pip-pip-egg-info-twrrxz0k"
  ]
}
{
  "path": [
    "",
    "/usr/lib64/python39.zip",
    "/usr/lib64/python3.9",
    "/usr/lib64/python3.9/lib-dynload",
    "/home/user/.local/lib/python3.9/site-packages",
    "/usr/local/lib/python3.9/site-packages",
    "/usr/lib64/python3.9/site-packages",
    "/usr/lib/python3.9/site-packages",
    "/home/user/hello/no-pro"
  ],
  "argv": [
    "/home/user/hello/no-pro/setup.py",
    "develop",
    "--no-deps",
    "--user",
    "--prefix="
  ]
}

pip install -e . with pyproject.toml

{
  "path": [
    "/usr/lib/python3.9/site-packages/pip/_vendor/pep517",
    "/tmp/pip-build-env-5z25jrps/site",
    "/usr/lib64/python39.zip",
    "/usr/lib64/python3.9",
    "/usr/lib64/python3.9/lib-dynload",
    "/tmp/pip-build-env-5z25jrps/overlay/lib/python3.9/site-packages",
    "/tmp/pip-build-env-5z25jrps/overlay/lib64/python3.9/site-packages",
    "/tmp/pip-build-env-5z25jrps/normal/lib/python3.9/site-packages",
    "/tmp/pip-build-env-5z25jrps/normal/lib64/python3.9/site-packages"
  ],
  "argv": [
    "/usr/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py",
    "egg_info"
  ]
}
{
  "path": [
    "/usr/lib/python3.9/site-packages/pip/_vendor/pep517",
    "/tmp/pip-build-env-5z25jrps/site",
    "/usr/lib64/python39.zip",
    "/usr/lib64/python3.9",
    "/usr/lib64/python3.9/lib-dynload",
    "/tmp/pip-build-env-5z25jrps/overlay/lib/python3.9/site-packages",
    "/tmp/pip-build-env-5z25jrps/overlay/lib64/python3.9/site-packages",
    "/tmp/pip-build-env-5z25jrps/normal/lib/python3.9/site-packages",
    "/tmp/pip-build-env-5z25jrps/normal/lib64/python3.9/site-packages"
  ],
  "argv": [
    "/usr/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py",
    "dist_info",
    "--egg-base",
    "/tmp/pip-modern-metadata-0a_ne5zk"
  ]
}
{
  "path": [
    "",
    "/tmp/pip-build-env-5z25jrps/site",
    "/usr/lib64/python39.zip",
    "/usr/lib64/python3.9",
    "/usr/lib64/python3.9/lib-dynload",
    "/tmp/pip-build-env-5z25jrps/overlay/lib/python3.9/site-packages",
    "/tmp/pip-build-env-5z25jrps/overlay/lib64/python3.9/site-packages",
    "/tmp/pip-build-env-5z25jrps/normal/lib/python3.9/site-packages",
    "/tmp/pip-build-env-5z25jrps/normal/lib64/python3.9/site-packages",
    "/home/user/hello/pro"
  ],
  "argv": [
    "/home/user/hello/pro/setup.py",
    "develop",
    "--no-deps",
    "--user",
    "--prefix="
  ]
}
setup.py
import sys
import json

with open('log.txt', 'a') as log:
    o = {
        "path":sys.path,
        "argv":sys.argv,
    }
    json.dump(o, log)

import setuptools

setuptools.setup()
pyproject.toml
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

The plan

Build isolation is good. We should probably keep it. I will try to understand how and why easy_install decides where to install packages.

Possible fix ideas:

  • A. Make setup.py develop respect --user even if site.ENABLE_USER_SITE=False. Note: this may break other callers of setup.py develop --user if they rely on site.ENABLE_USER_SITE=False overriding --user
  • B. Or a surgical-strike: have pip set an environment variable HI_I_AM_PIP_AND_I_WANT_YOU_TO_RESPECT_MINUS_MINUS_USER and check it in easy_install

@hexagonrecursion
Copy link
Contributor

hexagonrecursion commented Mar 5, 2022

Related:

  1. 05ddf95

    HAS_USER_SITE = not sys.version < "2.6"

    My guess is that pyhton < "2.6" did not automatically add ~/.local/lib/.../site-packages to sys.path

  2. 152c6fa and 9456da4 - the culprit. No changelog, no docs, no bugtracker link - I can not understand why this change was made. @RonnyPfannschmidt, do you remember?

    HAS_USER_SITE = not sys.version < "2.6" and site.ENABLE_USER_SITE
  3. d52f186

  4. Make easy_install command less strict (fixes #1405) #1941

@RonnyPfannschmidt
Copy link
Contributor

I absolutely don't remember, this happened 12 years ago on bit bucket when it still supported mercurial, and it was on distribute prior to the re merge of the 2

hexagonrecursion added a commit to hexagonrecursion/setuptools that referenced this issue Mar 5, 2022
hexagonrecursion added a commit to hexagonrecursion/setuptools that referenced this issue Mar 5, 2022
hexagonrecursion added a commit to hexagonrecursion/setuptools that referenced this issue Mar 6, 2022
@kynan
Copy link

kynan commented Oct 2, 2022

Thanks @hexagonrecursion @jaraco for addressing this!

Just for completeness I'll mention that you're still "stuck" right now if you don't have root on your machine and system installed setuptools doesn't yet have this patch: in this case, even if you pip install --user --upgrade setuptools it won't help as build isolation will be ignoring the user site (with the patched setuptools) and use the system installed (unpatched) setuptools.

This will hopefully resolve itself soon as Linux distributions "catch up".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
@RonnyPfannschmidt @abravalheri @kynan @jinserk @hexagonrecursion and others