Skip to content

Conversation

RonnyPfannschmidt
Copy link
Contributor

closes #1216

as enough users cargo culted layering dynamic version from version file into setuptools_scm usage, we explicitly warn about it + its use in setup.cfg/pyproject.toml

@RonnyPfannschmidt RonnyPfannschmidt force-pushed the fix-1216-explicitly-deprecate-setuptools-dynamic-version-when-active branch from ff20cbb to 629f4f4 Compare August 19, 2025 21:26
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds explicit warnings for misconfigurations where users have incorrectly combined setuptools-scm with setuptools dynamic version configurations, a common cargo-culted antipattern that sabotages setuptools-scm functionality.

  • Detects and warns when version = attr: is used in setup.cfg metadata
  • Detects and warns when [tool.setuptools.dynamic] version configuration is present in pyproject.toml
  • Nullifies the problematic version configurations to prevent interference with setuptools-scm

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/setuptools_scm/_integration/setup_cfg.py Adds warning detection for attr-based version in setup.cfg and nullifies it
src/setuptools_scm/_integration/pyproject_reading.py Adds warning detection for setuptools dynamic version in pyproject.toml and supports test injection
testing/test_integration.py Adds test coverage for setup.cfg dynamic version warning behavior
testing/test_pyproject_reading.py Adds test coverage for pyproject.toml dynamic version warning and test utilities
src/setuptools_scm/_config.py Minor whitespace cleanup
CHANGELOG.md Documents the fix for issue #1216

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

tool_name: str = DEFAULT_TOOL_NAME,
canonical_build_package_name: str = "setuptools-scm",
_given_result: _t.GivenPyProjectResult = None,
_given_definition: TOML_RESULT | None = None,
Copy link
Preview

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _given_definition parameter appears to be a testing-only feature but lacks documentation in the docstring. Consider adding documentation for this parameter or making it clear that it's for internal testing use only.

Copilot uses AI. Check for mistakes.



## v9.2.0

Copy link
Preview

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two ## v9.2.0 sections in the changelog, which will create confusion. The second one should likely be a different version number or these sections should be merged.

Suggested change

Copilot uses AI. Check for mistakes.

raise _given_result

defn = read_toml_content(path)
if _given_definition is not None:
Copy link
Preview

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The conditional logic for _given_definition vs read_toml_content(path) should be moved earlier in the function, before the existing _given_result handling, to maintain consistent parameter precedence and avoid potential confusion about which takes priority.

Copilot uses AI. Check for mistakes.

warnings.warn(
f"{path}: at [{section}]\n"
f"{expression} forcing setuptools to override the version setuptools-scm sets\n"
"When using setuptools-scm its invalid to use setuptools dynamic version as well, please removeit.\n"
Copy link

@pjonsson pjonsson Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space in removeit.

Edit: its => it is (or it's)

def warn_dynamic_version(path: Path, section: str, expression: str) -> None:
warnings.warn(
f"{path}: at [{section}]\n"
f"{expression} forcing setuptools to override the version setuptools-scm sets\n"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English isn't my first language, but I think there's a missing "is" before "forcing", and possibly a missing "that" before "setuptools-scm".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9.2.0 broke package discovery in pytest-asyncio==1.1.0 and older
2 participants