fpm
fpm copied to clipboard
python: Check for pip when using pip.
When converting python packages, fpm now defaults to using pip as of #1820. However, not all python installations actually contain pip. For example, on Debian 11🗡️ the python3 package doesn't automatically provide pip -- you have to install python3-pip.
🗡️ I tested this using the docker.io/ruby:3.0.2 docker image which is based on Debian 11.
Here's the error message:
Running command {:args=>["python3", "-m", "pip", "download", "--no-clean", "--no-deps", "--no-binary", ":all:", "-d", "/tmp/package-python-build-2c477699cd74c76cc26dc416c750c553fb18fbc79bed4a993006b4698409", "-i", "https://pypi.python.org/simple", "django"], :level=>:debug, :file=>"fpm/util.rb", :line=>"138", :method=>"execmd"}
Process is running {:pid=>879, :level=>:debug, :file=>"fpm/util.rb", :line=>"147", :method=>"execmd"}
/usr/bin/python3: No module named pip {:level=>:info, :file=>"cabin/mixins/pipe.rb", :line=>"47", :method=>"block in pipe"}
Process failed: python3 failed (exit code 1). Full command was:["python3", "-m", "pip", "download", "--no-clean", "--no-deps", "--no-binary", ":all:", "-d", "/tmp/package-python-build-2c477699cd74c76cc26dc416c750c553fb18fbc79bed4a993006b4698409", "-i", "https://pypi.python.org/simple", "django"] {:level=>:error, :file=>"fpm/command.rb", :line=>"505", :method=>"rescue in execute"}
Proposal: fpm should check if python3 -m pip works and provide an actionable error message if possible.
I'm not exactly sure how to check if pip is available. Some tests:
- When not available,
python3 -m pipexits code 1 and prints an error message "/usr/bin/python3: No module named pip" - When available,
python3 -m pipexiits 0 and prints help messages. python3 -m pip config listprints nothing on a stock installation (debian 11) and exits 0. If pip is not available, this exits 1.