Skip to content

Commit 4a17fc7

Browse files
authored
feat: add support for Python 3.12 when determining what's in the stdlib (#143)
* fix(stdlibs): fallback to last item - i.e 'last' known Python version - in stdlibs if no match * fix(stdlib): add 3.12 stdlib with removed modules + fix missing 3.11 modules that should have been there * fix(test internals): check for existing dist with dash and with package name using underscore * fix: bump lock files * bump version to 1.12.2
1 parent 26b8ddd commit 4a17fc7

File tree

7 files changed

+279
-224
lines changed

7 files changed

+279
-224
lines changed

components/polylith/libs/grouping.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,16 @@ def get_python_version() -> str:
1111
return f"{sys.version_info.major}.{sys.version_info.minor}"
1212

1313

14+
def get_latest_standard_libs() -> Set[str]:
15+
values = list(standard_libs.values())
16+
17+
return values[-1]
18+
19+
1420
def get_standard_libs(python_version: str) -> Set[str]:
15-
return standard_libs.get(python_version, set())
21+
libs = standard_libs.get(python_version)
22+
23+
return libs or get_latest_standard_libs()
1624

1725

1826
def exclude_libs(import_data: dict, to_exclude: Set) -> dict:

components/polylith/libs/stdlib.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,24 @@ def to_py310(stdlib: set) -> set:
248248

249249

250250
def to_py311(stdlib: set) -> set:
251-
news = {"tomllib"}
251+
news = {"tomllib", "_tkinter", "sitecustomize", "usercustomize"}
252252
removed = {"binhex"}
253253

254254
return union(stdlib, news, removed)
255255

256256

257+
def to_py312(stdlib: set) -> set:
258+
news: set = set()
259+
removed = {"asynchat", "asyncore", "distutils", "imp", "smtpd"}
260+
261+
return union(stdlib, news, removed)
262+
263+
257264
py38 = with_extras(stdlib_python_3_8)
258265
py39 = to_py39(py38)
259266
py310 = to_py310(py39)
260267
py311 = to_py311(py310)
268+
py312 = to_py312(py311)
261269

262270

263-
standard_libs = {"3.8": py38, "3.9": py39, "3.10": py310, "3.11": py311}
271+
standard_libs = {"3.8": py38, "3.9": py39, "3.10": py310, "3.11": py311, "3.12": py312}

poetry.lock

Lines changed: 145 additions & 135 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/poetry_polylith_plugin/poetry.lock

Lines changed: 92 additions & 82 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/poetry_polylith_plugin/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "poetry-polylith-plugin"
3-
version = "1.12.1"
3+
version = "1.12.2"
44
description = "A Poetry plugin that adds tooling support for the Polylith Architecture"
55
authors = ["David Vujic"]
66
homepage = "https://davidvujic.github.io/python-polylith-docs/"

test/components/polylith/libs/test_stdlib.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,23 @@ def test_stdlib_3_11():
2929
py311 = stdlib.standard_libs["3.11"]
3030

3131
assert py310.difference(py311) == {"binhex"}
32-
assert py311.difference(py310) == {"tomllib"}
32+
assert py311.difference(py310) == {
33+
"tomllib",
34+
"_tkinter",
35+
"sitecustomize",
36+
"usercustomize",
37+
}
38+
39+
40+
def test_stdlib_3_12():
41+
py311 = stdlib.standard_libs["3.11"]
42+
py312 = stdlib.standard_libs["3.12"]
43+
44+
assert py311.difference(py312) == {
45+
"asynchat",
46+
"asyncore",
47+
"distutils",
48+
"imp",
49+
"smtpd",
50+
}
51+
assert py312.difference(py311) == set()

test/components/polylith/poetry/test_internals.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def test_distribution_packages():
4040

4141
res = internals.distributions_packages(dists)
4242

43-
expected_dist = "importlib-metadata"
44-
expected_package = "importlib_metadata"
43+
expected_dist = "mypy-extensions"
44+
expected_package = "mypy_extensions"
4545

4646
assert res.get(expected_dist) is not None
4747
assert res[expected_dist] == [expected_package]

0 commit comments

Comments
 (0)