Skip to content

Commit

Permalink
dev: Migrate from Makefile to justfile
Browse files Browse the repository at this point in the history
The [just](https://github.com/casey/just) build command runner is "just"
a better `make`, for our purposes. In particular, it properly terminates
the documentation build if `setuptools-scm` is not installed. I'm sure
there is a way to cast spells at `make` to make it do that, but why?
Whenever there's a big .PHONY line in a Makefile, it means that `make`
is probably the wrong tool. Also, the old Makefile I provided was only
valid for GNU make (make portability is a bit gross).

Also, `just` has binaries built for every major platform so installing
is not a hassle.
  • Loading branch information
adigitoleo committed Aug 23, 2024
1 parent c68a97d commit f17c6c2
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 42 deletions.
39 changes: 0 additions & 39 deletions Makefile

This file was deleted.

6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ They have their own README file as well.

The documentation can be built offline from a git clone or unpacked source distribution.
Install documentation builder dependencies with `pip install '.[doc]'`.
Developers are also recommended to download the [just](https://github.com/casey/just) command runner.
Otherwise, build commands can be found in the provided `justfile`.

Run `make html` from the terminal to generate PyDRex's documentation
Run `just html` from the terminal to generate PyDRex's documentation
(available in the `html` directory), including the API reference.
The homepage will be `html/index.html`.
Alternatively, run `make live_docs` to build and serve the documentation on a `localhost` port.
Alternatively, run `just live_docs` to build and serve the documentation on a `localhost` port.
Follow the displayed prompts to open the live documentation in a browser.
It should automatically reload after changes to the source code.

Expand Down
33 changes: 33 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
VERSION := `python -m setuptools_scm -f plain`

build:
python -m build

release: build
python -m twine upload dist/*

test:
mkdir out
pytest -v --outdir=out

html:
# WARNING: --math fetches .js code from a CDN, be careful where it comes from:
# https://github.com/mitmproxy/pdoc/security/advisories/GHSA-5vgj-ggm4-fg62
2>pdoc.log pdoc -t docs/template -o html pydrex !pydrex.mesh !pydrex.distributed tests \
--favicon "https://raw.githubusercontent.com/seismic-anisotropy/PyDRex/main/docs/assets/favicon32.png" \
--footer-text "PyDRex {{VERSION}}" \
--math

live_docs:
# WARNING: --math fetches .js code from a CDN, be careful where it comes from:
# https://github.com/mitmproxy/pdoc/security/advisories/GHSA-5vgj-ggm4-fg62
pdoc -t docs/template pydrex !pydrex.mesh !pydrex.distributed tests \
--favicon "https://raw.githubusercontent.com/seismic-anisotropy/PyDRex/main/docs/assets/favicon32.png" \
--footer-text "PyDRex {{VERSION}}" \
--math

clean:
rm -rf dist
rm -rf out
rm -rf html
rm -rf pdoc.log
3 changes: 2 additions & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# PyDRex tests

Running the base test suite requires [pytest](https://docs.pytest.org) and up to ~16GB RAM.
By default, `make test` will attempt to write persistent logs and output to `./out/`.
If the [just](https://github.com/casey/just) command runner is installed,
`just test` will run the test suite and attempt to write persistent logs and output to `./out/`.

Alternatively, run `pytest` from the root of the source tree.
To print more verbose test progress and information, use the flag `pytest -v`.
Expand Down

0 comments on commit f17c6c2

Please sign in to comment.