Document how to use pytest in packages using meson-python
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- ドキュメント
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- python
調査の方向性
まずプロジェクトのドキュメントを見つけ、提案されている Development with meson-python セクションを確認します。pip でインストールした後、meson.build、pyproject.toml、package/ レイアウト、pytest package/ を使って、説明されているワークフローを再現します。テストのインストールと、ビルドオプションまたはインストールタグが開発と wheel ビルドにどのような影響を与えるかを、pytest 8.0 の動作を説明しながら文書化します。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Python
- スター
- 180
- フォーク
- 93
- 平均マージ
- 18時間 33分
- マージ済み PR(30日)
- 19
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
mesonbuild/meson-python のほかの issue
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
mesonbuild/meson-python#541 ·
メンテナーはふだん 1 日以内に返信
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
mesonbuild/meson-python#473 · コメント 6 件 ·
メンテナーはふだん 1 日以内に返信
-
documentation enhancement tests
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
mesonbuild/meson-python#903 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
mesonbuild/meson-python#871 · コメント 7 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
pip install overrides existing build configuration対応中かも @Alvaro-Kothe が 117 日前に担当しました。 オープンquestion
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
mesonbuild/meson-python#851 · コメント 6 件 ·
メンテナーはふだん 1 日以内に返信
mesonbuild/meson-python の issue をすべて見る
似ている issue
-
python-version
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
bug javascript P2-medium python release:v3.1
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
adrirubio/claude-deck#546 ·
メンテナーはふだん 1 日以内に返信
-
area: desktop area: website priority: P2 type: feature
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
appandflow/stim#3411 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1時間未満 初心者へのやさしさ 88/100
baptistehamon/lsapy#185 ·
メンテナーはふだん 1 日以内に返信