Document how to use pytest in packages using meson-python
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Documentación
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- build-system, documentation
Línea de trabajo
Comienza localizando la documentación del proyecto y revisando la sección propuesta Development with meson-python. Reproduce el flujo de trabajo descrito con meson.build, pyproject.toml, el diseño de package/ y pytest package/ después de instalar con pip. Documenta cómo la instalación de pruebas y las opciones de compilación o las etiquetas de instalación afectan al desarrollo y a las compilaciones de wheels, explicando también el comportamiento de pytest 8.0.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 180
- Forks
- 93
- Merge medio
- 20 h 58 min
- PR fusionados (30 d)
- 22
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de mesonbuild/meson-python
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
mesonbuild/meson-python#541 ·
Los mantenedores suelen responder en 1 día
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
mesonbuild/meson-python#473 · 6 comentarios ·
Los mantenedores suelen responder en 1 día
-
documentation enhancement tests
Dificultad 5/5 Más de una semana Aptitud para principiantes 45/100
mesonbuild/meson-python#903 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
mesonbuild/meson-python#871 · 7 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
pip install overrides existing build configurationPosiblemente ocupada @Alvaro-Kothe la tomó hace 111 días. Abiertoquestion
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
mesonbuild/meson-python#851 · 6 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de mesonbuild/meson-python
Issues similares
-
feature:LinkChecker
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
digitalfabrik/integreat-cms#4594 ·
Los mantenedores suelen responder en 5 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
EleutherAI/lm-evaluation-harness#4319 ·
Los mantenedores suelen responder en 1 día
-
needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
json_params_matcher fails on falsy top-level JSON primitives (0, False, "")Posiblemente ocupada @mayureshsonawane17 la tomó hoy. AbiertoWaiting for: Product Owner
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 5 días