Coder Social home page Coder Social logo

danchr / pipenv-to-requirements Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gsemet/pipenv-to-requirements

0.0 1.0 0.0 48 KB

Generate requirements[-dev].txt from Pipfile using pipenv

License: MIT License

Makefile 19.27% Python 80.73%

pipenv-to-requirements's Introduction

pipenv-to-requirements

https://travis-ci.org/gsemet/pipenv-to-requirements.svg?branch=master Pypi package MIT licensed

Generate requirements[-dev].txt from Pipfile (using pipenv). Used in my modern Python module project cookiecutter. template.

Rational

Pipfile and its sibling Pipfile.lock are clearly superior tools defining clear dependencies or a package. Pipfile is to be maintained by the package's developer while Pipfile.lock represent a clear image of what is currently installed on the current system, guarantying full reproductibility of the setup. See more information about Pipfile format here. Most of the time, Pipfile.lock should be ignored (ie, not tracked in your git) for packages published on Pypi.

pipenv is a great tool to maintain Pipfile, but developers might be stuck with backward compatibility issues for tools and services that still use requirements.txt and does not know how to handle Pipfile or Pipfile.lock yet.

For examples:

  • ReadTheDocs
  • Pyup (experimental support is arriving )
  • Any library that uses PBR (*)
  • pip install (if you install a package with pip that does not have a requirements.txt, its dependencies won't be installed, even if you use Pipfile)

(*): for the moment, I recommend to generate at least requirements.txt (without version freeze) for the libraries using PBR that you publish on Pypi. Remember PBR automatically synchronize the content of requirements.txt found at the root of a package with setup.py of this package. This allows automatic installation of the very dependencies of your package. Without this file, your package will be installed by pip, but its dependencies will be ignored. Support in PBR may be added in the future (see this this patch ).

Usage

Just before building source/binary/wheel package of your python module, only of the following commands:

  • To generate requirements files (ie, dependencies are described eventually by range), typically for libraries:

    pipenv run pipenv_to_requirements
  • To generate frozen requirements (ie, all dependencies have their version frozen), typically for applications:

    pipenv run pipenv_to_requirements -f

It will generate requirements.txt and, if applicable, requirements-dev.txt, in the current directory.

Example using a Makefile:

dev:
    pipenv install --dev
    pipenv run pip install -e .

dists: requirements sdist bdist wheels

requirements:
    # For a library, use:
    pipenv run pipenv_to_requirements
    # For an application, use:
    # pipenv run pipenv_to_requirements -f

sdist: requirements
    pipenv run python setup.py sdist

bdist: requirements
    pipenv run python setup.py bdist

wheels: requirements
    pipenv run python setup.py bdist_wheel

Just use make requirements to refresh the requirements.txt.

ReadTheDocs

Simply commit these files in your tree so that readthedocs, and ensure they are synchronized each time you change your Pipfile. Do not forget to ask ReadTheDocs to use requirements-dev.txt when building the documentation.

Contributing

Create your development environment with

$ make dev

Execute unit tests:

$ make test

Code formatter:

$ make style

Code Style Checks:

$ make check

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.