|
1 | 1 | ## Notes for PnetCDF-python developers |
2 | 2 | --- |
3 | | -### Note on python library packaging |
| 3 | +### Library packaging and publishing |
| 4 | + * Packaging: build source distribution and wheel distribution (optional) |
| 5 | + 1. Create virtual env and install PnetCDF-C and all python dependencies as developer installation |
| 6 | + 2. Update version number, cd to repo directory and generate distribution: |
| 7 | + ``` |
| 8 | + python3 -m pip install --upgrade build twine |
| 9 | + ``` |
| 10 | + ``` |
| 11 | + CC=/path/to/mpicc PNETCDF_DIR=/path/to/pnetcdf/dir python3 -m build |
| 12 | + ``` |
| 13 | + * Publish on [TestPyPI](https://packaging.python.org/en/latest/guides/using-testpypi/) for testing |
| 14 | + 1. Create TestPyPI account and update `.pypirc` as instruction |
| 15 | + 2. Publish source distribution on TestPyPI |
| 16 | + ``` |
| 17 | + python3 -m pip install --upgrade build twine |
| 18 | + ``` |
| 19 | + ``` |
| 20 | + python3 -m twine upload --repository testpypi dist/pnetcdf-x.x.x.tar.gz |
| 21 | + ``` |
| 22 | + 3. Create and activate a new vanilla python env for testing. Make sure PnetCDF-C and mpich is installed. Then quick install via the distribution on TestPyPI (no python dependencies required). Note that `-i` redirects pip-install to search pnetcdf-python in testpypi index and `--extra-index-url` redirects pip-install to search dependency libraries (e.g. numpy) in official pypi index. |
| 23 | + ``` |
| 24 | + CC=/path/to/mpicc PNETCDF_DIR=/path/to/pnetcdf/dir pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple pnetcdf==x.x.x |
| 25 | + ``` |
| 26 | + |
| 27 | + 4. Run test programs |
| 28 | + |
| 29 | + |
| 30 | +### Library installation |
4 | 31 | * Quick install |
5 | 32 | * Currently, quick install via `pip install pnetcdf` is disabled. Main challenge is that build distribution (using wheels) is platform-specific and multiple wheels need to be generated to cover all mainstream platforms. A working source distribution for `pip install` is easier and has been tested on PyPI (works for all platforms but still needs MPI and PnetCDF-C installation) |
6 | 33 | * `MANIFEST.in` controls files to be included in source distribution (sdist), which will be eventually uploaded to PyPI if we enables quick install in the future. After modifications to `MANIFEST.IN` file, here are steps to check if the files included are valid to build the library. |
|
39 | 66 | * `dependencies` defines python libraries required for running the project and will first check if requirement already satisfied in current environment before installing the latest qualified version of the library. |
40 | 67 | * `requires` defines libraries required for building the project. `pip install` by default creates and uses isolated building env for building stage which completely ignores current user env. For example, if user already installed mpi4py==3.1.6, "mpi4py>=3.1.4" will still automatically install a mpi4py 4.0.0 in the building env and thereafter use syntax from 4.0.0 to build pnetcdf-python. This caused version mismatch issues between building and running envs when numpy 2.0 and mpi4py 4.0.0 are released. To address this issue, current user guide forces to use current python env for building stage by adding ` -no-build-isolation` arg to `pip install` command. |
41 | 68 |
|
| 69 | +
|
42 | 70 | ### Note on configuring Read the Docs tool for user guide generation |
43 | 71 | * Read the Docs settings |
44 | 72 | * User guide is automatically generated on main branch changes and opened PR requests. Modify this in Read the Docs dashboard if needed |
|
0 commit comments