Skip to content

Commit 9fa8cbd

Browse files
committed
pip: Update readme
1 parent 241d8b1 commit 9fa8cbd

2 files changed

Lines changed: 72 additions & 20 deletions

File tree

pip/flatpak-pip-generator.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,7 @@ def collect(compat_fn) -> list[dict]:
442442
return [make_source(pypi_sdist)], []
443443

444444
if any(is_platform_wheel(f["filename"]) for f in get_pypi_files()):
445-
return [], [
446-
f"{name}: Only platform wheels are available. "
447-
f"Use --prefer-wheels={name} to allow them."
448-
]
445+
return [], [f"__PLATFORM_ONLY__:{name}"]
449446

450447
return [], [f"{name}: No suitable source found on PyPI"]
451448

@@ -900,9 +897,8 @@ def to_ver(v: str) -> Version | None:
900897
modules: list[dict[str, str | list[str] | list[dict[str, Any]]]] = []
901898
vcs_modules: list[dict[str, str | list[str] | list[dict[str, Any]]]] = []
902899
sources: dict[str, Any] = {}
903-
904900
unresolved_dependencies_errors = []
905-
901+
prefer_wheels_missing: list[str] = []
906902
prefer_set = {normalize_name(p) for p in opts.prefer_wheels}
907903

908904
tempdir_prefix = f"pip-generator-{output_package}"
@@ -989,7 +985,14 @@ def to_ver(v: str) -> Version | None:
989985
)
990986

991987
for error in errors:
992-
unresolved_dependencies_errors.append(error)
988+
if error.startswith("__PLATFORM_ONLY__:"):
989+
pkg = error.removeprefix("__PLATFORM_ONLY__:")
990+
prefer_wheels_missing.append(pkg)
991+
unresolved_dependencies_errors.append(
992+
f"Only platform wheels are available for: {pkg}"
993+
)
994+
else:
995+
unresolved_dependencies_errors.append(error)
993996

994997
if resolved:
995998
sources[name_cf] = {
@@ -1179,4 +1182,12 @@ def dict_representer(
11791182
for e in unresolved_dependencies_errors:
11801183
print(f"- ERROR: {e}")
11811184

1185+
if prefer_wheels_missing:
1186+
pkgs = ",".join(sorted(set(prefer_wheels_missing)))
1187+
print(
1188+
f"\nOnly platform wheels are available for: {pkgs}. "
1189+
f"Use '--runtime $RUNTIME_ID//$RUNTIME_BRANCH --prefer-wheels={pkgs}'\n",
1190+
file=sys.stderr,
1191+
)
1192+
11821193
raise Exception("Unresolved dependencies. Handle them manually")

pip/readme.md

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,54 @@ You can use that in your manifest like
3838
]
3939
```
4040

41+
## Source Selection
42+
43+
By default, this tool selects artifacts from PyPI using the following
44+
priority: universal wheels (`none-any.whl`) > sdists.
45+
46+
If neither is available for a module, the an error is raised.
47+
Platform-specific wheels are ignored unless explicitly enabled via
48+
`--prefer-wheels=module1,module2,...`.
49+
50+
When `--prefer-wheels` is used, a Flatpak runtime must be provided with
51+
the `--runtime` argument. The runtime must include `Python`, `pip`, and
52+
`python-packaging` module. This is used to determine platform tags
53+
(Python version, ABI, and architecture).
54+
55+
By default, platform wheels are considered for the following
56+
`x86_64` and `aarch64`. This can be overridden with
57+
`--wheel-arches arch1 arch2 ...`.
58+
59+
If the specified runtime is only available for a single architecture,
60+
platform tags for other architectures are inferred from it.
61+
62+
## Examples for preferring platform wheels
63+
64+
### Generate for x86_64 and aarch64
65+
66+
```sh
67+
./flatpak-pip-generator --runtime org.freedesktop.Sdk//25.08 --prefer-wheels=cryptography,cffi cryptography
68+
```
69+
70+
### Generate for only x86_64
71+
72+
```sh
73+
./flatpak-pip-generator --runtime org.freedesktop.Sdk//25.08 --prefer-wheels=cryptography,cffi --wheel-arches x86_64 cryptography
74+
```
75+
76+
### Generate for x86_64 and ppc64le
77+
78+
```sh
79+
./flatpak-pip-generator --runtime org.freedesktop.Sdk//25.08 --prefer-wheels=cryptography,cffi --wheel-arches x86_64,ppc64le cryptography
80+
```
81+
4182
## Options
4283

4384
```
44-
usage: flatpak-pip-generator.py [-h] [--python2] [--cleanup {scripts,all}]
45-
[--requirements-file REQUIREMENTS_FILE]
46-
[--pyproject-file PYPROJECT_FILE] [--build-only]
47-
[--build-isolation][--ignore-installed IGNORE_INSTALLED]
48-
[--checker-data] [--output OUTPUT] [--runtime RUNTIME]
49-
[--yaml] [--ignore-errors] [--ignore-pkg [IGNORE_PKG ...]]
50-
[packages ...]
85+
usage: flatpak-pip-generator [-h] [--python2] [--cleanup {scripts,all}] [--requirements-file REQUIREMENTS_FILE] [--pyproject-file PYPROJECT_FILE] [--optdep-groups [GROUP ...]] [--build-only]
86+
[--build-isolation] [--ignore-installed IGNORE_INSTALLED] [--checker-data] [--output OUTPUT] [--runtime RUNTIME] [--yaml] [--ignore-errors] [--ignore-pkg [IGNORE_PKG ...]]
87+
[--prefer-wheels PREFER_WHEELS] [--wheel-arches WHEEL_ARCHES]
88+
[packages ...]
5189
5290
positional arguments:
5391
packages
@@ -61,20 +99,23 @@ options:
6199
Specify requirements.txt file. Cannot be used with pyproject file.
62100
--pyproject-file PYPROJECT_FILE
63101
Specify pyproject.toml file. Cannot be used with requirements file.
102+
--optdep-groups [GROUP ...]
103+
Specify optional dependency groups to include. Can only be used with pyproject file.
64104
--build-only Clean up all files after build
65105
--build-isolation Do not disable build isolation. Mostly useful on pip that does't support the feature.
66106
--ignore-installed IGNORE_INSTALLED
67-
Comma-separated list of package names for which pip should ignore already installed packages.
68-
Useful when the package is installed in the SDK but not in the runtime.
107+
Comma-separated list of package names for which pip should ignore already installed packages. Useful when the package is installed in the SDK but not in the runtime.
69108
--checker-data Include x-checker-data in output for the "Flatpak External Data Checker"
70109
--output, -o OUTPUT Specify output file name
71-
--runtime RUNTIME Specify a flatpak to run pip inside of a sandbox, ensures python version compatibility.
72-
Format: $RUNTIME_ID//$RUNTIME_BRANCH
110+
--runtime RUNTIME Specify a flatpak to run pip inside of a sandbox, ensures python version compatibility. Format: $RUNTIME_ID//$RUNTIME_BRANCH
73111
--yaml Use YAML as output format instead of JSON
74112
--ignore-errors Ignore errors when downloading packages
75113
--ignore-pkg [IGNORE_PKG ...]
76-
Ignore packages when generating the manifest. Needs to be specified
77-
with version constraints if present (e.g. --ignore-pkg 'foo>=3.0.0' 'baz>=21.0').
114+
Ignore packages when generating the manifest. Needs to be specified with version constraints if present (e.g. --ignore-pkg 'foo>=3.0.0' 'baz>=21.0').
115+
--prefer-wheels PREFER_WHEELS
116+
Comma-separated list of packages for which platform wheels should be preferred over sdists
117+
--wheel-arches WHEEL_ARCHES
118+
Comma-separated list of architectures for which platform wheels should be generated (default: x86_64,aarch64)
78119
```
79120

80121
## Development

0 commit comments

Comments
 (0)