Document how to use pytest in packages using meson-python
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Documentazione
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- build-system, documentation
Direzione di ricerca
Inizia individuando la documentazione del progetto e rivedendo la sezione proposta Development with meson-python. Riproduci il workflow descritto con meson.build, pyproject.toml, la struttura di package/ e pytest package/ dopo l’installazione con pip. Documenta come l’installazione dei test e le opzioni di build o i tag di installazione influenzano lo sviluppo e le build delle wheel, spiegando anche il comportamento di pytest 8.0.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 180
- Fork
- 93
- Merge medio
- 20h 58m
- PR unite (30g)
- 22
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di mesonbuild/meson-python
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
mesonbuild/meson-python#541 ·
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
mesonbuild/meson-python#473 · 6 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
documentation enhancement tests
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
mesonbuild/meson-python#903 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
mesonbuild/meson-python#871 · 7 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
pip install overrides existing build configurationForse già presa @Alvaro-Kothe l’ha presa 113 giorni fa. Apertaquestion
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
mesonbuild/meson-python#851 · 6 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di mesonbuild/meson-python
Issue simili
-
defect from-review v0.9.2
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
khuisman/mcp-gee-sweet#926 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 84/100
EtanHey/brainlayer#1164 ·
I maintainer di solito rispondono entro 1 giorno
-
bug security
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
yunaremaia/vibeguard#141 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
PrismorSec/prismor#599 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
iii-hq/iii#2278 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno