[英]Pandas development environment: pytest does not see changes after building edited .pyx file
問:當我編輯.pyx
文件並構建時,為什么 pytest 看不到變化? 我錯過了什么步驟?
如本頁末尾所述,我將 Visuals Studio Code 與遠程容器一起使用。
如果我將更改添加到pandas/_libs/tslibs/offsets.pyx ,然后運行
(pandas-dev) root@60017c489843:/workspaces/pandas# python setup.py build_ext -j 4
Compiling pandas/_libs/tslibs/offsets.pyx because it changed.
[1/1] Cythonizing pandas/_libs/tslibs/offsets.pyx
/opt/conda/envs/pandas-dev/lib/python3.8/site-packages/setuptools/config/pyprojecttoml.py:108: _BetaConfiguration: Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*. warnings.warn(msg, _BetaConfiguration)
# ... more output here without errors ...
我的單元測試失敗了,因為它沒有針對我更新的offsets.pxy
版本進行測試。 他指向一行(見下文),其中錯誤僅存在於文件的舊版本中。
pandas/tests/tseries/offsets/test_offsets.py ........x......................................................F
.... more output here ...
E TypeError: __init__() got an unexpected keyword argument 'milliseconds'
pandas/_libs/tslibs/offsets.pyx:325: TypeError
無論我向cdef _determine_offset
添加什么更改並構建,pytest 都看不到編輯,因此我假設我在某處缺少編譯步驟。
git clone git@github.com:markopacak/pandas.git
git checkout bug-dateoffset-milliseconds
conda activate pandas-dev
python setup.py build_ext -j 4
pytest pandas/tests/tseries/offsets/test_offsets.py::TestDateOffset
假設你已經為 pandas 設置了一個開發環境,最好像我一樣在 VS Code 上使用遠程容器。
(pandas-dev) root@60017c489843:/workspaces/pandas# python --version
Python 3.8.15
我很確定你需要在構建擴展后安裝(否則構建的擴展在哪里以及 python/pytest 應該如何知道在哪里看?)。 這是我的工作流程前一段時間的樣子(不確定它是否仍然適用但應該足夠接近):
python setup.py build_ext --inplace -j 4
python -m pip install -e . --no-build-isolation --no-use-pep517
...
pytest pandas/tests/xxxx/yyyy.py
在我看來,以開發模式 ( -e
) 安裝是最方便的開發選項。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.