I'm trying to build a package and for some reason when it's trying to install setuptools, it's running into issues:
$ python -m build
* Creating virtualenv isolated environment...
* Installing packages in isolated environment... (setuptools>=61.0)
Collecting setuptools>=61.0
Using cached setuptools-69.1.1-py3-none-any.whl (819 kB)
Installing collected packages: setuptools
Attempting uninstall: setuptools
Found existing installation: setuptools 59.6.0
Not uninstalling setuptools at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'setuptools'. No files were found to uninstall.
ERROR: Can't roll back setuptools; was not uninstalled
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/usr/local/lib/python3.10/dist-packages/distutils-precedence.pth'
Consider using the `--user` option or check the permissions.
Traceback (most recent call last):
File "/home/x/.local/lib/python3.10/site-packages/build/__main__.py", line 388, in main
built = build_call(
File "/home/x/.local/lib/python3.10/site-packages/build/__main__.py", line 239, in build_package_via_sdist
sdist = _build(isolation, srcdir, outdir, 'sdist', config_settings, skip_dependency_check)
File "/home/x/.local/lib/python3.10/site-packages/build/__main__.py", line 147, in _build
return _build_in_isolated_env(srcdir, outdir, distribution, config_settings)
File "/home/x/.local/lib/python3.10/site-packages/build/__main__.py", line 113, in _build_in_isolated_env
env.install(builder.build_system_requires)
File "/home/x/.local/lib/python3.10/site-packages/build/env.py", line 143, in install
_subprocess(cmd)
File "/home/x/.local/lib/python3.10/site-packages/build/env.py", line 64, in _subprocess
subprocess.run(cmd, check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
File "/usr/lib/python3.10/subprocess.py", line 526, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/tmp/build-env-l1ium7ru/local/bin/python', '-Im', 'pip', 'install', '--use-pep517', '--no-warn-script-location', '-r', '/tmp/build-reqs-f8wiyjft.txt']' returned non-zero exit status 1.
ERROR Command '['/tmp/build-env-l1ium7ru/local/bin/python', '-Im', 'pip', 'install', '--use-pep517', '--no-warn-script-location', '-r', '/tmp/build-reqs-f8wiyjft.txt']' returned non-zero exit status 1.
But when I try and see what version I have:
$ pip list | grep setuptools
setuptools 69.1.1
When I go into the directory /usr/lib/python3/dist-packages, there is a version 59.6.0:
$ ls /usr/lib/python3/dist-packages | grep setuptools
setuptools
setuptools-59.6.0.egg-info
I have both build and pip upgraded. As mentioned above I also have setuptools upgraded. It's saying it's permission issue (which yes, the files in /usr/lib/... are root) but the main question is, why is it trying to use the root version instead of the local version? Or am I doing something wrong?
(If I need to include extra files, just let me know)
To fix the issue I went ahead and just sudo'd into root and updated the package there. I still don't know why the local version was not updating properly.