This guide covers the development workflow for BEAMZ using modern Python tooling with uv.
BEAMZ is very young and in a very crowded space - but it is quickly growing.
Install uv:
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# macOS with Homebrew
brew install uvgit clone https://github.com/QuentinWach/beamz.git
cd beamz
uv sync # Installs all dependencies# Install package in dev mode
uv sync
# Install with all extras (dev, test, gpu)
uv sync --all-extras
# Install specific extra
uv sync --extra gpu
# Update dependencies
uv sync --upgradeAll development commands use the Makefile:
make help # Show all available commands
make test # Run tests with coverage
make test-fast # Run quick tests
make format # Format code (black + isort)
make lint # Check code quality
make build # Build distributionOr use uv directly:
uv run pytest tests/
uv run black beamz/# Add runtime dependency
uv add <package-name>
# Add dev dependency
uv add --dev <package-name>
# Add with version constraint
uv add "numpy>=1.24,<2.0"
# Remove dependency
uv remove <package-name># All tests with coverage
make test
# Fast tests (skip @pytest.mark.slow)
make test-fast
# Single test file
make test-single FILE=test_physics_energy.py
# Specific test function
uv run pytest tests/test_physics_energy.py::test_energy_conservation -v
# Tests by marker
uv run pytest -m design
uv run pytest -m simulation- Place tests in
tests/directory - Use
test_*.pynaming convention - Use pytest fixtures from
tests/conftest.py - Add markers for categorization:
@pytest.mark.slow @pytest.mark.design @pytest.mark.simulation
# Auto-format code
make format
# Check formatting (CI)
make format-checkmake lintAll tool configurations are in pyproject.toml:
- pytest
- black (line-length: 88, target: py310+)
- isort (black-compatible)
# Update version and create git tag
make version VERSION=0.1.X
# Or manually:
python release_version.py 0.1.XThis will:
- Update version in
pyproject.tomlandbeamz/__init__.py - Create git tag
v0.1.X - Push tag to remote repository
export GITHUB_TOKEN=your_token_here
python release_version.py 0.1.X --message "Release notes"Options:
--no-push: Don't push tag to remote--force: Force overwrite existing tag--skip-version-update: Skip updating version files
# Build distribution
make build
# or: uv build
# Publish to PyPI
make publish
# or: uv run twine upload dist/*Note: The old patch_wheel.py step is no longer needed with uv/hatchling.
- Update version:
make version VERSION=0.1.X - Build:
make build - Test in test environment
- Publish:
make publish
beamz/
├── beamz/ # Main package
│ ├── design/ # Geometry and meshing
│ ├── simulation/ # FDTD engine
│ ├── optimization/ # Topology optimization
│ ├── devices/ # Sources and monitors
│ └── visual/ # Visualization
├── tests/ # Test suite
├── examples/ # Example scripts
├── pyproject.toml # Project config (source of truth)
├── uv.lock # Dependency lockfile
├── Makefile # Development shortcuts
└── release_version.py # Version bump + tag helper
- Single source of truth for project metadata
- Uses
hatchlingbuild backend - Contains all tool configurations
- Minimum Python: 3.10
- Reproducible dependency lockfile
- Committed to version control
- Auto-updated by
uv add/remove
- Specifies Python 3.11 for development
- Auto-detected by uv
# Clear cache and reinstall
uv cache clean
uv sync
# Regenerate lockfile
uv lock --upgrade# List available Python versions
uv python list
# Install specific version
uv python install 3.11
# Use specific version
uv sync --python 3.11Ensure package is installed in editable mode:
uv syncGitHub Actions workflows use uv:
.github/workflows/tests.yml- Run tests on push/PR- Configured for Python 3.10 and 3.11
- Uses
astral-sh/setup-uv@v5action
- Always use
uv add/removefor dependencies (keeps lockfile in sync) - Run
make formatbefore committing - Run
make test-fastduring development - Run
make testbefore pushing - Keep lockfile committed (ensures reproducibility)
- Use
makecommands for consistency - Prefix one-off commands with
uv run(e.g.,uv run python script.py)