polylith-cli 0.1.0__tar.gz → 0.2.0__tar.gz
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.
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/PKG-INFO +1 -1
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/commands/check.py +9 -10
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/commands/libs.py +3 -5
- polylith_cli-0.2.0/polylith_cli/polylith/distributions/__init__.py +3 -0
- polylith_cli-0.2.0/polylith_cli/polylith/distributions/collect.py +21 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/distributions/core.py +28 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/project/get.py +5 -4
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/pyproject.toml +1 -1
- polylith_cli-0.1.0/polylith_cli/polylith/distributions/__init__.py +0 -2
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/README.md +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/alias/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/alias/core.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/bricks/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/bricks/base.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/bricks/brick.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/bricks/component.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/check/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/check/collect.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/check/grouping.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/check/report.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/cli/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/cli/__main__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/cli/core.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/cli/create.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/cli/options.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/commands/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/commands/create.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/commands/diff.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/commands/info.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/commands/sync.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/development/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/development/development.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/diff/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/diff/collect.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/diff/report.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/dirs/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/dirs/dirs.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/files/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/files/files.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/imports/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/imports/parser.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/info/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/info/collect.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/info/report.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/interface/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/interface/interfaces.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/libs/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/libs/grouping.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/libs/report.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/libs/stdlib.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/project/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/project/create.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/project/parser.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/project/templates.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/readme/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/readme/readme.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/repo/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/repo/get.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/repo/repo.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/reporting/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/reporting/theme.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/sync/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/sync/collect.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/sync/report.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/sync/update.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/test/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/test/tests.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/workspace/__init__.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/workspace/create.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/workspace/parser.py +0 -0
- {polylith_cli-0.1.0 → polylith_cli-0.2.0}/polylith_cli/polylith/workspace/paths.py +0 -0
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import importlib.metadata
|
|
2
1
|
from pathlib import Path
|
|
3
|
-
from
|
|
2
|
+
from typing import Set
|
|
3
|
+
from polylith_cli.polylith import check, distributions
|
|
4
|
+
|
|
5
|
+
def collect_known_aliases(project_data: dict, options: dict) -> Set[str]:
|
|
6
|
+
deps = project_data['deps']
|
|
7
|
+
library_alias = options['alias']
|
|
8
|
+
return distributions.known_aliases_and_sub_dependencies(deps, library_alias)
|
|
4
9
|
|
|
5
10
|
def run(root: Path, ns: str, project_data: dict, options: dict) -> bool:
|
|
6
11
|
is_verbose = options['verbose']
|
|
7
12
|
is_quiet = options['quiet']
|
|
8
13
|
is_strict = options['strict']
|
|
9
|
-
library_alias = options['alias']
|
|
10
|
-
third_party_libs = project_data['deps']
|
|
11
14
|
name = project_data['name']
|
|
12
15
|
collected_imports = check.report.collect_all_imports(root, ns, project_data)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
known_aliases.update(alias.parse(library_alias))
|
|
16
|
-
extra = alias.pick(known_aliases, third_party_libs)
|
|
17
|
-
libs = third_party_libs.union(extra)
|
|
18
|
-
details = check.report.create_report(project_data, collected_imports, libs, is_strict)
|
|
16
|
+
collected_libs = collect_known_aliases(project_data, options)
|
|
17
|
+
details = check.report.create_report(project_data, collected_imports, collected_libs, is_strict)
|
|
19
18
|
res = all([not details['brick_diff'], not details['libs_diff']])
|
|
20
19
|
if not is_quiet:
|
|
21
20
|
check.report.print_missing_deps(details['brick_diff'], name)
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
|
-
from polylith_cli.polylith import
|
|
2
|
+
from polylith_cli.polylith import distributions
|
|
3
3
|
from polylith_cli.polylith.libs import report
|
|
4
4
|
|
|
5
5
|
def run(root: Path, ns: str, project_data: dict, options: dict) -> bool:
|
|
6
6
|
is_strict = options['strict']
|
|
7
7
|
library_alias = options['alias']
|
|
8
8
|
name = project_data['name']
|
|
9
|
-
|
|
9
|
+
deps = project_data['deps']
|
|
10
10
|
brick_imports = report.get_third_party_imports(root, ns, project_data)
|
|
11
11
|
report.print_libs_summary(brick_imports, project_data)
|
|
12
12
|
report.print_libs_in_bricks(brick_imports)
|
|
13
|
-
|
|
14
|
-
extra = alias.pick(library_aliases, third_party_libs)
|
|
15
|
-
libs = third_party_libs.union(extra)
|
|
13
|
+
libs = distributions.known_aliases_and_sub_dependencies(deps, library_alias)
|
|
16
14
|
return report.print_missing_installed_libs(brick_imports, libs, name, is_strict)
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
from polylith_cli.polylith.distributions.collect import known_aliases_and_sub_dependencies
|
|
2
|
+
from polylith_cli.polylith.distributions.core import distributions_packages, distributions_sub_packages, get_distributions
|
|
3
|
+
__all__ = ['distributions_packages', 'distributions_sub_packages', 'get_distributions', 'known_aliases_and_sub_dependencies']
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import importlib.metadata
|
|
2
|
+
from typing import Set
|
|
3
|
+
from polylith_cli.polylith import alias
|
|
4
|
+
from polylith_cli.polylith.distributions.core import distributions_packages, distributions_sub_packages
|
|
5
|
+
|
|
6
|
+
def known_aliases_and_sub_dependencies(deps: dict, library_alias: list) -> Set[str]:
|
|
7
|
+
"""Collect known aliases (packages) for third-party libraries.
|
|
8
|
+
|
|
9
|
+
When the library origin is not from a lock-file:
|
|
10
|
+
collect sub-dependencies for each library, and append to the result.
|
|
11
|
+
"""
|
|
12
|
+
third_party_libs = deps['items']
|
|
13
|
+
lock_file = str.endswith(deps['source'], '.lock')
|
|
14
|
+
dists = list(importlib.metadata.distributions())
|
|
15
|
+
dist_packages = distributions_packages(dists)
|
|
16
|
+
custom_aliases = alias.parse(library_alias)
|
|
17
|
+
sub_deps = distributions_sub_packages(dists) if not lock_file else {}
|
|
18
|
+
a = alias.pick(dist_packages, third_party_libs)
|
|
19
|
+
b = alias.pick(custom_aliases, third_party_libs)
|
|
20
|
+
c = alias.pick(sub_deps, third_party_libs)
|
|
21
|
+
return third_party_libs.union(a, b, c)
|
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
import importlib.metadata
|
|
2
|
+
import re
|
|
2
3
|
from functools import reduce
|
|
3
4
|
from typing import Dict, List
|
|
4
5
|
|
|
5
6
|
|
|
7
|
+
SUB_DEP_SEPARATORS = r"[\s!=;><\^~]"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def parse_sub_package_name(dependency: str) -> str:
|
|
11
|
+
parts = re.split(SUB_DEP_SEPARATORS, dependency)
|
|
12
|
+
|
|
13
|
+
return str(parts[0])
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def dist_subpackages(dist) -> dict:
|
|
17
|
+
name = dist.metadata["name"]
|
|
18
|
+
dependencies = importlib.metadata.requires(name) or []
|
|
19
|
+
|
|
20
|
+
parsed_package_names = list({parse_sub_package_name(d) for d in dependencies})
|
|
21
|
+
|
|
22
|
+
return {name: parsed_package_names} if dependencies else {}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def map_sub_packages(acc, dist) -> dict:
|
|
26
|
+
return {**acc, **dist_subpackages(dist)}
|
|
27
|
+
|
|
28
|
+
|
|
6
29
|
def top_level_packages(dist) -> List[str]:
|
|
7
30
|
top_level = dist.read_text("top_level.txt")
|
|
8
31
|
|
|
@@ -25,6 +48,11 @@ def distributions_packages(dists) -> Dict[str, List[str]]:
|
|
|
25
48
|
return reduce(map_packages, dists, {})
|
|
26
49
|
|
|
27
50
|
|
|
51
|
+
def distributions_sub_packages(dists) -> Dict[str, List[str]]:
|
|
52
|
+
"""Return the dependencies of each distribution."""
|
|
53
|
+
return reduce(map_sub_packages, dists, {})
|
|
54
|
+
|
|
55
|
+
|
|
28
56
|
def get_distributions(project_dependencies: set) -> list:
|
|
29
57
|
dists = importlib.metadata.distributions()
|
|
30
58
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import re
|
|
2
2
|
from functools import lru_cache
|
|
3
3
|
from pathlib import Path
|
|
4
|
-
from typing import List
|
|
4
|
+
from typing import List
|
|
5
5
|
import tomlkit
|
|
6
6
|
from polylith_cli.polylith import repo, workspace
|
|
7
7
|
|
|
@@ -22,13 +22,14 @@ def get_project_name(data) -> str:
|
|
|
22
22
|
return data['project']['name']
|
|
23
23
|
return data['tool']['poetry']['name']
|
|
24
24
|
|
|
25
|
-
def get_project_dependencies(data) ->
|
|
25
|
+
def get_project_dependencies(data) -> dict:
|
|
26
26
|
if repo.is_poetry(data):
|
|
27
27
|
deps = data['tool']['poetry'].get('dependencies', [])
|
|
28
|
-
|
|
28
|
+
items = set(deps.keys())
|
|
29
29
|
else:
|
|
30
30
|
deps = data['project'].get('dependencies', [])
|
|
31
|
-
|
|
31
|
+
items = {re.split('[\\^~=!<>]', dep)[0] for dep in deps}
|
|
32
|
+
return {'items': items, 'source': repo.default_toml}
|
|
32
33
|
|
|
33
34
|
@lru_cache
|
|
34
35
|
def get_toml(path: Path) -> tomlkit.TOMLDocument:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|