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

fix building of python modules that have tarballs named .tgz and .zip #2002

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions lib/fpm/package/python.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,20 @@ 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"))
if files.length != 1
# a single file and unpack it. Iterate over recognized file formats.
::Dir.chdir(build_path) do
files = ::Dir.glob(["*.tar.gz", "*.tgz"])
if files.length == 1
safesystem("tar", "-zxf", files[0], "-C", target)
break
end
files = ::Dir.glob("*.zip")
if files.length == 1
safesystem("unzip", files[0], "-d", target)
break
end
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)
else
# no pip, use easy_install
logger.debug("no pip, defaulting to easy_install", :easy_install => attributes[:python_easyinstall])
Expand Down