Q: Why is pytest not seeing changes when I edit a .pyx
file and build? What step am I missing?
I'm using Visuals Studio Code with remote containers as described at the end of this page.
If I add changes to pandas/_libs/tslibs/offsets.pyx, and then run
(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 ...
my unit-test fails because it does not test against my updated version of offsets.pxy
. He points to a line (see below) where the error exists only in the old version of the file.
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
Whatever change I add to cdef _determine_offset
and build, pytest does not see the edits, therefore I assume I'm missing a compilation step somewhere.
Reproducible example
- clone my pandas fork:
git clone [email protected]:markopacak/pandas.git
git checkout bug-dateoffset-milliseconds
- In your dev-environment (docker container or VS Code remote container) run:
conda activate pandas-dev
python setup.py build_ext -j 4
pytest pandas/tests/tseries/offsets/test_offsets.py::TestDateOffset
Assumes you have set-up a dev environment for pandas, ideally using remote-containers on VS Code like I did.
(pandas-dev) root@60017c489843:/workspaces/pandas# python --version
Python 3.8.15
CodePudding user response:
I'm pretty sure you need to install once the extensions are built (otherwise where are the built extension and how python/pytest should know where to look?). This is how my workflow looked some time ago (not sure it still applies but should be close enough):
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
Installing in development mode (-e
) is the most convenient option in my opinion for development.