Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Dependency management practices

Now I'm taking part in node.js project and i like "node way" of dependecy management.

I'll provide some examples for those who haven't worked with npm

  • npm install package_name --save - installs package_name as production dependency
  • npm install package name --save-dev - install package_name as development dependecy.

All deps are stored in package.json file, which is indexed by version control system. When i clone repo, i just type npm install in terminal and it installs everything. As far as i know, pip freeze is able to do it, but:

On production server I can type npm install --production and all my build tools, testing frameworks, etc. are not installed. Just production deps.

So, the question is:

How do you split production and development dependecies with pip(or other tool)?

like image 352
Alexey Sidash Avatar asked Feb 17 '15 16:02

Alexey Sidash


People also ask

What is the best way to manage dependencies in Python?

Using venv and pipenv are two methods of managing dependencies in Python. They are simple to implement and, for most users, adequate solutions for handling multiple projects with different dependencies. However, they are not the only solutions. Other services can complement their use.

How would you manage dependencies in a Python project program?

One such solution for managing dependencies is the ActiveState Platform, which can automatically resolve all the dependencies for your project, and compile them (packages, dependencies and sub-dependencies) into a runtime for the operating system you use.

Is pip a dependency management tool?

Application dependency managementUse pip in a secure manner to install a Python application and its dependencies during deployment. Use pip-tools, Pipenv, or poetry to generate the fully-specified application-specific dependencies, when developing Python applications.

How do I set dependencies in Python?

There are two ways to specify dependencies for Cloud Functions written in Python: using the pip package manager's requirements. txt file or packaging local dependencies alongside your function. Dependency specification using the Pipfile/Pipfile.


1 Answers

I would create two virtualenvs (venv for Python 3) with a separate requirements.txt file for each, like requirements-production.txt and requirements-develop.txt, but that looks a bit strange to me.

Personally, I usually use git's branches to separate production/development code. Most of the development goes in the develop branch, there's a single requirements.txt (which can change over time, for sure). When everything's alright and/or the development cycle has ended, I just merge it with the master branch. Haven't had a need to test different versions of dependencies simultaneously.

like image 193
Igor Hatarist Avatar answered Oct 12 '22 16:10

Igor Hatarist