Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch from makefile to poethepoet for Python commands #91

Merged
merged 5 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
python -m pip install -e ".[docs]"
- name: Build documentation
run: |
make docs
poe docs
- name: Upload Pages
uses: actions/upload-pages-artifact@v3
with:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ jobs:
run: |
sudo apt-get install -y cloc
echo "# Lines of Code Report" >> $GITHUB_STEP_SUMMARY
make loc >> $GITHUB_STEP_SUMMARY
poe loc >> $GITHUB_STEP_SUMMARY
- name: Check linting
run: |
make lint
poe lint
- name: Test with pytest
run: |
coverage run -m pytest
Expand All @@ -63,9 +63,9 @@ jobs:
coverage html -d coverage -i
- name: Build documentation
run: |
make docs
poe docs
if [ "$generateDocx" = "true" ]; then
make docs-docx
poe docs-docx
rm -rf docs/build/singlehtml
fi
- name: Upload Documentation
Expand All @@ -90,9 +90,9 @@ jobs:
source ./tools/linux_ci_setup.sh
- name: Run clang-format
run: |
pip install clang-format==19.1.3
make format-cpp
git diff --exit-code --compact-summary || { echo "Code formatting failed; run 'make format-cpp'"; exit 1; }
pip install poethepoet clang-format==19.1.3
poe format-cpp
git diff --exit-code --compact-summary || { echo "Code formatting failed; run 'poe format-cpp'"; exit 1; }
- name: Build bmdscore
run: |
source ./tools/linux_ci_env.sh
Expand Down
69 changes: 0 additions & 69 deletions Makefile

This file was deleted.

16 changes: 7 additions & 9 deletions docs/source/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ py.test
py.test -k test_my_special_test_name
```

There is a built-in Makefile, ``make``, that runs many common utility methods for developing the application. You can run tests by running `make test`, run code formatting using `make format`, or build documentation using `make docs`. For more details on other built-in actions, view the `Makefile` (or the `make.bat` file for Windows).
You can run tests by running `poe test`, run code formatting using `poe format`, or build documentation using `poe docs`. For more details on other built-in actions, view the `poe` commands by simply typing `poe`.

Github Actions are in place to execute whenever a pull-request is submitted to check code formatting and successful tests. When code is merged into the `main` branch, a wheel artifact is created and stored on github. We use [cibuildwheel](https://cibuildwheel.pypa.io/en/stable/) to build wheel packages in Windows, macOS, and Linux using Github Actions.

Expand All @@ -65,8 +65,7 @@ make run_tests_with_coverage
Code formatting is also enforced in the C++ codebase. To run the formatter, use the following command:

```bash
pip install clang-format==19.1.3
make format-cpp
poe format-cpp
```

A specific version of clang-format is pinned for reproducibility on all platforms.
Expand All @@ -79,16 +78,15 @@ See [documentation](https://github.com/USEPA/BMDS-UI/blob/main/docs/development.

Documentation is generated using [Sphinx](https://www.sphinx-doc.org/). Narrative text is written in Markdown; any examples of using `pybmds` are written in jupyter notebooks and are executing when building documentation; the returned notebook with any output (such as figures or output tables) are rendered directly in the documentation.

To build documentation, there are a few different commands available in the `make` file:
To build documentation, there are a few different commands available:

```bash
make docs # Build documentation {html}
make docs-docx # Build documentation {docx}
make docs-serve # Realtime documentation preview
make docs-clean # Clean documentation
poe docs # Build documentation {html}
poe docs-docx # Build documentation {docx}
poe docs-serve # Realtime documentation preview
```

Using the `make serve` command is recommended for editing documentation; it updates the preview in realtime files are saved.
Using the `poe docs-serve` command is recommended for editing documentation; it updates the preview in realtime files are saved.

## Versioning

Expand Down
65 changes: 0 additions & 65 deletions make.bat

This file was deleted.

79 changes: 79 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ dependencies = [

[project.optional-dependencies]
dev = [
"poethepoet~=0.32.2",
"coverage~=7.6.4",
"mypy~=1.13.0",
"pybind11==2.13.6",
Expand All @@ -46,6 +47,7 @@ dev = [
"ruff~=0.7.1",
"setuptools~=75.3.0",
"wheel~=0.44.0",
"clang-format==19.1.3",
]
docs = [
"Sphinx~=8.1.3",
Expand Down Expand Up @@ -142,3 +144,80 @@ version = {attr = "pybmds.__version__"}
[tool.setuptools.packages.find]
where = ["src"]
include = ["pybmds*"]

[tool.poe.tasks.sync-dev]
help = "Sync dev environment after code checkout"
sequence = [
{cmd = 'uv pip install -e ".[dev,docs]"'},
]

[tool.poe.tasks.test]
help = "Run Python tests"
cmd = "py.test"

[tool.poe.tasks.format]
help = "Format Python code"
sequence = [
{cmd = "ruff format ."},
{cmd = "ruff check . --fix --show-fixes"},
]

[tool.poe.tasks.format-cpp]
help = "Format C++ code"
sequence = [
{shell = 'find src -name "*.cpp" -o -name "*.h" | xargs clang-format -i'},
]

[tool.poe.tasks.lint]
help = "Check Python formatting issues"
sequence = [
{cmd = "ruff format . --check"},
{cmd = "ruff check ."},
]

[tool.poe.tasks.build]
help = "Build Python package"
sequence = [
{cmd ="python setup.py develop"},
{cmd ="stubgen -p pybmds.bmdscore -o src/"},
{cmd ="ruff format src/pybmds/bmdscore.pyi"},
]

[tool.poe.tasks.dist]
help = "Build wheel package for distribution"
sequence = [
{cmd ="python setup.py bdist_wheel"},
]

[tool.poe.tasks.coverage]
help = "Run Python coverage and create HTML report"
sequence = [
{cmd = "coverage run -m pytest"},
{cmd = "coverage html -d coverage_html -i"},
]

[tool.poe.tasks.loc]
help = "Generate lines of code report"
cmd = """cloc \
--exclude-dir=build,dist,venv \
--exclude-ext=json,yaml,svg,toml,ini \
--vcs=git \
--counted loc-files.txt \
--md \
.
"""

[tool.poe.tasks.docs]
help = "Build html documentation"
cmd = "sphinx-build -W -b html docs/source docs/build/html"

[tool.poe.tasks.docs-docx]
help = "Build docx documentation"
sequence = [
{cmd = "sphinx-build -W -b singlehtml docs/source docs/build/singlehtml"},
{shell = "cd docs/build/singlehtml && pandoc -s index.html -o ../pybmds.docx"},
]

[tool.poe.tasks.docs-serve]
help = "Preview html documentation"
cmd = "sphinx-autobuild -b html docs/source docs/build/html --port 5800"