Skip to content

consider removing setup.py #233

Description

@vredchenko

Context

Discovered during review of PR #229 (Docker rework) and smartem-devtools PR DiamondLightSource/smartem-devtools#166.

Current state

setup.py hooks into three setuptools commands (install, develop, egg_info) to do two things:

  1. copy_version_files() — Copies src/_version.py to each sub-package (smartem_backend, smartem_agent, smartem_common, smartem_api)
  2. copy_dotenv() — Copies .env.example to .env if .env doesn't exist

Why it may be unnecessary

copy_version_files() is redundant

setuptools-scm already handles version file generation via the [tool.setuptools_scm] version_file config in pyproject.toml. The setup.py hook duplicates this work. Verified empirically: Docker builds produce correct _version.py files without the setup.py hook firing.

copy_dotenv() is a minor convenience with limited reach

  • Only reliably works in editable installs (pip install -e .) on the host
  • Does not fire reliably during PEP 517 wheel builds (which is what pip install ., uv, and Docker builds use)
  • .dockerignore excludes .env.example (matches .env.*), so it never enters Docker build context — verified empirically
  • Could be replaced by a note in README or a Makefile target

cmdclass hooks are a legacy mechanism

Modern Python packaging (PEP 517/518) uses build backends that don't necessarily invoke setuptools command classes. The hooks work in editable installs but are unreliable in standard installs.

Related

What to investigate

  • Can setup.py be deleted entirely?
  • Is there a better mechanism for the .env.example.env convenience (e.g. documented manual step, Makefile)?
  • Are there any other consumers of the cmdclass hooks?
  • Does the duplicate .env.example in smartem-decisions still serve a purpose if setup.py is removed? (identical copy exists in smartem-devtools/env-examples/)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementMinor improvements to existing functionality

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions