Skip to content

Commit

Permalink
Merge branch 'topic/default/pdm-install-hook' into 'branch/default'
Browse files Browse the repository at this point in the history
pre_install hook using nox to create the fake modules

See merge request fluiddyn/fluidfft!55
  • Loading branch information
paugier committed Feb 9, 2024
2 parents 9d6a5b1 + 69aa625 commit 78ebec7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand Down
35 changes: 30 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -189,15 +198,17 @@ 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)

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}"
Expand Down Expand Up @@ -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")
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand All @@ -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 = [
Expand Down Expand Up @@ -142,3 +145,6 @@ directory = ".coverage"

[tool.coverage.xml]
output = ".coverage/coverage.xml"

[tool.black]
line-length = 82

0 comments on commit 78ebec7

Please sign in to comment.