0

Recently I start a project based on Flask/Python. Right now I have set the environment - but I never create a project step by step in python, I have only experienced little scripts and small apps when I learn the programming language.

I have install and set all the dependencies in the same folder as you can see here:

enter image description here

In 'env' - I have create the virtual environment.

In 'TheSocial' - is and it will be the application itself.

My questions are:

1) If this 'env' will be moved or it wasn't created inside 'project_py', my application from 'TheSocial' can still run inside the virutalenv, or not ?

2) Are there any standards that you need to respect when you created any project structure ?

I have also seen an already answered StackOverFlow question , but I want to find out answers for question 1)

This questions are addressed in scope to understand how real projects are structured and design from scratch.

1 Answers1

1

1) Creating virtualenv changes your sytem's $PATH:

 $ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/Users/wgonczaronek/bin:/usr/local/sbin
 $ source venv/bin/activate
 $ echo $PATH
/Users/wgonczaronek/Projects/django & flask security/CSP/csp-flask/venv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/Users/wgonczaronek/bin:/usr/local/sbin

Inside activate there are following lines responsible for this:

VIRTUAL_ENV="/Users/wgonczaronek/Projects/django & flask security/CSP/csp-flask/venv"
export VIRTUAL_ENV

_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"

This means that when you move your env this will no longer be valid.

2) Just be consistent. In my project I like to "encapsulate" git repository in a directory of the same name where I keep my virtual env and other things (I have a special file FFF.txt which stands for Frequently Forgotten Features where I save all project related info for personal use :D). This allows me to clean after project in one command when I want to get rid of it and I am not bothered with naming conventions of my environment - I do not have to edit .gitignore. Some people like to use virtual env wrapper or pyenv which keep all virtual env outside project though. Just experiment and find out what suits you best.

gonczor
  • 3,994
  • 1
  • 21
  • 46