Description
Issue: Tests Fail Due to Missing setuptools_scm
in OA Template
Description
After creating a package using the OpenAstronomy packaging-guide template and installing it in editable mode, running tests with pytest
fails with the following error:
ModuleNotFoundError: No module named 'setuptools_scm'
The issue likely arises because the test environment attempts to access files inside the _dev
directory, which depends on setuptools_scm
. However, setuptools_scm
is not required in the test environment. This issue is resolved locally when setuptools_scm
is manually installed, but when running the pytest
CI workflow, the error persists:
pkgname/_dev/scm_version.py:6: in <module>
from setuptools_scm import get_version
ModuleNotFoundError: No module named 'setuptools_scm'
Workarounds
The issue can be resolved by:
- Manually pip installing
setuptools_scm
in the environment. - Adding
setuptools_scm
to the package dependencies. - Excluding the
_dev
directory frompytest
by adding the following topyproject.toml
:[tool.pytest.ini_options] norecursedirs = ["pkgname[\\/]_dev"]
Expected Behavior
- The package should install and test successfully without manually installing
setuptools_scm
.
- The test environment should not require files inside_dev
Environment
- Latest OA template
- Python Version: 3.13.2 | packaged by conda-forge | [Clang 18.1.8 ]
- OS: Darwin 24.3.0
- Pip Version: 25.0.1
- Pytest Version: 8.3.5
I have tried creating the package multiple times and encountered this issue consistently, but I'm unsure of the root cause within the template. The last fix (i.e., norecursedirs) seems like a global workaround, though I'm curious if this error is reproducible on a different machine.