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

Allow arch dependent packages #331

Open
wants to merge 1 commit into
base: master
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
40 changes: 27 additions & 13 deletions pip/flatpak-pip-generator
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ parser.add_argument('--output', '-o',
help='Specify output file name')
parser.add_argument('--runtime',
help='Specify a flatpak to run pip inside of a sandbox, ensures python version compatibility')
parser.add_argument('--arch-dependent-allow', action='store_true',
help='Allow arch dependent packages to be used')
parser.add_argument('--arch-dependent-force', action='store_true',
help='Force arch dependent packages to be used')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README.md should have entries on these new parameters

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: shouldn't this have options to choose which arches are we targeting? Likes of arches-only and skip-arches?

Otherwise LGTM.

Copy link
Contributor

@bbhtt bbhtt Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: shouldn't this have options to choose which arches are we targeting? Likes of arches-only and skip-arches?

Otherwise LGTM.

That seems complicated and a future work. Currently, pip download cannot download a package for another arch unless you specify the whole pep 600 platform tag, eg. pip download --platform=manylinux_2_31_aarch64 --only-binary=:all: shiboken6

The tag varies from package to package due to the glibc version/package availability. There is also linux_aarch64/musllinux apart from manylinux.

There's also an issue where pip download doesn't handle legacy manylinux tag aliases too well pypa/pip#10760

It would need

a) Heuristics for guessing what value to pass to --platform

b) Modifying flatpak_cmd, based on (a)

I think for now it should be left to host/pip.

parser.add_argument('--yaml', action='store_true',
help='Use YAML as output format instead of JSON')
opts = parser.parse_args()
Expand Down Expand Up @@ -251,19 +255,29 @@ with tempfile.TemporaryDirectory(prefix=tempdir_prefix) as tempdir:
except FileNotFoundError:
pass

fprint('Downloading arch independent packages')
for filename in os.listdir(tempdir):
if not filename.endswith(('bz2', 'any.whl', 'gz', 'xz', 'zip')):
version = get_file_version(filename)
name = get_package_name(filename)
url = get_tar_package_url_pypi(name, version)
print('Deleting', filename)
try:
os.remove(os.path.join(tempdir, filename))
except FileNotFoundError:
pass
print('Downloading {}'.format(url))
download_tar_pypi(url, tempdir)
if opts.arch_dependent_force:
fprint('Not using arch independent packages [--arch-dependent-force]')
else:
fprint('Downloading arch independent packages')
for filename in os.listdir(tempdir):
if not filename.endswith(('bz2', 'any.whl', 'gz', 'xz', 'zip')):
version = get_file_version(filename)
name = get_package_name(filename)
try:
url = get_tar_package_url_pypi(name, version)
except Exception as e:
if not opts.arch_dependent_allow:
raise
else:
print('Ignoring "{}" [--arch-dependent-allow]'.format(e))
continue
print('Deleting', filename)
try:
os.remove(os.path.join(tempdir, filename))
except FileNotFoundError:
pass
print('Downloading {}'.format(url))
download_tar_pypi(url, tempdir)

files = {get_package_name(f): [] for f in os.listdir(tempdir)}

Expand Down