-
Notifications
You must be signed in to change notification settings - Fork 16
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
PDM, Nox and Meson #51
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b2dc796
Use PDM
paugier 0f6d5bc
Simple Nox file
paugier 6a41807
No Python 3.8
paugier dbbdd05
Tiny Makefile for dev + pdm lock
paugier 48e09be
Meson!
paugier d2414ed
Make Ruff happier
paugier 9696408
docs/dev-install.md
paugier c51cb7f
style: double quotes in pyproject.toml
martibosch 68702b0
build: use nox in github actions
martibosch d2b99a6
nox --force-python for micromamba
paugier db49da2
CI build doc
paugier f51e100
CI: install gdal with mamba-org/setup-micromamba
paugier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,3 +113,7 @@ output/ | |
# Transonic | ||
__pythran__ | ||
__numba__ | ||
__python__ | ||
|
||
# PDM | ||
.pdm-python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
install: | ||
pdm sync | ||
|
||
lock: | ||
pdm lock | ||
|
||
test: | ||
pdm test | ||
|
||
build_doc: | ||
nox -s doc -R | ||
|
||
test_in_nox_env: | ||
nox -s test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../CHANGELOG.md |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../CONTRIBUTING.md |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Setup a development environment | ||
|
||
Once [PDM] and [Nox] are installed, it is very easy to setup a development environment for | ||
PyLandStats. On most systems, one can install PDM and Nox with [Pipx], with something like: | ||
|
||
```sh | ||
python3 -m pip install pipx | ||
python3 -m pipx ensurepath | ||
``` | ||
|
||
and then in a new terminal: | ||
|
||
```sh | ||
pipx install pdm | ||
pipx install nox | ||
``` | ||
|
||
Once PDM is installed, clone the PyLandStats repo and run `make` from the root | ||
directory. This should install a dedicated local virtual environment `.venv`. | ||
You can then activate it and run the tests. | ||
|
||
Note that there are few other targets in the `Makefile` useful for developers. In | ||
particular, it is good to periodically recompute the dependencies written in | ||
the `pdm.lock` file (with `make lock`) to check if new packages uploaded on PyPI | ||
do not break PyLandStats. It is reasonable to do this in a dedicated PR. | ||
|
||
[nox]: https://nox.thea.codes | ||
[pdm]: https://pdm-project.org | ||
[pipx]: https://github.com/pypa/pipx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
project( | ||
'pylandstats', | ||
'cpp', | ||
license: 'GPL-3.0-or-later', | ||
meson_version: '>= 1.1.0', | ||
default_options: [ | ||
'buildtype=release', | ||
'cpp_std=c++11', | ||
], | ||
) | ||
|
||
# https://mesonbuild.com/Python-module.html | ||
py_mod = import('python') | ||
py = py_mod.find_installation('python3', pure: false) | ||
py_dep = py.dependency() | ||
|
||
backend = get_option('transonic-backend') | ||
|
||
if backend.contains(',') | ||
backends = backend.split(',') | ||
else | ||
backends = [backend] | ||
endif | ||
|
||
use_pythran = backend.contains('pythran') | ||
if use_pythran | ||
incdir_numpy = run_command('transonic-get-include', 'numpy', check: true).stdout().strip() | ||
inc_np = include_directories(incdir_numpy) | ||
np_dep = declare_dependency(include_directories: inc_np) | ||
|
||
incdir_pythran = run_command('transonic-get-include', 'pythran', check: true).stdout().strip() | ||
pythran = find_program('pythran', native: true) | ||
|
||
cpp_args_pythran = [ | ||
'-DENABLE_PYTHON_MODULE', | ||
'-D__PYTHRAN__=3', | ||
'-DPYTHRAN_BLAS_NONE' | ||
] | ||
|
||
if get_option('use-xsimd') == true | ||
# xsimd is unvendored from pythran by conda-forge, and due to a compiler | ||
# activation bug the default <prefix>/include/ may not be visible (see | ||
# gh-15698). Hence look for xsimd explicitly. | ||
xsimd_dep = dependency('xsimd', required: false) | ||
pythran_dep = declare_dependency( | ||
include_directories: incdir_pythran, | ||
dependencies: xsimd_dep, | ||
) | ||
cpp_args_pythran += ['-DUSE_XSIMD'] | ||
else | ||
pythran_dep = declare_dependency( | ||
include_directories: incdir_pythran, | ||
) | ||
endif | ||
|
||
pythran_complex_hook = get_option('pythran-complex-hook') | ||
if pythran_complex_hook == 'os-dependent' | ||
pythran_complex_hook = host_machine.system() == 'linux' | ||
endif | ||
|
||
if get_option('native') | ||
cpp_args_pythran += ['-march=native', '-Ofast'] | ||
endif | ||
|
||
endif | ||
|
||
subdir('pylandstats') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
option( | ||
'transonic-backend', | ||
type: 'string', | ||
value: 'pythran,python,numba', | ||
description: | ||
'pythran,python,numba (default), cython, numpy, numba; ' + | ||
'or comma separated value representing multi-backends', | ||
) | ||
option( | ||
'native', | ||
type: 'boolean', | ||
value: false, | ||
description: 'Performance oriented and not portable build', | ||
) | ||
option( | ||
'use-xsimd', | ||
type: 'boolean', | ||
value: true, | ||
description: 'Turns on xsimd vectorization', | ||
) | ||
option( | ||
'pythran-complex-hook', | ||
type: 'combo', | ||
choices: ['os-dependent', 'true', 'false'], | ||
value: 'os-dependent', | ||
description: 'Pythran complex_hook option', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
"""Task runner for the developer. | ||
|
||
# Usage | ||
|
||
``` | ||
nox -l # list of sessions. | ||
nox -s <session> # execute a session | ||
nox -k <keyword> # execute some session | ||
``` | ||
|
||
""" | ||
|
||
import os | ||
|
||
import nox | ||
|
||
os.environ.update({"PDM_IGNORE_SAVED_PYTHON": "1"}) | ||
nox.options.reuse_existing_virtualenvs = 1 | ||
|
||
|
||
@nox.session | ||
def doc(session): | ||
"""Build the documentation in a Nox environment.""" | ||
command = "pdm sync --clean -G doc --no-self" | ||
session.run_install(*command.split(), external=True) | ||
|
||
# for documentation, we don't need the other backends | ||
command = "pip install . -C setup-args=-Dtransonic-backend=python" | ||
session.run_install(*command.split(), external=True) | ||
|
||
session.run("sphinx-build", "docs", "docs/_build") | ||
print(f"file://{os.getcwd()}/docs/_build/index.html") | ||
|
||
|
||
@nox.session | ||
def wheel(session): | ||
"""Build the wheel.""" | ||
session.install("build", "twine") | ||
session.run("python", "-m", "build") | ||
session.run("twine", "check", "dist/*") | ||
|
||
|
||
@nox.session(venv_backend="mamba|micromamba|conda") | ||
def test(session): | ||
"""Run the test in a Nox environment.""" | ||
command = "pdm sync --clean --prod -G test --no-self" | ||
session.run_install(*command.split(), external=True) | ||
|
||
session.conda_install("gdal>=3.3", channel=["conda-forge"]) | ||
session.install(".", "--no-deps", external=True) | ||
|
||
session.run( | ||
"pytest", | ||
"-v", | ||
"-s", | ||
"--cov=pylandstats", | ||
"--cov-append", | ||
"--cov-report=xml", | ||
"--cov-report", | ||
"term-missing", | ||
"tests", | ||
) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it looks reasonable. It looks a bit like a Nox bug. I'm going to have a look at that.