Skip to content

Commit 87c64a0

Browse files
authored
Add none-any.whl (#435)
* Add none-any.whl Reason/Description: If the file is of type none-any.whl it can be used as well, because it is suitable for all architectures
1 parent a1eb29c commit 87c64a0

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

pip/flatpak-pip-generator

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def get_tar_package_url_pypi(name: str, version: str) -> str:
8383
url = 'https://pypi.org/pypi/{}/{}/json'.format(name, version)
8484
with urllib.request.urlopen(url) as response:
8585
body = json.loads(response.read().decode('utf-8'))
86-
for ext in ['bz2', 'gz', 'xz', 'zip']:
86+
for ext in ['bz2', 'gz', 'xz', 'zip', 'none-any.whl']:
8787
for source in body['urls']:
8888
if source['url'].endswith(ext):
8989
return source['url']
@@ -251,6 +251,8 @@ modules = []
251251
vcs_modules = []
252252
sources = {}
253253

254+
unresolved_dependencies_errors = []
255+
254256
tempdir_prefix = 'pip-generator-{}'.format(output_package)
255257
with tempfile.TemporaryDirectory(prefix=tempdir_prefix) as tempdir:
256258
pip_download = flatpak_cmd + [
@@ -288,14 +290,18 @@ with tempfile.TemporaryDirectory(prefix=tempdir_prefix) as tempdir:
288290
if not filename.endswith(('bz2', 'any.whl', 'gz', 'xz', 'zip')):
289291
version = get_file_version(filename)
290292
name = get_package_name(filename)
291-
url = get_tar_package_url_pypi(name, version)
293+
try:
294+
url = get_tar_package_url_pypi(name, version)
295+
print('Downloading {}'.format(url))
296+
download_tar_pypi(url, tempdir)
297+
except Exception as err:
298+
# Can happen if only an arch dependent wheel is available like for wasmtime-27.0.2
299+
unresolved_dependencies_errors.append(err)
292300
print('Deleting', filename)
293301
try:
294302
os.remove(os.path.join(tempdir, filename))
295303
except FileNotFoundError:
296304
pass
297-
print('Downloading {}'.format(url))
298-
download_tar_pypi(url, tempdir)
299305

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

@@ -506,3 +512,22 @@ with open(output_filename, 'w') as output:
506512
else:
507513
output.write(json.dumps(pypi_module, indent=4))
508514
print('Output saved to {}'.format(output_filename))
515+
516+
if len(unresolved_dependencies_errors) != 0:
517+
print("Unresolved dependencies. Handle them manually")
518+
for e in unresolved_dependencies_errors:
519+
print(f"- ERROR: {e}")
520+
521+
workaround = """Example how to handle wheels which only support specific architectures:
522+
- type: file
523+
url: https://files.pythonhosted.org/packages/79/ae/7e5b85136806f9dadf4878bf73cf223fe5c2636818ba3ab1c585d0403164/numpy-1.26.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
524+
sha256: 7ab55401287bfec946ced39700c053796e7cc0e3acbef09993a9ad2adba6ca6e
525+
only-arches:
526+
- aarch64
527+
- type: file
528+
url: https://files.pythonhosted.org/packages/3a/d0/edc009c27b406c4f9cbc79274d6e46d634d139075492ad055e3d68445925/numpy-1.26.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
529+
sha256: 666dbfb6ec68962c033a450943ded891bed2d54e6755e35e5835d63f4f6931d5
530+
only-arches:
531+
- x86_64
532+
"""
533+
raise Exception(f"Not all dependencies can be determined. Handle them manually.\n{workaround}")

0 commit comments

Comments
 (0)