Git Product home page Git Product logo

reqwire's Introduction

reqwire

Codacy Badge https://travis-ci.org/darvid/reqwire.svg?branch=master Join the chat at https://gitter.im/python-reqwire/Lobby

reqwire wires up your pip requirements with pip-tools.

https://asciinema.org/a/97035.png

Install

From PyPI:

$ pip install -U reqwire

From source:

$ pip install -e git+https://github.com/darvid/reqwire.git#egg=reqwire

Features

  • Manage multiple requirement source files, or tags
  • Add requirements from the command line (ร  la npm --save)
  • Compile tagged source files with pip-compile (from pip-tools)

Rationale

Until PEP 518 and Pipfile become reality, maintaining one or more requirements.txt files for Python projects will continue to be subject to personal preference and differing opinions on best practices [1]. Typical workflows involve maintaining multiple requirements.txt files, and many projects have some form of tooling, be it Makefile targets or external tools, such as Vincent Driessen's excellent pip-tools.

reqwire is a glorified wrapper around pip-tools, and imposes a slightly opinionated workflow:

  • Python requirements are split into source files and built files, with the built files being the output from pip-compile, containing pinned versions of the entire dependency graph. (Use reqwire init to quickly scaffold the necessary directory structure.)
  • Source files (with the .in extension) represent a project's immediate dependencies, and are always pinned to specific versions or version ranges.
  • Source filenames are synonymous with tags, which can be passed to reqwire add and reqwire build to maintain requirements for entirely separate environments.

Disclaimer

reqwire makes no claims about being designed specifically for humans, bonobos, cats, or any other land mammal. This project is not farm raised, free range, organic, low sugar, MSG free, gluten free, halal, kosher, vegan, or particularly of any nutritional value whatsoever. It just wraps pip-tools and helps you manage your freakin Python requirements. โ˜ฎ ๐ŸŒˆ

Links

Roadmap

  • Unit tests
  • Provide a command to update requirements (user-specified version)
  • Provide a command to freshen requirements
  • Provide a command to combine tags to a single output file (easily possible with pip-compile)
  • Provide a utility for generating setup and runtime requirements in setup.py scripts using setuptools.
  • Abandon in favor of Pipfile ๐Ÿ‘Œ
[1]

reqwire's People

Contributors

codacy-badger avatar darvid avatar dependabot[bot] avatar gitter-badger avatar ticosax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

reqwire's Issues

Pip versions > 10 are not supported

I get the stacktrace below if I use any pip > 10

$ reqwire build -a
Traceback (most recent call last):
  File "/home/kevin/.local/bin/reqwire", line 7, in <module>
    from reqwire.cli import main
  File "/home/kevin/.local/lib/python3.7/site-packages/reqwire/cli.py", line 16, in <module>
    import reqwire.helpers.requirements
  File "/home/kevin/.local/lib/python3.7/site-packages/reqwire/helpers/requirements.py", line 15, in <module>
    import pip.basecommand
ModuleNotFoundError: No module named 'pip.basecommand'

Current workaround is to downgrade back to pip < 10, e.g.:

pip install -U "pip<10"

Reqwire version 0.2.1

PRESERVE_TOPLEVEL broke adding requirements

Commit 0b86ba7 apparently introduced a bug with the add command, where if no other flags are provided, the provided specifier replaces all of the requirements in the targeted source file.

I have a very fuzzy recollection of why that configuration flag was introduced, and only exposed via the environment, and not documented. It certainly is not working as intended, so for now I'm just removing it altogether.

There is also a bug in requirements.resolve_specifier, in which it does not return a HashableInstallRequirement sometimes, resulting in the possibility of duplicate requirements being added.

Vanishing requirements

I've stumbled upon an issue that causes reqwire to drop previously added dependencies to a requirement .in. Steps to reproduce:

bash-3.2$ mkdir test
bash-3.2$ cd test
bash-3.2$ reqwire init
created /Users/fmontag/test/requirements/src
created /Users/fmontag/test/requirements/lck
created /Users/fmontag/test/requirements/src/docs.in
created /Users/fmontag/test/requirements/src/main.in
created /Users/fmontag/test/requirements/src/qa.in
created /Users/fmontag/test/requirements/src/test.in
bash-3.2$ reqwire add sqlalchemy
Collecting sqlalchemy
Installing collected packages: sqlalchemy
Successfully installed sqlalchemy-1.1.5
saving requirement(s) to main
bash-3.2$ cat requirements/src/main.in
# -*- mode: requirementstxt -*-
# vim: set ft=requirements
# Generated by reqwire on Sun Feb 26 20:12:35 2017
--index-url https://pypi.python.org/simple
SQLAlchemy==1.1.5

Ok, at this point let's add another dependency to main.in:

bash-3.2$ reqwire add sqlalchemy-utils
Collecting sqlalchemy-utils
Requirement already satisfied: six in /Users/fmontag/venv/lib/python3.6/site-packages (from sqlalchemy-utils)
Requirement already satisfied: SQLAlchemy>=1.0 in /Users/fmontag/venv/lib/python3.6/site-packages (from sqlalchemy-utils)
Installing collected packages: sqlalchemy-utils
Successfully installed sqlalchemy-utils-0.32.12
saving requirement(s) to main
bash-3.2$ cat requirements/src/main.in
# -*- mode: requirementstxt -*-
# vim: set ft=requirements
# Generated by reqwire on Sun Feb 26 20:13:03 2017
--index-url https://pypi.python.org/simple
SQLAlchemy-Utils==0.32.12

The first one just vanishes, adding a second dependency drops the first. Maybe it is just because sqlalchemy-utils pulls in sqlalchemy as a dependency but both of them are top level dependencies for my project so I was expecting to have both of them pinned in main.in.

How to add editable dependencies ?

Hi,
I'm interested to add editable dependencies like this:

-e git+https://github.com/darvid/reqwire.git@5b455cdca4e919041dfdf448c329eb206329b5e3#egg=reqwire

Is there is a way to achieve this ?

Use a different build directory name

Using build as the build directory name is less than ideal because most standard .gitignore files ignore it.

Open to suggestions. Some possibilities:

  • built
  • resolved
  • full
  • _build (and use _src for src?)
  • all

Preserve nested requirement file lines

Because reqwire uses pip.req.parse_requirements, requirements from nested requirement files are flattened out when source files get updated with reqwire add. These lines need to be preserved in source files, and the nested requirements need to be excluded from the resulting resolved requirements. Unsure what degree of validation should be done to avoid conflicts between added requirements (and their dependencies) and requirements from nested files.

Prompt to recurse building of tags when building tags

If qa.in depends on main.in and you update or add a package in main.in, it would be handy to be prompted to also build any downstream tags that have main.in as nested includes. And an option to automatically do it, as well.

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.