Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src layout option #130

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kamathramu87
Copy link

@kamathramu87 kamathramu87 commented Oct 4, 2024

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • Documentation in docs is updated

Description of changes
Some teams prefer using src layout for the project. Benefit of using src layout are described here

@kamathramu87 kamathramu87 changed the title Src layout option src layout option Oct 4, 2024
@fpgmaas
Copy link
Owner

fpgmaas commented Oct 8, 2024

This currently breaks functionality if the directory already exists:

Traceback (most recent call last):
  File "/var/folders/dk/4hmjslc11rggp3bqq8tnjv4w0000gn/T/tmp6j1_71zf.py", line 49, in <module>
    move_to_src_layout()
  File "/var/folders/dk/4hmjslc11rggp3bqq8tnjv4w0000gn/T/tmp6j1_71zf.py", line 24, in move_to_src_layout
    src_dir.rename(tgt_dir / src_dir.name)
  File "/Users/florian/.pyenv/versions/3.11.2/lib/python3.11/pathlib.py", line 1175, in rename
    os.rename(self, target)
OSError: [Errno 66] Directory not empty: '/Users/florian/git/cookiecutter-poetry/example-project/example_project' -> '/Users/florian/git/cookiecutter-poetry/example-project/src/example_project'
ERROR: Stopping generation because post_gen_project hook script didn't exit successfully
Hook script failed (exit status: 1)
make: *** [bake-with-inputs] Error 1

To make life easier, maybe we can simply create both src/{{cookiecutter.project_slug}} and {{cookiecutter.project_slug}}, and just delete the one we do not need in the post hook.

Also, currently the y/n defaults to y, so many users who used this template earlier will now get some unexpected results. Maybe instead of a y/n prompt, let's prompt for layout with options flat or src, and default to flat.

@fpgmaas
Copy link
Owner

fpgmaas commented Oct 8, 2024

Additionally, the behavior/config for mypy is probably different. We might need to add a unit test that checks if mypy still runs successfully in both cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants