elgertam/cookiecutter-pipenv

path to source code

piccolbo opened this issue · 3 comments

  • Date you used Cookiecutter PyPackage: like, yesterday
  • Cookiecutter version used, if any:
  • Python version, if known: 3.6
  • Operating System: os x high sierra

Description

should the source code be under pkg-slug or src/pkg-slug?

What I Did

I run into this article
https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure
that purports that putting the code only one level below the top level is a tragedy waiting to happen because it puts the current code on the python path for testing. It recommends adding an additional src level in between. I don't have a strong opinion but I thought I'd run it by you.

Thanks for bringing this up. I find the code structure to be a matter of personal preference. I chose the structure in this template for two reasons: first, it's what I'm used to, and second, it's what I've seen in the Python community more often. I think the Java-style src/<pkg-slug> convention makes certain tasks a bit easier (in particular, testing with py.test), but other tasks become harder (e.g. src is typically not a Python package, so executing python -m src.<pkg-slug> would not work). Both ways are valid, and in this case, I chose the one that I tend to see more often.

I occasionally have strong opinions about certain things. For example, I think the convention of putting all virtualenvs inside the same directory is just wrong, so I use the less-common .venv/-inside-the-project-root convention.

I'm going to close this issue, but I appreciate the comments. If you're curious, I'd encourage you to fork my template and use the src/<pkg-slug> convention.

@piccolbo I've had a change of heart and am re-opening the issue. I have come to the conclusion that code in a src/ directory is preferable to the alternative.

If you'd be interested in submitting a PR, I'd review it and try to merge it soon. If not, I'd understand as well.

I switched to using poetry in the meantime, so I am not the right person to submit this PR.