Skip to content

Commit

Permalink
Merge pull request #2068 from mattaezell/pip_zip
Browse files Browse the repository at this point in the history
Support pip download returning a zip file
  • Loading branch information
jordansissel authored Dec 8, 2024
2 parents e66a359 + 790f53c commit ad4402f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/fpm/package/python.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,19 @@ def download_if_necessary(package, version=nil)
# behind a directory with the Python package extracted and ready to be used.
# For example, `pip download ... Django` puts `Django-4.0.4.tar.tz` into the build_path directory.
# If we expect `pip` to leave an unknown-named file in the `build_path` directory, let's check for
# a single file and unpack it. I don't know if it will /always/ be a .tar.gz though.
files = ::Dir.glob(File.join(build_path, "*.tar.gz"))
# a single file and unpack it.
files = ::Dir.glob(File.join(build_path, "*.{tar.gz,zip}"))
if files.length != 1
raise "Unexpected directory layout after `pip download ...`. This might be an fpm bug? The directory is #{build_path}"
end

safesystem("tar", "-zxf", files[0], "-C", target)
if files[0].end_with?("tar.gz")
safesystem("tar", "-zxf", files[0], "-C", target)
elsif files[0].end_with?("zip")
safesystem("unzip", files[0], "-d", target)
else
raise "Unexpected file format after `pip download ...`. This might be an fpm bug? The file is #{files[0]}"
end
else
# no pip, use easy_install
logger.debug("no pip, defaulting to easy_install", :easy_install => attributes[:python_easyinstall])
Expand Down

0 comments on commit ad4402f

Please sign in to comment.