# Developing WFDB-Python ## Guidelines We welcome community contributions in the form of pull requests. When contributing code, please ensure: - Documentation is provided. New functions and classes should have numpy/scipy style [docstrings](https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt). - Unit tests are written for new features that are not covered by [existing tests](https://github.com/MIT-LCP/wfdb-python/tree/main/tests). - The code style is consistent with the project's formating standards. Run the formatter with: ```sh black . ``` ## Package and Dependency Management This project uses [poetry](https://python-poetry.org/docs/) for package management and distribution. Development dependencies are specified as optional dependencies, and then added to the "dev" extra group in the [pyproject.toml](./pyproject.toml) file. ```sh # Do NOT use: poetry add --dev poetry add --optional ``` The `[tool.poetry.dev-dependencies]` attribute is NOT used because of a [limitation](https://github.com/python-poetry/poetry/issues/3514) that prevents these dependencies from being pip installable. Therefore, dev dependencies are not installed when purely running `poetry install`, and the `--no-dev` flag has no meaning in this project. ## Creating Distributions Make sure the versions in [version.py](./wfdb/version.py) and [pyproject.toml](./pyproject.toml) are updated and kept in sync. It may be useful to publish to testpypi and preview the changes before publishing to PyPi. However, the project dependencies likely will not be available when trying to install from there. Setup: configure access to repositories: ```sh # Create an API token, then add it poetry config pypi-token.pypi # For testpypi poetry config repositories.test-pypi https://test.pypi.org/legacy/ poetry config pypi-token.test-pypi ``` To build and upload a new distribution: ```sh poetry build poetry publish -r test-pypi poetry publish ``` ## Creating Documentation The project's documentation is generated by [Sphinx](https://docs.readthedocs.io/en/stable/intro/getting-started-with-sphinx.html) using the content in the [docs](./docs) directory. The generated content is then hosted on readthedocs (RTD) at: To manage the content on RTD, request yourself to be added to the [wfdb](https://readthedocs.org/projects/wfdb/) project. The project has already been configured to import content from the GitHub repository. Documentation for new releases should be automatically built and uploaded. See the [import guide](https://docs.readthedocs.io/en/stable/intro/import-guide.html) for more details. There is some redundancy in specifying the Sphinx requirements between pyproject.toml and [docs/requirements.txt](./docs/requirements.txt), the latter of which is used by RTD. Make sure that the content is consistent across the two files. To generate the HTML content locally, install the required dependencies and run from the `docs` directory: ```sh make html ``` ## Tests Run tests using pytest: ```sh pytest # Distribute tests across multiple cores. # https://github.com/pytest-dev/pytest-xdist pytest -n auto ```