Thank you for your interest in contributing to pyOpTools! This document provides guidelines and instructions for setting up your development environment and contributing to the project.
- Python 3.8 or higher
- C++ compiler (for Cython extensions)
- Git
- Clone the repository:
git clone https://github.com/cihologramas/pyoptools.git
cd pyoptools- Install the package in editable mode with development dependencies:
pip install -e .[test]This command will automatically build the Cython extensions and install the package in development mode.
If you modify Cython source files (.pyx or .pxd), you can rebuild extensions without reinstalling:
python setup.py build_ext -iAlternatively, re-run the editable install:
pip install -e .We use pre-commit hooks to ensure code quality and consistency. These hooks automatically check your code before each commit.
- Install pre-commit hooks (one-time setup):
pre-commit installAfter installation, pre-commit hooks will run automatically on git commit. The hooks will:
- Lint all Cython files (
.pyxand.pxd) for style and potential issues - Ensure all Cython strings use double quotes for consistency
To run hooks manually without committing:
pre-commit run --all-filesTo run hooks only on staged files:
pre-commit runThe project uses the following hooks (defined in .pre-commit-config.yaml):
- cython-lint: Lints all
.pyxand.pxdfiles - double-quote-cython-strings: Enforces double quotes in Cython strings
All hooks must pass before a commit is allowed. To bypass hooks (not recommended):
git commit --no-verifyRun all tests:
pytestRun tests with coverage:
pytest --cov=pyoptoolsRun a specific test:
pytest tests/path/to/test_file.py::test_function_name- Follow PEP8 with line length preference of 88 characters
- Use 4 spaces for indentation (no tabs)
- Prefer double quotes for strings (enforced by pre-commit hooks)
- Use NumPy-style docstrings
- Import order: standard library, third-party, local imports
For more detailed code style guidelines, see AGENTS.md.
The scripts/ directory contains helpful development tools:
-
clean.py: Remove Cython-generated build artifacts
python scripts/clean.py
-
autopep8_cython.py: Auto-format Cython source files
python scripts/autopep8_cython.py
- Create a new branch for your changes:
git checkout -b feature-or-fix-name- Make your changes and ensure tests pass
- Commit your changes (pre-commit hooks will run automatically)
- Push your branch and create a pull request
- Build and test commands: See
AGENTS.mdfor comprehensive build instructions - Project structure: See
AGENTS.mdfor detailed project organization - Documentation: Available at https://pyoptools.readthedocs.io/
If you have questions or need help, please:
- Open an issue on GitHub
- Check the existing documentation
- Contact the development team
Thank you for contributing to pyOpTools!