Skip to content

Commit 62c603e

Browse files
committedMar 6, 2025
Add Pixi package management configuration and documentation
This commit introduces Pixi configuration files and documentation to streamline package management and development workflows: - Added `pixi.toml` for defining project dependencies and tasks - Added `pixi.lock` with locked package dependencies - Updated `pyproject.toml` to use modern Python packaging standards - Added `pixi_notes.md` with comprehensive Pixi usage instructions - Updated conda recipe to use modern recipe format - Preserved `setup.py.bk` as a backup of the previous setup method - Added variants and recipe configuration for multi-python version support
1 parent e1335f8 commit 62c603e

10 files changed

+5078
-60
lines changed
 

‎conda.recipe/README.md

+54-21
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,60 @@
1-
# Conda packaging recipe
1+
# Conda Packaging Recipe
22

3-
- for each supported version of python, create a conda environement with the following python 3.X conda-verify conda-build boa anaconda-client
3+
This directory contains the conda packaging recipe for fstd2nc. You can build and publish the package using either the traditional conda-build approach or the modern pixi-based workflow.
44

5-
```shell
6-
mamba create -n builder38 python 3.8 conda-verify conda-build boa anaconda-client
7-
```
5+
## Using Pixi (Recommended)
86

9-
- activate the environement
10-
- from the fstd2nc directory run the following
11-
```shell
12-
. activate builderXX
13-
conda mambabuild conda.recipe [-c <your private conda channel>]
14-
```
15-
- login to anaconda if you have a private channel
16-
```shell
17-
anaconda login
18-
```
19-
- upload your package
20-
```shell
21-
anaconda upload <path to tar.bz2 file>
22-
```
7+
The modern way to build and publish conda packages using pixi:
238

9+
1. Ensure you have pixi installed (see [installation guide](https://prefix.dev/docs/pixi/installation))
2410

25-
# Notes
26-
- removed pygeode dependency
11+
2. Activate the development environment:
12+
```shell
13+
pixi shell -e dev
14+
```
2715

16+
3. Build the conda package:
17+
```shell
18+
pixi run -e dev conda-build
19+
```
20+
This will build the package using rattler-build and output to `/tmp/conda-build`
21+
22+
4. Upload to the fortiers channel:
23+
```shell
24+
pixi run -e dev conda-upload
25+
```
26+
Note: You need to be logged in to anaconda.org with appropriate permissions
27+
28+
29+
## Configuration Notes
30+
31+
- The package is currently configured for linux-64 platform
32+
- Dependencies are fetched from:
33+
- fortiers channel (for eccc_rpnpy)
34+
- conda-forge
35+
- PyPI (for pygeode>=1.2.2, as it's not available in conda)
36+
Note: To use PyPI packages in pixi.toml, you need to specify them with pip:
37+
```toml
38+
[dependencies]
39+
pip = "*" # Required for PyPI packages
40+
pygeode = {pip = ">=1.2.2"} # Specify pip source
41+
```
42+
- Build configuration is managed through:
43+
- `pixi.toml` for the pixi workflow
44+
45+
46+
## Troubleshooting
47+
48+
If you encounter issues:
49+
1. Verify channel access:
50+
```shell
51+
pixi info channels
52+
```
53+
2. Check your anaconda.org authentication:
54+
```shell
55+
anaconda whoami
56+
```
57+
3. Ensure all build dependencies are available:
58+
```shell
59+
pixi run -e dev conda-build --dry-run
60+
```

‎conda.recipe/build.sh

-5
This file was deleted.

‎conda.recipe/meta.yaml

-33
This file was deleted.

‎conda.recipe/recipe.yaml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
schema_version: 1
2+
3+
package:
4+
name: fstd2nc
5+
version: 0.20240625.8
6+
7+
source:
8+
path: ../.
9+
10+
build:
11+
number: 0
12+
script:
13+
- python -m pip install . -vv --no-deps --no-build-isolation --no-compile
14+
- find $PREFIX -name '*.pyc' -delete
15+
- find $PREFIX -name '__pycache__' -delete
16+
17+
requirements:
18+
host:
19+
- python
20+
- pip
21+
- setuptools
22+
- pip >=21.0 # Ensure modern pip for proper installation
23+
- wheel
24+
- hatchling
25+
- numpy
26+
run:
27+
- python
28+
- numpy >1.15.3
29+
- netcdf4
30+
- progress
31+
- pandas
32+
- xarray >=0.10.3
33+
- dask
34+
- toolz
35+
- iris >=2.0
36+
- certifi
37+
- cftime
38+
- eccc_rpnpy >=2.2.0
39+
40+
tests:
41+
- python:
42+
imports:
43+
- fstd2nc
44+
45+
about:
46+
homepage: https://github.com/neishm/fstd2nc
47+
license: LGPL-3.0-or-later
48+
summary: 'Converts to netCDF and provides an xarray interface to RPN standard files (from Environment Canada).'
49+
50+
extra:
51+
channels:
52+
- fortiers
53+
- conda-forge
54+
- nodefaults
55+
channel_priority: flexible
56+

‎conda.recipe/variants.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# entries per package version that users are interested in
2+
python:
3+
# Note that versions are _strings_ (not numbers)
4+
- "3.8"
5+
- "3.9"
6+
- "3.10"
7+
- "3.11"
8+
- "3.12"
9+
- "3.13"

‎pixi.lock

+4,734
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pixi.toml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
[project]
2+
name = "fstd2nc"
3+
description = "Converts to netCDF and provides an xarray interface to RPN standard files (from Environment Canada)."
4+
authors = ["Mike Neish"]
5+
channels = ["fortiers", "conda-forge", "nodefaults", "pypi"]
6+
platforms = ["linux-64"]
7+
8+
[tasks.test]
9+
description = "Run package tests"
10+
cmd = "pytest -vrf"
11+
12+
13+
[tasks.lint]
14+
description = "Run lint on package"
15+
cmd = "ruff check fstd2nc"
16+
17+
18+
[tasks.lint-fix]
19+
description = "Run lint-fix on package"
20+
cmd = "ruff check --fix fstd2nc"
21+
22+
[tasks.format]
23+
description = "Run format on package"
24+
cmd = "ruff format fstd2nc"
25+
26+
[tasks.build]
27+
description = "Build package"
28+
cmd = "python -m pip install . -vv --no-deps --no-build-isolation"
29+
30+
[tasks.doc]
31+
description = "Make docs"
32+
cmd = "sphinx-build -b html docs docs/_build/html"
33+
34+
[tasks.get-version]
35+
description = "Check version"
36+
cmd = "python -c \"import fstd2nc; print(fstd2nc.__version__)\""
37+
38+
[tasks.conda-build]
39+
cmd = "rattler-build build --recipe-dir conda.recipe --output-dir /tmp/conda-build -c conda-forge -c fortiers"
40+
41+
[tasks.render]
42+
cmd = "conda-smithy rerender"
43+
44+
[tasks.conda-upload]
45+
cmd = "anaconda upload /tmp/conda-build/linux-64/fstd2nc-*.conda -u fortiers"
46+
depends-on = ["conda-build"]
47+
48+
[dependencies]
49+
dask = ">=2023.7.1"
50+
eccc_rpnpy = ">=2.2.0"
51+
iris = ">=2.0"
52+
netcdf4 = "*"
53+
numpy = ">=1.15.3"
54+
pandas = ">=1.5.1"
55+
pip = "*"
56+
progress = "*"
57+
python = ">=3.10.12"
58+
toolz = "*"
59+
xarray = ">=0.10.3"
60+
61+
[feature.dev.dependencies]
62+
anaconda-client = "*"
63+
ipython = "==8.14.0"
64+
myst-parser = "==1.0.0"
65+
nbsphinx = "==0.9.2"
66+
pygments = "==2.12.0"
67+
pytest = "==7.4.0"
68+
ruff = ">=0.0.280"
69+
setuptools = "==58.5.3"
70+
sphinx = "==5.3.0"
71+
sphinx_rtd_theme = "==0.5.1"
72+
sphinx-autodoc-typehints = "==1.21.8"
73+
sphinx-gallery = "==0.13.0"
74+
wheel = "*"
75+
76+
77+
[environments]
78+
dev = ["dev"]
79+
80+
[target.linux-64.dependencies]

‎pixi_notes.md

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Using Pixi with fstd2nc
2+
3+
[Pixi](https://prefix.dev/docs/pixi/overview) is a modern package management tool that helps manage Python environments with conda packages. This guide explains how to use pixi with fstd2nc.
4+
5+
## Setup
6+
7+
1. First, install pixi following the [official installation guide](https://prefix.dev/docs/pixi/installation)
8+
9+
10+
## Common Tasks
11+
12+
The following tasks are available in the project:
13+
14+
1. Testing:
15+
```bash
16+
pixi run -e dev test # Run package tests with pytest (verbose mode)
17+
```
18+
19+
2. Code Quality:
20+
```bash
21+
pixi run -e dev lint # Check code with ruff
22+
pixi run -e dev lint-fix # Auto-fix linting issues
23+
pixi run -e dev format # Format code with ruff
24+
```
25+
26+
3. Building and Installation:
27+
```bash
28+
pixi run -e dev build # Install package in development mode
29+
```
30+
31+
4. Documentation:
32+
```bash
33+
pixi run -e dev doc # Build Sphinx documentation
34+
```
35+
36+
5. Version Management:
37+
```bash
38+
pixi run -e dev get-version # Check current package version
39+
```
40+
41+
6. Conda Packaging:
42+
```bash
43+
pixi run -e dev conda-build # Build conda package
44+
pixi run -e dev render # Rerender conda-smithy configuration
45+
pixi run -e dev conda-upload # Upload package to fortiers channel
46+
```
47+
48+
## Development Environment
49+
50+
The project includes a `dev` environment with additional tools for development:
51+
- Testing: pytest
52+
- Code Quality: ruff
53+
- Documentation: sphinx and related packages
54+
- Building: setuptools, wheel, pip
55+
56+
To activate the development environment:
57+
```bash
58+
pixi shell --environment dev
59+
```
60+
61+
## Platform-Specific Notes
62+
63+
- The `fstd2nc-deps` package will only be installed on Windows systems
64+
- `eccc_rpnpy` is installed from the fortiers channel
65+
- All other dependencies are fetched from conda-forge by default
66+
- Currently configured for linux-64 platform
67+
68+
## Best Practices
69+
70+
1. Always activate the pixi environment before working on the project:
71+
```bash
72+
pixi shell -e dev
73+
```
74+
75+
2. Update dependencies when needed:
76+
```bash
77+
pixi add <package-name>
78+
```
79+
80+
3. Run code quality checks before committing:
81+
```bash
82+
pixi run -e dev lint
83+
pixi run -e dev format
84+
```
85+
86+
## Troubleshooting
87+
88+
If you encounter issues with the fortiers channel or eccc_rpnpy:
89+
1. Verify the channel is properly added:
90+
```bash
91+
pixi info channels
92+
```
93+
2. Try updating the environment:
94+
```bash
95+
pixi update
96+
```

‎pyproject.toml

+49-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,50 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "numpy"]
2+
requires = ["setuptools>=8.1", "pip>=8.1", "wheel", "hatchling", "numpy"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "fstd2nc"
7+
dynamic = ["version"]
8+
description = "Converts RPN standard files (from Environment Canada) to netCDF files."
9+
readme = "README.md"
10+
authors = [
11+
{name = "Mike Neish"}
12+
]
13+
license = {text = "LGPL-3"}
14+
classifiers = [
15+
"Development Status :: 3 - Alpha",
16+
"Environment :: Console",
17+
"Intended Audience :: Science/Research",
18+
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
19+
"Programming Language :: Python",
20+
"Topic :: Scientific/Engineering :: Atmospheric Science"
21+
]
22+
urls = {Homepage = "https://github.com/neishm/fstd2nc"}
23+
dependencies = [
24+
"numpy >= 1.13.0, != 1.15.3",
25+
"netcdf4",
26+
'fstd2nc-deps >= 0.20200304.0 ; sys_platform == "win32"'
27+
]
28+
29+
[project.optional-dependencies]
30+
manyfiles = ["pandas", "progress"]
31+
array = ["xarray>=0.10.3", "dask", "toolz"]
32+
iris = ["iris>=2.0", "xarray>=0.10.3", "dask", "toolz"]
33+
pygeode = ["pygeode>=1.2.2", "xarray>=0.10.3", "dask", "toolz"]
34+
35+
[project.scripts]
36+
fstd2nc = "fstd2nc.__main__:_fstd2nc_cmdline_trapped"
37+
fstdump = "fstd2nc.__main__:_fstdump"
38+
ccc2nc = "cccbuffer.__main__:run"
39+
cccdump = "cccbuffer.cccdump:run"
40+
41+
[project.entry-points."xarray.backends"]
42+
fstd = "fstd2nc._xarray_hook:FSTDBackendEntrypoint"
43+
ccc = "cccbuffer._xarray_hook:CCCBackendEntrypoint"
44+
45+
[tool.setuptools]
46+
packages.find = {} # Equivalent to find_packages() in setup.py
47+
package-data = {fstd2nc = ["locale/*/LC_MESSAGES/fstd2nc.mo"]}
48+
49+
[tool.setuptools.dynamic]
50+
version = {attr = "fstd2nc.__version__"}

‎setup.py ‎setup.py.bk

File renamed without changes.

0 commit comments

Comments
 (0)
Please sign in to comment.