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 dependencynpm 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)?
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With