-
-
Notifications
You must be signed in to change notification settings - Fork 227
Fix 1216 explicitly deprecate setuptools dynamic version when active #1219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7570f68
e67c027
629f4f4
a47b08e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import warnings | ||
|
||
from pathlib import Path | ||
|
||
|
||
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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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". |
||
"When using setuptools-scm its invalid to use setuptools dynamic version as well, please removeit.\n" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing space in Edit: |
||
"Setuptools-scm is responsible for setting the version, forcing setuptools to override creates errors." | ||
) | ||
|
||
|
||
def warn_pyproject_setuptools_dynamic_version(path: Path) -> None: | ||
warn_dynamic_version(path, "tool.setuptools.dynamic", "version = {attr = ...}") | ||
|
||
|
||
def warn_setup_cfg_dynamic_version(path: Path) -> None: | ||
warn_dynamic_version(path, "metadata", "version = attr: ...}") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,6 +174,7 @@ def read_pyproject( | |
tool_name: str = DEFAULT_TOOL_NAME, | ||
canonical_build_package_name: str = "setuptools-scm", | ||
_given_result: _t.GivenPyProjectResult = None, | ||
_given_definition: TOML_RESULT | None = None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
) -> PyProjectData: | ||
"""Read and parse pyproject configuration. | ||
|
||
|
@@ -195,7 +196,10 @@ def read_pyproject( | |
if isinstance(_given_result, (InvalidTomlError, FileNotFoundError)): | ||
raise _given_result | ||
|
||
defn = read_toml_content(path) | ||
if _given_definition is not None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] The conditional logic for Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
defn = _given_definition | ||
else: | ||
defn = read_toml_content(path) | ||
|
||
requires: list[str] = defn.get("build-system", {}).get("requires", []) | ||
is_required = has_build_package(requires, canonical_build_package_name) | ||
|
@@ -224,6 +228,17 @@ def read_pyproject( | |
requires, | ||
) | ||
|
||
setuptools_dynamic_version = ( | ||
defn.get("tool", {}) | ||
.get("setuptools", {}) | ||
.get("dynamic", {}) | ||
.get("version", None) | ||
) | ||
if setuptools_dynamic_version is not None: | ||
from .deprecation import warn_pyproject_setuptools_dynamic_version | ||
|
||
warn_pyproject_setuptools_dynamic_version(path) | ||
|
||
return pyproject_data | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""Test deprecation warnings and their exact text.""" | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from setuptools_scm._integration.deprecation import warn_dynamic_version | ||
|
||
|
||
def test_warn_dynamic_version_full_text() -> None: | ||
"""Test the complete warning text for warn_dynamic_version function.""" | ||
test_path = Path("test_file.toml") | ||
expected_warning = ( | ||
f"{test_path}: at [test.section]\n" | ||
"test_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" | ||
"Setuptools-scm is responsible for setting the version, forcing setuptools to override creates errors." | ||
) | ||
|
||
with pytest.warns(UserWarning) as warning_info: # noqa: PT030 | ||
warn_dynamic_version(test_path, "test.section", "test_expression") | ||
|
||
assert len(warning_info) == 1 | ||
assert str(warning_info[0].message) == expected_warning |
There was a problem hiding this comment.
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.Copilot uses AI. Check for mistakes.