File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
src/setuptools_scm/_integration Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -228,6 +228,19 @@ def read_pyproject(
228
228
requires ,
229
229
)
230
230
231
+ setuptools_dynamic_version = (
232
+ defn .get ("tool" , {})
233
+ .get ("setuptools" , {})
234
+ .get ("dynamic" , {})
235
+ .get ("version" , None )
236
+ )
237
+ if setuptools_dynamic_version is not None :
238
+ warnings .warn (
239
+ f"{ path } : at [tool.setuptools.dynamic]\n "
240
+ "version = {attr = ...} is sabotaging setuptools-scm"
241
+ )
242
+ section ["version" ] = None
243
+
231
244
return pyproject_data
232
245
233
246
Original file line number Diff line number Diff line change @@ -126,3 +126,23 @@ def test_read_pyproject_with_given_definition(monkeypatch: pytest.MonkeyPatch) -
126
126
)
127
127
128
128
assert res .should_infer ()
129
+
130
+
131
+ def test_read_pyproject_with_setuptools_dynamic_version_warns () -> None :
132
+ with pytest .warns (
133
+ UserWarning ,
134
+ match = r"pyproject.toml: at \[tool\.setuptools\.dynamic\]\n"
135
+ r"version = {attr = \.\.\.} is sabotaging setuptools-scm" ,
136
+ ):
137
+ pyproject_data = read_pyproject (
138
+ _given_definition = {
139
+ "build-system" : {"requires" : ["setuptools-scm[simple]" ]},
140
+ "project" : {"name" : "test-package" , "dynamic" : ["version" ]},
141
+ "tool" : {
142
+ "setuptools" : {
143
+ "dynamic" : {"version" : {"attr" : "test_package.__version__" }}
144
+ }
145
+ },
146
+ }
147
+ )
148
+ assert pyproject_data .project_version is None
You can’t perform that action at this time.
0 commit comments