dynamic-dependencies 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ __all__ = ["optional_dependencies", "dependencies", "Config"]
2
+
3
+ from dynamic_dependencies.calculate import dependencies, optional_dependencies
4
+ from dynamic_dependencies.config import Config
@@ -0,0 +1,15 @@
1
+ __all__ = ["dependencies", "optional_dependencies"]
2
+
3
+ from dynamic_dependencies.config import Config
4
+
5
+
6
+ def dependencies(config: Config) -> list[str] | None:
7
+ if config.require is None:
8
+ return None
9
+ return config.resolve(config.require)
10
+
11
+
12
+ def optional_dependencies(config: Config) -> dict[str, list[str]] | None:
13
+ if config.optional is None:
14
+ return None
15
+ return {key: config.resolve(value) for key, value in config.optional}
@@ -0,0 +1,36 @@
1
+ __all__ = ["Config"]
2
+
3
+ import sys
4
+ from dataclasses import dataclass
5
+ from functools import cached_property
6
+ from os import PathLike
7
+
8
+ from dependency_groups import DependencyGroupResolver
9
+ from typing_extensions import Self
10
+
11
+ if sys.version_info >= (3, 11):
12
+ import tomllib
13
+ else:
14
+ import tomli as tomllib
15
+
16
+
17
+ @dataclass
18
+ class Config:
19
+ dependency_groups: dict[str, list[str | dict[str, str]]]
20
+ require: str | None = None
21
+ optional: dict[str, str] | None = None
22
+
23
+ @classmethod
24
+ def from_pyproject(cls, file: str | PathLike[str] = "pyproject.toml") -> Self:
25
+ with open(file, "rb") as f:
26
+ data = tomllib.load(f)
27
+ tool_data = data.get("tool", {}).get("dynamic_dependencies", {})
28
+ dependency_groups = data.get("dependency-groups", {})
29
+ return cls(dependency_groups=dependency_groups, **tool_data)
30
+
31
+ @cached_property
32
+ def resolver(self) -> DependencyGroupResolver:
33
+ return DependencyGroupResolver(self.dependency_groups)
34
+
35
+ def resolve(self, group: str) -> list[str]:
36
+ return list(map(str, self.resolver.resolve(group)))
@@ -0,0 +1,13 @@
1
+ __all__ = ["finalize_distribution_options"]
2
+
3
+ from setuptools import Distribution
4
+
5
+ from dynamic_dependencies import dependencies, optional_dependencies, Config
6
+
7
+
8
+ def finalize_distribution_options(dist: Distribution) -> None:
9
+ config = Config.from_pyproject()
10
+ if config.require is not None:
11
+ dist.install_requires = dependencies(config)
12
+ if config.optional is not None:
13
+ dist.extras_require = optional_dependencies(config)
File without changes
@@ -0,0 +1,91 @@
1
+ Metadata-Version: 2.4
2
+ Name: dynamic-dependencies
3
+ Version: 1.0.0
4
+ Summary: Dependencies based on `dependency-groups'.
5
+ Author-email: Ярыкин Евгений <pypi@zedzhen.ru>
6
+ License-Expression: Zlib
7
+ Project-URL: source, https://github.com/zedzhen/dynamic_dependencies
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: dependency-groups~=1.3
12
+ Requires-Dist: tomli~=2.0; python_version < "3.11"
13
+ Requires-Dist: typing-extensions~=4.14
14
+ Provides-Extra: setuptools
15
+ Requires-Dist: dynamic_dependencies_setuptools==1.0.0; extra == "setuptools"
16
+ Dynamic: license-file
17
+ Dynamic: provides-extra
18
+ Dynamic: requires-dist
19
+
20
+ # EN
21
+ [RU](#ru)
22
+
23
+ Dependencies based on `dependency-groups'.
24
+
25
+ ### Usage:
26
+ Add `dynamic_dependencies[setuptools]` to build-system.requires (in the pyproject.toml file)
27
+ ```toml
28
+ [build-system]
29
+ requires = [
30
+ "setuptools>=81.0.0",
31
+ "dynamic_dependencies[setuptools]~=1.0",
32
+ ]
33
+ ```
34
+
35
+ If you use a different backend for the build:
36
+ 1. Add `dynamic_dependencies` instead of `dynamic_dependencies[setuptools]`
37
+ 2. Read the configuration from `pyproject.toml` `dynamic_dependencies.Config.from_pyproject`
38
+ 3. Get the dependency lists by calling `dynamic_dependencies.dependencies` and `dynamic_dependencies.optional_dependencies'.
39
+ 4. Write it down in the distribution information.
40
+ 5. *If this is a public builder, create a PR/issue to add
41
+
42
+ ### configuration:
43
+ ```toml
44
+ [tool.dynamic_dependencies]
45
+ require = "name1"
46
+ optional = {
47
+ "grp1" = "name2",
48
+ "grp2" = "name3"
49
+ }
50
+ ```
51
+
52
+ The group `name1` will be added to the required dependencies.
53
+ The group `name2` will be added to the optional dependencies as `grp1` (`...[grp1]`).
54
+ The group `name3` will be added to the optional dependencies as `grp2` (`...[grp2]`).
55
+
56
+ # RU
57
+ [EN](#en)
58
+
59
+ Зависимости основанные на `dependency-groups`.
60
+
61
+ ### Использование:
62
+ Добавьте `dynamic_dependencies[setuptools]` в build-system.requires (в файл pyproject.toml)
63
+ ```toml
64
+ [build-system]
65
+ requires = [
66
+ "setuptools>=81.0.0",
67
+ "dynamic_dependencies[setuptools]~=1.0",
68
+ ]
69
+ ```
70
+
71
+ Если вы используете другой бекенд для сборки:
72
+ 1. Добавьте `dynamic_dependencies`, вместо `dynamic_dependencies[setuptools]`
73
+ 2. Прочтите конфигурацию из `pyproject.toml` `dynamic_dependencies.Config.from_pyproject`
74
+ 3. Получите списки зависимостей вызвав `dynamic_dependencies.dependencies` и `dynamic_dependencies.optional_dependencies`.
75
+ 4. Запишите в информацию о дистрибутиве.
76
+ 5. *Если это публичный сборщик, создайте PR/issue на добавление
77
+
78
+ ### конфигурация:
79
+
80
+ ```toml
81
+ [tool.dynamic_dependencies]
82
+ require = "name1"
83
+ optional = {
84
+ "grp1" = "name2",
85
+ "grp2" = "name3"
86
+ }
87
+ ```
88
+
89
+ Группа `name1` будет добавлена в обязательные зависимости.
90
+ Группа `name2` будет добавлена в НЕобязательные зависимости как `grp1` (`...[grp1]`).
91
+ Группа `name3` будет добавлена в НЕобязательные зависимости как `grp2` (`...[grp2]`).
@@ -0,0 +1,10 @@
1
+ dynamic_dependencies/__init__.py,sha256=lOkJA51ARpaZjraAH1nPV0yDKIHFF7WTDLWQwy1cqm8,189
2
+ dynamic_dependencies/calculate.py,sha256=5Cvi8DNVC32eBwE-_Qz-_O71bmsGx2DnrBTiF4v5X54,451
3
+ dynamic_dependencies/config.py,sha256=PrviLEV_Tm33AcazNfah6N-qTf0JthBzGhkDRhR5Lh0,1088
4
+ dynamic_dependencies/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ dynamic_dependencies/integrations/setuptools_.py,sha256=sHXWEdqIDJiU3fYd81-KHWTuKy1-TGtxBMSERiwY_NM,445
6
+ dynamic_dependencies-1.0.0.dist-info/licenses/LICENSE,sha256=wSk_aA_JNno1E0FfQHlndm5sGQjbFq_Lgyum47q71Eo,892
7
+ dynamic_dependencies-1.0.0.dist-info/METADATA,sha256=s6pImdfGPLNxojWrKQLwyTKUMsKK1IfRbJm-YMusCTE,3233
8
+ dynamic_dependencies-1.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
9
+ dynamic_dependencies-1.0.0.dist-info/top_level.txt,sha256=dei5rUBJaXqXcTSo8GlBjmokXV7rYqIqMeQ4jKI_ll8,21
10
+ dynamic_dependencies-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,19 @@
1
+ The zlib/libpng License
2
+
3
+ Copyright (c) 2026 Ярыкин Евгений
4
+
5
+ This software is provided 'as-is', without any express or implied
6
+ warranty. In no event will the authors be held liable for any damages
7
+ arising from the use of this software.
8
+
9
+ Permission is granted to anyone to use this software for any purpose,
10
+ including commercial applications, and to alter it and redistribute it
11
+ freely, subject to the following restrictions:
12
+
13
+ 1. The origin of this software must not be misrepresented; you must not
14
+ claim that you wrote the original software. If you use this software
15
+ in a product, an acknowledgement in the product documentation would be
16
+ appreciated but is not required.
17
+ 2. Altered source versions must be plainly marked as such, and must not be
18
+ misrepresented as being the original software.
19
+ 3. This notice may not be removed or altered from any source distribution.
@@ -0,0 +1 @@
1
+ dynamic_dependencies