Giter VIP home page Giter VIP logo

pip-tools-demo's Introduction

Saner Dependency Management in Python

This is the companion repo to my YouTube video talking about a better way to manage dependencies in Python.

Previous Art

  1. RIP Pipenv: Tried Too Hard. Do what you need with pip-tools.
  2. Python Application Dependency Management in 2018

Prepare Your Python Environment

python3 -m venv ./venv
source ./venv/bin/activate

Your newly created virtualenv should now be activated if your prompt changed to the following:

(venv) ubuntu@dev...

or, should you happen to be using dotfiles.relaxdiego.com, it should have changed to something similar to the following

... via ๐Ÿ v3.7.7 (venv)

Install The Dependencies

Install all development and runtime dependencies.

WARNING: Make sure you are using a virtualenv before running this command. Since it uses pip-sync to install dependencies, it will remove any package that is not listed in either dev-requirements.in or setup.py. If you followed the steps in Prepare Your Development Environment above, then you're good.

make dev-install

Adding A Development Dependency

  1. Add it to dev-requirements.in and then run make dev-install:
echo "foo" >> dev-requirements.in
make dev-install

This will create dev-requirements.txt and then install all dev-dependencies

  1. Commit dev-requirements.in and dev-requirements.txt. Both files should now be updated and the foo package installed in your local machine. Make sure to commit both files to the repo to let your teammates know of the new dependency.
git add dev-requirements.*
git commit -m "Add foo to dev-requirements.txt"
git push origin

Adding A Runtime Dependency

  1. Add it to runtime_requirements list in setup.py and then run:
make requirements.txt

This will create requirements.txt and then install all dependencies

  1. Commit setup.py and requirements.txt. Both files should now be updated and the foo package installed in your local machine. Make sure to commit both files to the repo to let your teammates know of the new dependency.
git add requirements.txt
git add setup.py
git commit -m "Add bar to runtime requirements"
git push origin

Need A Fresh Start?

Sigh, what I'd give to get a fresh start in life too. Huh? Oh you mean a fresh start in the project? Well we got you covered there too! Just run:

make clean

Or if you really want to clean all the stuff

make clean all=t

Had Enough?

Make sure to deactivate the virtual environment and remove it if you want

deactivate
rm -rf venv

pip-tools-demo's People

Contributors

relaxdiego avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.