Skip to content

Commit b7abd45

Browse files
fix #374 - initialize configuration for toml integration
1 parent b26710a commit b7abd45

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/setuptools_scm/integration.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
from pkg_resources import iter_entry_points
22

33
from .version import _warn_if_setuptools_outdated
4-
from .config import Configuration
54
from .utils import do, trace_exception
6-
from . import get_version, _get_version
5+
from . import get_version
76

87

98
def version_keyword(dist, keyword, value):
@@ -31,9 +30,19 @@ def find_files(path=""):
3130
return []
3231

3332

33+
def _args_from_toml(name="pyproject.toml"):
34+
# todo: more sensible config initialization
35+
# move this elper back to config and unify it with the code from get_config
36+
37+
with open(name) as strm:
38+
defn = __import__("toml").load(strm)
39+
return defn.get("tool", {})["setuptools_scm"]
40+
41+
3442
def infer_version(dist):
43+
3544
try:
36-
config = Configuration.from_file()
45+
args = _args_from_toml()
3746
except Exception:
3847
return trace_exception()
39-
dist.metadata.version = _get_version(config)
48+
dist.metadata.version = get_version(**args)

testing/test_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def wd(wd):
1616

1717

1818
def test_pyproject_support(tmpdir, monkeypatch):
19+
pytest.importorskip("toml")
1920
monkeypatch.delenv("SETUPTOOLS_SCM_DEBUG")
2021
pkg = tmpdir.ensure("package", dir=42)
2122
pkg.join("pyproject.toml").write(
@@ -28,7 +29,6 @@ def test_pyproject_support(tmpdir, monkeypatch):
2829
assert res == "12.34"
2930

3031

31-
@pytest.mark.xfail(reason="#174")
3232
def test_pyproject_support_with_git(tmpdir, monkeypatch, wd):
3333
monkeypatch.delenv("SETUPTOOLS_SCM_DEBUG")
3434
pkg = tmpdir.join("wd")

0 commit comments

Comments
 (0)