Skip to content

Commit 03b03a6

Browse files
committed
Move variable to cookiecutter.json to fix issue
After renaming the project root directory from `{{ cookiecutter.project_slug }}` to `{{ cookiecutter.pypi_package_name }}`, running the e2e test failed with the following error: > jinja2.exceptions.UndefinedError: 'collections.OrderedDict object' has no attribute 'pypi_package_name' Move the `pypi_package_name` declaration from the pre-gen hook into the `cookiecutter.json` file proper to fix the issue.
1 parent 710f2d2 commit 03b03a6

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

cookiecutter.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"project_title": "",
3-
"python_package_name": "{{ cookiecutter.project_title.lower().replace(' ', '_').replace('-', '_') }}",
3+
"pypi_package_name": "{{ cookiecutter.project_title.lower().replace(' ', '-').replace('_', '-') }}",
4+
"python_package_name":
5+
"{{ cookiecutter.pypi_package_name.replace('-', '_') }}",
46
"project_description": "",
57
"first_module_name": "api",
68
"project_version": "0.1.0",
@@ -11,7 +13,7 @@
1113
"copyright_holder_full_name": "{{ cookiecutter.author_full_name }}",
1214
"github_username": "",
1315
"include_executable": "y",
14-
"executable_name": "{{ cookiecutter.python_package_name.replace('_', '-') }}",
16+
"executable_name": "{{ cookiecutter.pypi_package_name }}",
1517
"install_dependencies_now": "y",
1618
"_copy_without_render": [
1719
".redport/patches/*.patch"

hooks/pre_gen_project.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
%}
99
{{
1010
cookiecutter.update({
11-
"pypi_package_name":
12-
cookiecutter.python_package_name.replace('_', '-'),
1311
"spdx_license":
1412
spdx_license_dict[cookiecutter.project_license],
1513
"use_alternative_union_syntax":

0 commit comments

Comments
 (0)