diff --git a/Makefile b/Makefile index 7bc465a..c2bdade 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,6 @@ .PHONY: clean cleanall develop list-sessions tests doc develop: sync - pdm run python -c "from fluidfft_builder import create_fake_modules as c; c()" - pdm run pip install -e . --no-deps --no-build-isolation -v pdm run pip install -e plugins/fluidfft-fftw --no-build-isolation -v develop_mpi_with_fftw: @@ -18,7 +16,7 @@ develop_p3dfft: pdm run pip install -e plugins/fluidfft-p3dfft --no-build-isolation -v sync: - pdm sync --clean --no-self + pdm sync --clean lock: pdm lock diff --git a/noxfile.py b/noxfile.py index 3beaa28..1efac0c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -32,6 +32,7 @@ @nox.session(reuse_venv=True) def validate_code(session): + """Validate the code with black and pylint""" session.run_always( "pdm", "sync", "--clean", "-G", "lint", "--no-self", external=True ) @@ -119,13 +120,18 @@ def test_plugin(package_name): @nox.session(reuse_venv=True) def doc(session): + """Build the documentation""" session.run_always( "pdm", "sync", "--clean", "-G", "doc", "--no-self", external=True ) session.run_always( - "python", "-c", "from fluidfft_builder import create_fake_modules as c; c()" + "python", + "-c", + "from fluidfft_builder import create_fake_modules as c; c()", + ) + session.install( + ".", "--no-deps", "-C", "setup-args=-Dtransonic-backend=python" ) - session.install(".", "--no-deps", "-C", "setup-args=-Dtransonic-backend=python") session.chdir("doc") session.run("make", "cleanall", external=True) session.run("make", external=True) @@ -158,9 +164,12 @@ def _get_version_from_pyproject(path=Path.cwd()): @nox.session(name="add-tag-for-release", venv_backend="none") def add_tag_for_release(session): + """Add a version tag in the repo""" session.run("hg", "pull", external=True) - result = session.run(*"hg log -r default -G".split(), external=True, silent=True) + result = session.run( + *"hg log -r default -G".split(), external=True, silent=True + ) if result[0] != "@": session.run("hg", "update", "default", external=True) @@ -189,7 +198,7 @@ def add_tag_for_release(session): @nox.session(name="release-plugin", reuse_venv=True) def release_plugin(session): - """Release a plugin on PyPI.""" + """Release a plugin on PyPI""" for project in ("build", "twine", "lastversion"): session.install(project) @@ -197,7 +206,9 @@ def release_plugin(session): try: short_name = session.posargs[0] except IndexError: - session.error("No short name given. Use as `nox -R -s release-plugin -- fftw`") + session.error( + "No short name given. Use as `nox -R -s release-plugin -- fftw`" + ) print(short_name) path = Path.cwd() / f"plugins/fluidfft-{short_name}" @@ -244,3 +255,17 @@ def release_plugin(session): return session.run("twine", "upload", "dist/*") + + +@nox.session(name="create-fake-modules", reuse_venv=True) +def create_fake_modules(session): + """Create fake modules for doc""" + + session.install("-e", "./plugins/fluidfft-builder") + session.install("black") + session.run( + "python", + "-c", + "from fluidfft_builder import create_fake_modules as c; c()", + ) + session.run("black", "src/fluidfft") diff --git a/pyproject.toml b/pyproject.toml index 0ec1ab2..a9fc8b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,6 +93,7 @@ doc = [ lint = ["black", "pylint"] [tool.pdm.scripts] +pre_install = "nox -s create-fake-modules" black = 'black -l 82 src doc plugins tests --exclude "/(__pythran__|__python__|__numba__|build|doc/_build|\.ipynb_checkpoints/*)/"' black_check = 'black --check -l 82 src doc plugins tests --exclude "/(__pythran__|__python__|__numba__|build|doc/_build|\.ipynb_checkpoints/*)/"' lint = {shell="pylint -rn --rcfile=pylintrc --jobs=$(nproc) src doc tests plugins --exit-zero"} @@ -103,6 +104,8 @@ excludes = ["fluidfft-fftw", "fluidfft-mpi_with_fftw", "fluidfft-fftwmpi", "flui [tool.pdm.options] lock = ["-G", "pyfftw", "-G", "dask", "-G", "mpi"] +sync = ["--no-isolation"] +install = ["--no-isolation"] [tool.coverage.run] source = [ @@ -142,3 +145,6 @@ directory = ".coverage" [tool.coverage.xml] output = ".coverage/coverage.xml" + +[tool.black] +line-length = 82