Fix installations with system Python on Ubuntu/Fedora#31939
Fix installations with system Python on Ubuntu/Fedora#31939
Conversation
|
Why would it not have a bin directory? If it's version-specific, we can use |
|
I don't ask the questions, I just am trying to install flux-core and this is the error I hit. |
|
Can you upload the build log here? The fact that part of the installation is just missing is alarming... |
|
okay so this is weird, the build log looks okay? but in my terminal (and it exits on error): ==> Error: FileNotFoundError: [Errno 2] No such file or directory: '/opt/spack/opt/spack/linux-ubuntu22.04-x86_64/gcc-11.2.0/py-docutils-0.18.1-dcncvjgwszuwmanlasey434q3irm7q6d/bin'
/opt/spack/var/spack/repos/builtin/packages/py-docutils/package.py:42, in post_install:
40 def post_install(self):
41 bin_path = self.prefix.bin
>> 42 for file in os.listdir(bin_path):
43 if file.endswith(".py"):
44 os.symlink(os.path.join(bin_path, file), os.path.join(bin_path, file[:-3]))
See build log for details:
/tmp/root/spack-stage/spack-stage-py-docutils-0.18.1-dcncvjgwszuwmanlasey434q3irm7q6d/spack-build-out.txt
|
|
ping we'd like to get this working because it's failing the flux container build ping @trws |
|
I'm trying to repro this now, because trying it outside the container makes it work correctly and actually produces a bin directory no issue. |
|
@adamjstewart, something really strange is going on here. For some reason in this specific container (ubuntu 22.04 based) the directory tree in the prefix is placed under Is this maybe another crazy debianism we need to work around? |
|
It seems that if I switch the flag from |
|
And reading their docs it sounds like there is a third location, tools? https://docutils.sourceforge.io/docs/dev/distributing.html |
|
That is quite odd, I wouldn't expect pip to install things to |
|
Oh that's a good question. Yes it's just that one package, it's really, really odd. I didn't know that |
|
|
|
Why does flux need docutils? Could we make a variant that doesn't require it? |
|
Oh crap, I think I figured out why it's adding the local, but I'm arguing with myself about how to fix it... So, this python is set with its default |
Documentation, yes we could have a |
|
To follow up here - we tweaked the variant so it will build without error #32099, but if someone wants the docs they are still going to hit this issue. |
|
I'm hoping @pradyunsg will have an idea of why only this package is installing to the wrong location and what the best flags to use are. In the meantime, I marked this PR as a draft since the current PR is more of a workaround than a solution. |
|
Could someone share a clearer explaination of the behaviour you're seeing here, vs what you expected? 🙈 Something that shows the output of pip, as well the final filesystem structure you're seeing would help orient me as well. Right now, I've just read through the discussion and am not fully sure what the question is and what location is unexpected. |
|
The package is hard coded to expect docutils to have a bin. It does not, it has a local directory instead. |
|
@pradyunsg we are seeing the same issue as reported in pypa/pip#10978 Expected behaviorWe would expect Actual behaviorThings are being installed to: This causes all of our assumptions about the install layout to break, including patching of scripts in |
|
Are you using Fedora/RHEL-provided Python, outside of a virtual environment? If so, I'm pretty sure I've seen this before, and it's because of a patch that they've made to Python's site or sysconfig module that changes the installation scheme to be under a I've told at least two folks to report this to Fedora, but I don't know if anyone has reported this to them yet. :) |
|
Nope it was an ubuntu container. |
|
It's a Debian or Ubuntu one, they use a similar patch sadly, and yes we've complained about their munging of python a number of times, but this is the first time it's broken installation into an explicit prefix. |
|
Here's the patch, on 3.10: They likely have a similar one on older Python versions. |
|
To confirm whether we're right about this hypothesis, check if |
|
I've opened https://discuss.python.org/t/linux-distro-patches-to-sysconfig-are-changing-pip-install-prefix-outside-virtual-environments/18240 because this is broader than just Fedora and... non-trivial. Assuming this is the source of your issues, my pragmatic suggestion would be to check if there's a single |
|
I think @trws had the same idea, we can symlink everything in |
If docutils doesn't have a bin, then don't try to iterate over files in it.
Work around the debian and Fedora bug by symlinking the contents of the local directory if it appears.
422af55 to
bedbc2c
Compare
|
Basic patch implementing that added here @adamjstewart. |
| local_path = os.path.join(prefix, "local") | ||
| if os.path.isdir(local_path) and not os.path.isdir(os.path.join(prefix, "lib")): | ||
| for p in os.listdir(local_path): | ||
| os.symlink(os.path.join(local_path, p), os.path.join(prefix, p)) |
There was a problem hiding this comment.
If you're going to be thorough, setuptools, wheel, and dozens of other packages that don't use PythonPackage need this as well:
$ grep std_pip_args */package.py
cmor/package.py: args = std_pip_args + ["--prefix=" + prefix, "."]
faiss/package.py: args = std_pip_args + ["--prefix=" + prefix, "."]
fenics/package.py: args = std_pip_args + ["--prefix=" + self.prefix, "."]
flatbuffers/package.py: args = std_pip_args + ["--prefix=" + self.prefix, "."]
jsonnet/package.py: args = std_pip_args + ["--prefix=" + self.prefix, "."]
mxnet/package.py: args = std_pip_args + ["--prefix=" + prefix, "."]
py-dgl/package.py: args = std_pip_args + ["--prefix=" + prefix, "."]
py-jaxlib/package.py: args = std_pip_args + ["--prefix=" + self.prefix, "."]
py-keras/package.py: args = std_pip_args + ["--prefix=" + prefix, "."]
py-or-tools/package.py: args = std_pip_args + ["--prefix=" + prefix, "."]
py-pip/package.py: args = [os.path.join(whl, "pip")] + std_pip_args + ["--prefix=" + prefix, whl]
py-setuptools/package.py: args = ["-m", "pip"] + std_pip_args + ["--prefix=" + prefix, whl]
py-tensorboard-data-server/package.py: args = std_pip_args + ["--prefix=" + prefix, wheel]
py-tensorflow-estimator/package.py: args = std_pip_args + ["--prefix=" + prefix, "."]
py-tensorflow-hub/package.py: args = std_pip_args + ["--prefix=" + prefix, "."]
py-tensorflow-probability/package.py: args = std_pip_args + ["--prefix=" + prefix, "."]
py-tensorflow/package.py: args = std_pip_args + ["--prefix=" + prefix, "."]
py-tfdlpack/package.py: args = std_pip_args + ["--prefix=" + prefix, "."]
py-wheel/package.py: args = std_pip_args + ["--prefix=" + prefix, self.stage.archive_file]
sgpp/package.py: args = std_pip_args + ["--prefix=" + self.prefix, "."]
treelite/package.py: args = std_pip_args + ["--prefix=" + self.prefix, "."]There was a problem hiding this comment.
If these all have the same structure, should we make PythonManual (could use a better name) a new build system?
There was a problem hiding this comment.
Oof... some of these are much worse, Cmor is an autotools package that uses pip to install a module into its prefix, neither solution actually works for that without doing a view-like traversal.
There was a problem hiding this comment.
Curious what @alalazo thinks. We could extend both the current base class and PythonPackage and have this be a separate function that can be called in each package.
There was a problem hiding this comment.
Yeah, could do that. Could make it part of an Executable wrapper: pip_install say so that the command includes it? Even make it part of the existing callable pip from setup_dependent_packages?
|
@pradyunsg this is going to be a bit intrusive since we need to do this in dozens of places. Was this always the case with pip or is this bug only present in newer versions of pip? We could instead patch pip to restore the previous behavior if this is new. |
|
I'm going to close this. It won't work unless we do it in the base class and literally every package that invokes pip directly. I think the fix should either be on pip's side or on the side of the Debian/RHEL developers who broke things in the first place. |
If docutils doesn't have a bin, then don't try to iterate over files in it.