简体   繁体   中英

Python Library Files in Repo?

I'm relatively new to python and my question is concerning the repository of a python based application. Seems whenever I do pip install to install libraries I get a bunch of extra files in a “Venv” folder. If I were working on a central application should I include these files in the repo or should I add them to .gitignore ? I have tried finding if these are typically in a repo or not. I guess my real question is for the architectural design of a python repo (again I'm a python noob). What would you recommend?

The virtual environment (venv folder) should be excluded from your repo using.gitignore.

If you are using pipenv, the Pipfile and Pipfile.lock files should be included in your repo. This will ensure that the virtual environment can be recreated precisely.

Alternatively, you can use a requirements.txt file and include that in your repo.

Create requirements.txt:

$ pip freeze > requirements.txt

Install all packages specified in requirements.txt (after creating a new vitual environment):

$ pip install -r requirements.txt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM