Skip to content

Only install mpas_tools, not tests, into site-packages - #786

Merged
xylar merged 5 commits into
MPAS-Dev:masterfrom
xylar:fix-packaging
Nov 25, 2026
Merged

xylar merged 5 commits into
MPAS-Dev:masterfrom
xylar:fix-packaging

Conversation

@xylar

@xylar xylar commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

The mpas_tools package currently installs a top-level tests package into site-packages. This shadows the tests package of downstream projects. For example, pytest tests in Polaris fails with No module named 'tests.test_task'.

This PR:

  • switches package discovery to an allow-list (mpas_tools, mpas_tools.*), so only mpas_tools is installed
  • replaces MANIFEST.in with [tool.setuptools.package-data] in pyproject.toml, which also picks up a previously missed Publications.bib
  • adds a test that the package-data patterns cover every non-Python file git tracks under mpas_tools
  • fixes setuptools build warnings: uses a PEP 639 license expression, adds LICENSE and README.md symlinks (setuptools couldn't find either), and puts the description on one line
  • requires setuptools >=77 in recipe.yaml, dev-spec.txt and pixi.toml to match pyproject.toml
  • fixes test_dependencies.py, which was failing on master because it didn't map dask-core (recipe) to dask (PyPI)
  • brings the recipe and ci/ variant files up to date with the conda-forge feedstock: ${CMAKE_ARGS} in build.sh, no netcdf4 at build time, and the feedstock's hdf5 2 variants (newer compilers, hdf5 and libnetcdf)

Once this is released, the feedstock needs a new build to remove tests/ from existing environments.

🤖 Generated with Claude Code

Switch package discovery from an exclude-list to an allow-list so that
the top-level `tests` package (and any stray directory picked up as a
namespace package, such as a leftover `build/`) is no longer installed
into site-packages, where it shadows downstream projects' own `tests`.

Also:
- replace MANIFEST.in with `[tool.setuptools.package-data]` globs, which
  picks up the previously missed `Publications.bib`
- add a test that the package-data patterns match every non-Python file
  git tracks under `mpas_tools`
- use a PEP 639 license expression and `license-files` (setuptools>=77)
  and drop the deprecated license classifier
- symlink LICENSE and README.md into conda_package so setuptools can
  find them
- make the description a single line, as setuptools requires

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xylar

xylar commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator Author

Testing

I built the wheel with pip wheel . --no-deps --no-build-isolation before and after this change:

Before After
Top-level entries mpas_tools/, tests/, build/ (from a leftover in-tree build) mpas_tools/ only
Data files 1 tracked file missing (Publications.bib) match git ls-files mpas_tools exactly
setuptools warnings license deprecations, LICENSE/README.md not found, multi-line summary none
License in metadata none License-Expression: BSD-3-Clause, plus LICENSE in the wheel

python -m build --sdist also builds with no warnings.

I also ran the new tests/test_packaging.py:

  • it passes on this branch
  • it fails and names the file if I remove the **/*.bib pattern
  • it skips outside a git checkout, e.g. in the conda recipe's test step

tests/test_dependencies.py failed on master (dask vs. dask-core) and now passes.

I also ran a local recipe build with rattler-build build -m ci/linux_64_python3.14.____cpython.yaml -r recipe/. It builds against hdf5 2 and all recipe tests pass (pytest: 98 passed, 6 skipped). The 6 skipped are the source-checkout-only tests. The built package's site-packages has only mpas_tools/ and its dist-info.

xylar and others added 4 commits November 25, 2026 16:07
This matches the build-system requirement in pyproject.toml, which is
needed for the PEP 639 license metadata.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The recipe switched from dask to dask-core, but the test was not
updated, so it failed in a source checkout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pass ${CMAKE_ARGS} to cmake (needed for cross-compiling) and drop
netcdf4, which is not needed at build time, from the host requirements.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Take the hdf5 2 variants from the feedstock's .ci_support (newer
compilers, docker image, hdf5 and libnetcdf), keeping the local file
names that the build workflow expects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xylar xylar self-assigned this Nov 25, 2026
@xylar
xylar merged commit e3e951f into MPAS-Dev:master Nov 25, 2026
5 checks passed
@xylar
xylar deleted the fix-packaging branch November 25, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant