繁体   English   中英

Pandas 开发环境:pytest buildeded.pyx文件后看不到变化

[英]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 都看不到编辑,因此我假设我在某处缺少编译步骤。

可重现的例子

  1. 克隆我的 pandas 叉子: git clone git@github.com:markopacak/pandas.git
  2. git checkout bug-dateoffset-milliseconds
  3. 在您的开发环境(docker 容器或 VS Code 远程容器)中运行:
    • 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM