-
Notifications
You must be signed in to change notification settings - Fork 0
Home
It is not necessary to run setup.py build_ext --inplace or py -m build then install from dist, because the package has long been configured for self-assembly. More clear way to build and install exts (cython extensions) from repo root:
cd ./py_ballisticcalc.exts
pip install -e .
To remove just pip uninstall py_ballisticcalc.exts
This is because when installing through pip it tries to build wheel using setup.py or pyproject.toml, which creates an isolated environment, downloads build dependencies (like setuptools and cython) and then builds wheel, then installs package using this wheel. So if using -e flag it installs it locally in editable mode (not to the site packages). Then if you change the code in pyx/pxd you can re-run pip install -e . to recompile binaries. With pure python modules you should not rerun pip install after changes, except in cases when you added entries to pyproject.toml, setup.py, etc.
Or to ensure all dependencies, from repo-root:
pip install -e .[dev,charts]
pip install -e ./py_ballisticcalc.exts[dev]
Alternative:
cd ./py_ballisticcalc.exts
pip install cython
python setup.py build_ext --inplace
Now with uv:
uv pip install -e py_ballisticcalc_exts --no-cache-
uv sync --devalone will removes exts -
python .\py_ballisticcalc.exts\scripts\cleanup.pyshould removes old build artifacts -
uv sync --dev --extra exts --no-cacheshould force rebuild
uv sync --python="3.12" --dev --extra exts
(Without the --python argument it will default to the earliest supported version of Python.)
Then to get into the virtual environment that creates run: .venv\Scripts\activate
-
pytest tests... add-o log_cli=true -o log_cli_level=WARNINGto display logger statements even on success. pytest tests --engine="scipy_engine"pytest tests/zero_finding.py --engine="cythonized_euler_engine"
There are also Cython-specific tests in the Cython project subfolder:
pytest .\py_ballisticcalc.exts\tests-
pytest .\py_ballisticcalc.exts\tests -m stressto run stress tests
This Powershell script tests all engines and produces a summary.
-
pytest --cov=py_ballisticcalc --cov-report=term-missinglists coverage% and lines missing coverage by module. -
pytest --cov=py_ballisticcalc --cov-report=htmlgenerates HTML report inhtmlcovsubfolders
We can also include cython coverage.
python scripts\sync_cython_sources.py
pytest --engine="cythonized_rk4_engine" --cov=py_ballisticcalc --cov=py_ballisticcalc_exts --cov-report=htmlmypyuv run ruff check-
Docstrings:
pydocstyle .\py_ballisticcalc\ -
Doctests:
.\scripts\run_doctest.py -
uv run ruff format --diffto check Black-style formatting.
Code should use Google style DocStrings.
Good example of documentation style we want for this project.
Use pure package installed only, because mkdocs can't read docstrings from .pyx and .pyd. To prepare venv for mkdocs use pip install -e .[docs].
Then start server by running mkdocs serve. Modify mkdocs.yml and docs/**/*.md on the fly to see changes.
Helpful references: