`Distribution.files` does not show files with absolute RECORD entries on Windows with Python 3.10 and 3.11
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 68/100
Rechercherichtung
Beginnen Sie in importlib_metadata/init.py bei etwa Zeile 1046 und reproduzieren Sie das Szenario mit dem Beispiel-Wheel unter Windows mit Python 3.10 oder 3.11. Überprüfen Sie die Verarbeitung absoluter RECORD-Einträge und verifizieren Sie anschließend, dass Distribution.files den Pfad zur ausführbaren Datei enthält, wie dies unter Python 3.12 und späteren Versionen der Fall ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
If an installed distribution contains absolute paths in the RECORD file, Distribution.files is missing these files. (installer writes absolute paths for executable scripts on Windows since https://github.com/pypa/installer/pull/286.)
To reproduce:
Build a sample project with an executable script
project structure:
sampleproject/
├── sample/
│ ├── __init__.py
│ └── __main__.py
└── pyproject.toml
pyproject.toml:
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "sample"
version = "0.1"
[project.scripts]
sample = "sample:__main__"
build project:
python -m venv build-venv
build-venv\Scripts\python.exe -m pip install build
build-venv\Scripts\python.exe -m build sampleproject
Install the built wheel with installer and display the distribution files:
python -m venv test-venv
test-venv\Scripts\python.exe -m pip install installer importlib-metadata
test-venv\Scripts\python.exe -m installer sampleproject\dist\sample-0.1-py3-none-any.whl
test-venv\Scripts\python.exe -c "from pprint import pprint; from importlib_metadata import distribution; pprint(distribution('sample').files)"
When using Python 3.12 or later to install the wheel and display the files the correct output is:
[PackagePath('sample-0.1.dist-info/METADATA'),
PackagePath('sample-0.1.dist-info/RECORD'),
PackagePath('sample-0.1.dist-info/WHEEL'),
PackagePath('sample-0.1.dist-info/entry_points.txt'),
PackagePath('sample-0.1.dist-info/top_level.txt'),
PackagePath('C:/temp/test-uninstall/test-venv/Scripts/sample.exe'),
PackagePath('sample/__init__.py'),
PackagePath('sample/__main__.py')]
When using Python 3.11 or 3.10 to install the wheel and display the files the executable script is missing:
[PackagePath('sample-0.1.dist-info/METADATA'),
PackagePath('sample-0.1.dist-info/RECORD'),
PackagePath('sample-0.1.dist-info/WHEEL'),
PackagePath('sample-0.1.dist-info/entry_points.txt'),
PackagePath('sample-0.1.dist-info/top_level.txt'),
PackagePath('sample/__init__.py'),
PackagePath('sample/__main__.py')]
The reason is the following difference in path operations:
>C:\python311\python.exe -c "from pathlib import Path, PurePosixPath; print(Path('C:/a') / PurePosixPath('C:/b/c'))"
C:\a\b\c
>C:\python312\python.exe -c "from pathlib import Path, PurePosixPath; print(Path('C:/a') / PurePosixPath('C:/b/c'))"
C:\b\c
This issue can be worked around by converting the PurePosixPath to str first:
>C:\python311\python.exe -c "from pathlib import Path, PurePosixPath; print(Path('C:/a') / str(PurePosixPath('C:/b/c')))"
C:\b\c
Would you be open to such a fix in https://github.com/python/importlib_metadata/blob/f09a4bd87e3ed8f8c3bda7074bc8f7b0dfb94d72/importlib_metadata/__init__.py#L1046 ?
- Vorherrschende Sprache
- Python
- Sterne
- 142
- Forks
- 97
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus python/importlib_metadata
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
python/importlib_metadata#528 · 4 Kommentare ·
-
documentation help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
python/importlib_metadata#526 · 6 Kommentare ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
python/importlib_metadata#525 · 2 Kommentare ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
python/importlib_metadata#540 · 1 Kommentar ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
python/importlib_metadata#534 · 1 Kommentar ·
Alle Issues in python/importlib_metadata
Ähnliche Issues
-
link-check link-check:sphinx-theme
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
OpenHands/extensions#626 · 1 Kommentar ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100
CSCfi/sd-search-api#39 ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100