[Tutor] project directory structure
Ben Finney
ben+python at benfinney.id.au
Fri Aug 26 00:27:47 EDT 2016
Alex Kleider <akleider at sonic.net> writes:
> I'm still struggling with what is the best way to set up a project
> directory.
One thing to learn is that there's no one right way that is universally
applicable.
In particular, you are asking about *social* conventions here. These are
prone to change and negotiation and exceptions.
> Assuming the latter scenario, where should one run
> virtualenv -p python3 venv?
> ... at the top level or within the second level?
I recommend keeping the virtualenv entirely *outside* the code base.
Make a directory elsewhere to hold your virtualenvs, like a directory to
hold your caches.
Removing and re-populating the virtualenv should be independent from
removing and re-populating the working tree. Hence they should be
entirely separate directories.
> The main reason I want to get this right is because all my .py files
> begin with a shebang line of the form
> #!../venv/bin/python3
That's exactly the wrong thing to do. Your shebang line should *not*
assume a custom location of the Python interpreter.
It's the responsibility of the operating system or virtualenv to provide
the Python interpreter command in a standard place.
Instead, use:
#! /usr/bin/env python3
or:
#! /usr/bin/python3
and leave it to the operating system and the virtualenv to provide the
Python interpreter correctly.
--
\ “You've got to think about big things while you're doing small |
`\ things, so that all the small things go in the right |
_o__) direction.” —Alvin Toffler |
Ben Finney
More information about the Tutor
mailing list