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

Broken pip executables for ubuntu jammy builders #717

Open
jericop opened this issue Mar 14, 2024 · 0 comments
Open

Broken pip executables for ubuntu jammy builders #717

jericop opened this issue Mar 14, 2024 · 0 comments

Comments

@jericop
Copy link
Contributor

jericop commented Mar 14, 2024

Expected Behavior

Any executables made available on the PATH by the cpython buildpack should work, including pip executables.

Current Behavior

When you try to run pip3, you get an error because python executable in the shebang of the script is not valid.

Below is an example of one of the broken pip executables (script).

#!/tmp/tmp.7dyEKmx8Dm/bin/python3.10
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal.cli.main import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

The reason for this is that they are shell scripts that reference a path that existed on the system where python was compiled, but are not available in the same path during a build (pack build my-app ...).

See here for the original discussion, which was discovered in another issue.

Possible Solution

I have a fully working solution in the branch below that removes any broken pip executables, complete with unit and integration tests. I can create a pull request at any time if it is decided that this is the best way to address this problem.

https://github.com/jericop/cpython/tree/remove-setuptools-and-broken-pip

One point that needs to be addressed is where the cleanup should occur. @arjun024 suggested, in this comment, that the broken pip executables could possibly be removed during the dependency compilation phase, which would be run during the pip-install buildpack. One challenge with that approach is that it would modify the cpython layer after the fact, which would affect cacheing and the sbom for the layer. In my opinion the cleanup should probably happen in the cpython buildpack, but I am open to other ideas and suggestions.

Steps to Reproduce

  1. Build any python example from the paketo samples repo and then try to execute pip3 list, or any other valid pip command. It will fail because the python interpreter referenced in the script is not valid.
git clone https://github.com/paketo-buildpacks/samples.git

pack build no-package-manager-sample --path samples/python/no_package_manager  --builder paketobuildpacks/builder-jammy-base

docker run -it --rm --entrypoint launcher no-package-manager-sample pip3 list

You will get the following error:

pip3: /layers/paketo-buildpacks_cpython/cpython/bin/pip3: /tmp/tmp.7dyEKmx8Dm/bin/python3.10: bad interpreter: No such file or directory

Motivations

As cpython buildpack user, I was surprised to find that the pip3 command available on the PATH did not work. I quickly worked around the issue by calling python -m pip instead, but I generally expect any command available on the PATH to actually function.

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

1 participant