Document how to use pytest in packages using meson-python
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 45/100
- Issue-Typ
- Dokumentation
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- python
- Bereich
- build-system, documentation
Rechercherichtung
Beginnen Sie damit, die Projektdokumentation zu finden und den vorgeschlagenen Abschnitt Development with meson-python zu überprüfen. Reproduzieren Sie den beschriebenen Workflow mit meson.build, pyproject.toml, dem package/-Layout und pytest package/, nachdem Sie mit pip installiert haben. Dokumentieren Sie, wie die Testinstallation und Build-Optionen oder Installations-Tags die Entwicklung und Wheel-Builds beeinflussen, und erklären Sie dabei das Verhalten von pytest 8.0.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
There are two common directory layouts used by Python packages: tests source code alongside the Python source code, or tests source code in a dedicated package top-level directory. Some packages install the tests and some do not. AFAIU pytest 8.0 and later do not allow to have the tests files alongside the Python source code and execute them without installing them.
Example, given a package source code structure looking like:
meson.build
package/
__init__.py
_foo.pyx
foo.py
foo_test.py
pyproject.toml
The package needs to be installed to build the Cython extension module:
python -m pip install --no-build-isolation -e .
However, if foo_test.py is not installed, running pytest package/ results in tests loading errors because pytest imports pacakage.fo_test, which puts the package folder in the source directory in the modules cache, and it does not contain the _foo extension module. With pytest version previous to the 8.0 release, using the --import-mode=importlib option solved the issue. However, this is not true for pytest 8.0 and later.
The only solution I've found is to install the tests alongside the package. Then pytest package/ works as expected.
If a project does not want to have the tests as part of the distributed wheels, it needs either to add a meson build option that disables installing the tests and set it when building wheels for redistribution and not for development builds, or it needs to use install tags to filter the tests out and use -Cinstall-args=--tags=python-runtime,tests in development builds. I don't like the latter solution much, because it requires listing all the tags to be installed.
The pytest issue is not meson-python specific, it is more specific to packages using extension modules, but it is complex enough that it may be worth a mention somewhere in the documentation. Maybe we need a Development with meson-python section in the documentation.
- Vorherrschende Sprache
- Python
- Sterne
- 181
- Forks
- 96
- Ø Merge
- 21 Std. 24 Min.
- Gemergte PRs (30 T.)
- 8
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
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 mesonbuild/meson-python
-
documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
mesonbuild/meson-python#541 ·
Maintainer antworten meist innerhalb von 1 Tag
-
documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
mesonbuild/meson-python#473 · 6 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
documentation enhancement tests
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 45/100
mesonbuild/meson-python#903 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 52/100
mesonbuild/meson-python#871 · 7 Kommentare · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
pip install overrides existing build configurationEvtl. vergeben @Alvaro-Kothe hat das vor 134 Tagen übernommen. Offenquestion
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
mesonbuild/meson-python#851 · 6 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in mesonbuild/meson-python
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
pydot/pydot#601 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
letsencrypt/cp-cps#361 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
-
CI: startup_failure because callers grant fewer permissions than ledger-app-workflows@v1 declaresEvtl. vergeben @maykonmichel hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
LedgerHQ/app-boilerplate-rust#227 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
linuxmint/mintupdate#1107 ·