File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -310,7 +310,6 @@ def from_data(
310310 # Handle nested SCM configuration
311311
312312 scm_config = ScmConfiguration .from_data (scm_data )
313-
314313 return cls (
315314 relative_to = relative_to ,
316315 version_cls = version_cls ,
Original file line number Diff line number Diff line change @@ -228,6 +228,18 @@ def read_pyproject(
228228 requires ,
229229 )
230230
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+
231243 return pyproject_data
232244
233245
Original file line number Diff line number Diff line change @@ -126,3 +126,23 @@ def test_read_pyproject_with_given_definition(monkeypatch: pytest.MonkeyPatch) -
126126 )
127127
128128 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