1

I would like to create a virtual environment for my team. My team, works in different places and everyone has their own environment, it causes a lot of problems, everyone has a different version of the libraries (Python, RobotFramework).

I thought about:

  1. creating one common environment, I used virtualenv.
  2. Installing the prepared libraries (python and robotframework) with one command pip install ...,
  3. Prepared libraries will be in the git repository so that everyone can modify them, change the library version.

I have the first and third parts done, but I have a problem with the second. How to create such a package of libraries to be able to install it with one pip install command.

Should I create an environment locally, install all the libraries in it, and send them to git? Or should I package the project via setuptool (to tar.gz)?

Unfortunately, I cannot find the answer to this question, it seems to me that none of the above solutions is optimal.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Morf
  • 11
  • 1
  • 2
    Create a file listing the relevant dependencies `pip freeze > requirements.txt` then install from it `pip install -r requirements.txt` – jonrsharpe Oct 08 '20 at 08:21
  • This is a solution, but what if I want to create my own libraries and want to submit them for review by other users in the git repository? I will only send the file name without code. – Morf Oct 08 '20 at 08:29
  • Well, what if? Your library should have its own requirements file, or if you mean how do people depend on that library if it's not in PyPI, see e.g. https://stackoverflow.com/q/20101834/3001761. – jonrsharpe Oct 08 '20 at 08:31
  • I know my library should have its own requirements file, I am thinking about a specific situation: I would like all libraries were pulled from one place (git project), without communicating with external resources. – Morf Oct 08 '20 at 10:32
  • 1
    Are you familiar with docker? – Bryan Oakley Oct 09 '20 at 16:21
  • Yes, I am familiar with docker. If you have any idea how to do that in docker please let me know :) – Morf Oct 12 '20 at 08:35

2 Answers2

3

The easiest way of doing it would be creating a text file of all the libraries you are using in pip with the command.

pip freeze > requirements.txt

This will create a file listing all the packages with their versions that are being used. To install that ask every team member to place that requirement file in their projects and use

pip install -r requirements.txt
  • I would like all libraries were pulled from one place (git project), without communicating with external resources. I don't think that I can do that with requirements file. – Morf Oct 08 '20 at 13:46
2

With pip, you could download your dependencies. These will be .tar.gz, .whl or .zip files. Note that this could be complicated if your team uses multiple OS.

Here is an example which will download the dependencies into the directory named "dependencies", you can push this to git along with the requirements file.

pip freeze > req.txt
pip download -r req.txt -d dependencies

When someone clones your repository, they can install the dependencies offline with the following command.

pip install --no-index --find-links=dependencies -r req.txt
Bence Kaulics
  • 7,066
  • 7
  • 33
  • 63