Skip to content

Bug: Pytests Fail Due to Missing setuptools_scm #82

Open
@slizewsk

Description

@slizewsk

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 from pytest by adding the following to pyproject.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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions