Skip to content

Commit b51dd9c

Browse files
committed
resolve usage of uv and poetry
1 parent a45572e commit b51dd9c

File tree

4 files changed

+122
-91
lines changed

4 files changed

+122
-91
lines changed

cookiecutter.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"project_slug": "{{ cookiecutter.project_name | slugify }}",
77
"module_name": "{{ cookiecutter.project_slug | slugify | replace('-', '_') }}",
88
"project_short_description": "A short summary of the project",
9-
"package_manager": ["conda", "pip", "poetry", "uv"],
9+
"package_manager": ["conda", "pip", "poetry","uv"],
1010
"use_notebooks": ["no", "yes"],
1111
"use_docker": ["no", "yes"],
1212
"ci_pipeline": ["none", "gitlab"],
@@ -26,8 +26,7 @@
2626
"__prompt__": "Which [bold yellow]packaging tool[/] would you like to use?",
2727
"conda": "conda (environment.yml)",
2828
"pip": "pip (setup.py)",
29-
"poetry": "poetry (pyproject.toml)",
30-
"uv": "uv (uv.toml)"
29+
"poetry": "poetry (pyproject.toml)"
3130
},
3231
"use_notebooks": {
3332
"__prompt__": "Do you want to include [bold yellow]Jupyter Notebooks[/] in your project?",

hooks/post_gen_project.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
module_dir = 'src/{{ cookiecutter.module_name }}'
1515

1616
files_uv = {
17-
'uv.toml',
17+
'pyproject.toml',
1818
}
1919
files_pip = {
2020
'requirements.txt',
@@ -199,16 +199,13 @@ def _rename_files(file_pattern, old, new):
199199

200200

201201
def _delete_files(files: Iterable[str], exclude: Optional[str] = None):
202-
for file in files:
203-
if file != exclude:
204-
try:
202+
try:
203+
for file in files:
204+
if file != exclude:
205205
os.remove(file)
206-
except FileNotFoundError:
207-
# File does not exist; that's fine.
208-
continue
209-
except OSError as e:
210-
print(f"Error: failed to remove file '{file}' - {e}")
211-
sys.exit(1)
206+
except OSError as e:
207+
print(f"Error: failed to remove files - {e}")
208+
sys.exit(1)
212209

213210

214211
def _delete_folders(folders: Iterable[str], exclude: Optional[str] = None):
Lines changed: 113 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,131 @@
1+
{% if cookiecutter.package_manager == "poetry" -%}
12
[tool.poetry]
23
name = "{{ cookiecutter.project_slug }}"
34
version = "0.1.0"
45
description = "{{ cookiecutter.project_short_description }}"
56
authors = ["{{ cookiecutter.full_name }} <{{ cookiecutter.email }}>"]
67
license = "proprietary"
7-
packages = [{ include = "{{ cookiecutter.module_name }}", from = "src" }, ]
8+
packages = [{ include = "{{ cookiecutter.module_name }}", from = "src" }]
89
include = ["src/{{ cookiecutter.module_name }}/res/*"]
9-
{% if cookiecutter.create_cli == "yes" %}
10-
[tool.poetry.scripts]
11-
{{ cookiecutter.project_slug }} = "{{ cookiecutter.module_name }}.main:app"{% endif %}
1210

1311
[tool.poetry.dependencies]
14-
python = "^3.11"{% if cookiecutter.config_file == 'hocon' %}
15-
pyhocon = "^0.3.59"{% elif cookiecutter.config_file == 'yaml' %}
16-
PyYAML = "^6.0"{% endif %}{% if cookiecutter.create_cli == 'yes' %}
17-
typer = {extras = ["all"], version = "^0.9.0"}{% endif %}
12+
python = "^3.9"
13+
{% if cookiecutter.config_file == 'hocon' -%}
14+
pyhocon = "^0.3.59"
15+
{% elif cookiecutter.config_file == 'yaml' -%}
16+
PyYAML = "^6.0"
17+
{% endif -%}
18+
{% if cookiecutter.create_cli == 'yes' -%}
19+
typer = {extras = ["all"], version = "^0.9.0"}
20+
{% endif -%}
1821

1922
[tool.poetry.group.test.dependencies]
20-
pytest = "^7.0"
21-
pytest-cov = "^4.0"
23+
pytest = "^7.0"
24+
pytest-cov = "^4.0"
2225

23-
[tool.poetry.group.linter.dependencies]{% if cookiecutter.code_formatter == 'black' %}
24-
black = "^23.11"{% else %}
25-
ruff = "^0.1.7"{% endif %}
26-
isort = "^5.12.0"
26+
[tool.poetry.group.linter.dependencies]
27+
{% if cookiecutter.code_formatter == 'black' -%}
28+
black = "^23.11"
29+
{% else -%}
30+
ruff = "^0.1.7"
31+
{% endif -%}
32+
isort = "^5.12.0"
2733

2834
[tool.poetry.group.dev.dependencies]
29-
pre-commit = "^3.0"{% if cookiecutter.use_notebooks == 'yes' %}
30-
jupyterlab = "^3.5"{% endif %}
31-
{% if cookiecutter.code_formatter != 'black' %}
32-
[tool.ruff]
33-
line-length = 100
34-
src = ["src", "tests"]
35-
ignore = ["F401"]
36-
{% endif %}
37-
[tool.isort]{% if cookiecutter.code_formatter == 'black' %}
38-
profile = "black"{% else %}
39-
py_version = 310
40-
line_length = 100
41-
multi_line_output = 3{% endif %}
35+
pre-commit = "^3.0"
36+
{% if cookiecutter.use_notebooks == 'yes' -%}
37+
jupyterlab = "^3.5"
38+
{% endif -%}
39+
40+
[tool.poetry.extras]
41+
build = ["setuptools", "cython"]
42+
compile = ["cchardet"]
43+
44+
[tool.poetry.scripts]
45+
{% if cookiecutter.create_cli == "yes" -%}
46+
{{ cookiecutter.project_slug }} = "{{ cookiecutter.module_name }}.main:app"
47+
{% endif -%}
48+
49+
[tool.isort]
50+
{% if cookiecutter.code_formatter == 'black' -%}
51+
profile = "black"
52+
{% else -%}
53+
line_length = 100
54+
multi_line_output = 3
55+
{% endif -%}
56+
57+
[tool.pytest.ini_options]
58+
minversion = "7.0"
59+
testpaths = ["tests"]
60+
61+
[build-system]
62+
requires = ["poetry-core"]
63+
build-backend = "poetry.core.masonry.api"
64+
65+
{% else -%}
66+
67+
[project]
68+
name = "{{ cookiecutter.project_slug }}"
69+
version = "0.1.0"
70+
description = "{{ cookiecutter.project_short_description }}"
71+
authors = [{ name = "{{ cookiecutter.full_name }}", email = "{{ cookiecutter.email }}" }]
72+
license = "proprietary"
73+
requires-python = ">=3.9"
74+
dependencies = [
75+
{% if cookiecutter.config_file == 'hocon' -%}
76+
"pyhocon>=0.3.59",
77+
{% elif cookiecutter.config_file == 'yaml' -%}
78+
"PyYAML>=6.0",
79+
{% endif -%}
80+
{% if cookiecutter.create_cli == 'yes' -%}
81+
"typer[all]>=0.9.0",
82+
{% endif -%}
83+
]
84+
85+
[project.optional-dependencies]
86+
build = ["setuptools", "cython"]
87+
compile = ["cchardet"]
88+
89+
[project.scripts]
90+
{% if cookiecutter.create_cli == "yes" -%}
91+
{{ cookiecutter.project_slug }} = "{{ cookiecutter.module_name }}.main:app"
92+
{% endif -%}
93+
94+
[project.gui-scripts]
95+
hello_gui = "{{ cookiecutter.module_name }}.gui:main"
96+
97+
[project.entry-points."example.plugins"]
98+
a = "{{ cookiecutter.module_name }}_plugin_a"
99+
100+
[dependency-groups]
101+
dev = [
102+
{% if cookiecutter.use_notebooks == 'yes' -%}
103+
"jupyterlab>=3.5",
104+
{% endif -%}
105+
{% if cookiecutter.code_formatter == 'black' -%}
106+
"black>=23.11",
107+
{% else -%}
108+
"ruff>=0.1.7",
109+
{% endif -%}
110+
"pytest>=7.0",
111+
"pytest-cov>=4.0",
112+
"pre-commit>=3.0",
113+
"isort>=5.12.0"
114+
]
115+
116+
[tool.isort]
117+
{% if cookiecutter.code_formatter == 'black' -%}
118+
profile = "black"
119+
{% else -%}
120+
line_length = 100
121+
multi_line_output = 3
122+
{% endif -%}
42123

43124
[tool.pytest.ini_options]
44-
minversion = "7.0"
45-
testpaths = ["tests"]
125+
minversion = "7.0"
126+
testpaths = ["tests"]
46127

47128
[build-system]
48-
requires = ["poetry-core"]
49-
build-backend = "poetry.core.masonry.api"
129+
requires = ["setuptools", "wheel"]
130+
build-backend = "setuptools.build_meta"
131+
{% endif -%}

{{cookiecutter.project_slug}}/uv.toml

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)