|
4 | 4 |
|
5 | 5 | import tomlkit |
6 | 6 | from polylith import configuration, repo, toml |
7 | | - |
8 | | -poetry_pyproject_template = """\ |
9 | | -[tool.poetry] |
10 | | -name = "{name}" |
11 | | -version = "0.1.0" |
12 | | -{description} |
13 | | -{authors} |
14 | | -license = "" |
15 | | -
|
16 | | -packages = [] |
17 | | -
|
18 | | -[tool.poetry.dependencies] |
19 | | -python = "{python_version}" |
20 | | -
|
21 | | -[build-system] |
22 | | -requires = ["poetry-core>=1.0.0"] |
23 | | -build-backend = "poetry.core.masonry.api" |
24 | | -""" |
25 | | - |
26 | | -poetry_pep621_pyproject_template = """\ |
27 | | -[tool.poetry] |
28 | | -packages = [] |
29 | | -
|
30 | | -[project] |
31 | | -name = "{name}" |
32 | | -version = "0.1.0" |
33 | | -{description} |
34 | | -{authors} |
35 | | -
|
36 | | -requires-python = "{python_version}" |
37 | | -
|
38 | | -dependencies = [] |
39 | | -
|
40 | | -[build-system] |
41 | | -requires = ["poetry-core>=1.0.0"] |
42 | | -build-backend = "poetry.core.masonry.api" |
43 | | -""" |
44 | | - |
45 | | -hatch_pyproject_template = """\ |
46 | | -[build-system] |
47 | | -requires = ["hatchling", "hatch-polylith-bricks"] |
48 | | -build-backend = "hatchling.build" |
49 | | -
|
50 | | -[project] |
51 | | -name = "{name}" |
52 | | -version = "0.1.0" |
53 | | -{description} |
54 | | -{authors} |
55 | | -
|
56 | | -requires-python = "{python_version}" |
57 | | -
|
58 | | -dependencies = [] |
59 | | -
|
60 | | -[tool.hatch.build.targets.wheel] |
61 | | -packages = ["{namespace}"] |
62 | | -
|
63 | | -[tool.hatch.build.hooks.polylith-bricks] |
64 | | -
|
65 | | -[tool.polylith.bricks] |
66 | | -""" |
67 | | - |
68 | | -pdm_pyproject_template = """\ |
69 | | -[build-system] |
70 | | -requires = ["pdm-backend", "pdm-polylith-bricks"] |
71 | | -build-backend = "pdm.backend" |
72 | | -
|
73 | | -[project] |
74 | | -name = "{name}" |
75 | | -version = "0.1.0" |
76 | | -{description} |
77 | | -{authors} |
78 | | -
|
79 | | -requires-python = "{python_version}" |
80 | | -
|
81 | | -dependencies = [] |
82 | | -
|
83 | | -[tool.polylith.bricks] |
84 | | -""" |
| 7 | +from polylith.project import templates |
85 | 8 |
|
86 | 9 |
|
87 | 10 | def get_project_name(toml_data) -> str: |
@@ -147,18 +70,18 @@ def get_packages_for_projects(root: Path) -> List[dict]: |
147 | 70 |
|
148 | 71 | def _get_poetry_template(pyproject: dict) -> str: |
149 | 72 | if repo.is_pep_621_ready(pyproject): |
150 | | - return poetry_pep621_pyproject_template |
| 73 | + return templates.poetry_pep621_pyproject_template |
151 | 74 |
|
152 | | - return poetry_pyproject_template |
| 75 | + return templates.poetry_pyproject_template |
153 | 76 |
|
154 | 77 |
|
155 | 78 | def guess_project_template(pyproject: dict) -> str: |
156 | 79 | if repo.is_poetry(pyproject): |
157 | 80 | template = _get_poetry_template(pyproject) |
158 | 81 | elif repo.is_hatch(pyproject): |
159 | | - template = hatch_pyproject_template |
| 82 | + template = templates.hatch_pyproject_template |
160 | 83 | elif repo.is_pdm(pyproject): |
161 | | - template = pdm_pyproject_template |
| 84 | + template = templates.pdm_pyproject_template |
162 | 85 | else: |
163 | 86 | raise ValueError("Failed to guess the type of Project") |
164 | 87 |
|
|
0 commit comments