Requirements-Builder

https://img.shields.io/travis/inveniosoftware/requirements-builder.svg https://img.shields.io/coveralls/inveniosoftware/requirements-builder.svg https://img.shields.io/github/tag/inveniosoftware/requirements-builder.svg https://img.shields.io/pypi/dm/requirements-builder.svg https://img.shields.io/github/license/inveniosoftware/requirements-builder.svg

About

Build requirements from setup.py to test your package against minimum, latest and development versions of your package dependencies. Particularly useful when combined with your CI systems build matrix.

Installation

Requirements-Builder is on PyPI so all you need is:

$ pip install requirements-builder

Or, if you have virtualenvwrapper installed:

$ mkvirtualenv requirements-builder
$ pip install requirements-builder

Testing

Running the test suite is as simple as:

$ ./run-tests.sh

Usage

Build requirements files from setup.py requirements.

$ requirements-builder --help
Usage: requirements-builder [OPTIONS] SETUP

  Calculate requirements for different purposes.

Options:
  -l, --level [min|pypi|dev]  Specifies desired requirements level."min"
                              requests the minimal requirement that is
                              specified, "pypi" requests the maximum version
                              that satisfies the constrains and is available
                              in PyPi. "dev" includes experimental developer
                              versions for VCSs.
  -e, --extras TEXT           Comma separated list of extras.
  -r, --req PATH              Requirements file.
  --help                      Show this message and exit.

TravisCI

Following is an example of how to integrate Requirements-Builder with TravisCI:

env:
  - REQUIREMENTS=lowest
  - REQUIREMENTS=release
  - REQUIREMENTS=devel

python:
  - "2.7"
  - "3.3"
  - "3.4"
  - "3.5"

before_install:
  - "travis_retry pip install --upgrade pip"
  - "travis_retry pip install requirements-builder"
  - "requirements-builder --level=min setup.py
     > .travis-lowest-requirements.txt"
  - "requirements-builder --level=pypi setup.py
     > .travis-release-requirements.txt"
  - "requirements-builder --level=dev --req requirements-devel.txt setup.py
     > .travis-devel-requirements.txt"

install:
  - "travis_retry pip install -r .travis-$REQUIREMENTS-requirements.txt"
  - "pip install -e ."

Tox

How to integrate Requirements-Builder with tox:

[tox]
skipdist = True

envlist =
    {py27}-{min,pypi,dev}
    {py34}-{min,pypi,dev}
    {py35}-{min,pypi,dev}
    {py36}-{min,pypi,dev}

[testenv]
setenv =
    PYTHONPATH = {toxinidir}:{toxinidir}

deps =
    Requirements-Builder

commands =
    min: requirements-builder --level=min -o .tox/min.txt setup.py
    min: pip install -r .tox/min.txt
    pypi: requirements-builder --level=min -o .tox/pypi.txt setup.py
    pypi: pip install -r .tox/pypi.txt
    dev: requirements-builder -l dev -r devel.txt -o .tox/dev.txt setup.py
    dev: pip install -r .tox/requirements-dev.txt
    pip install -e .
    {envpython} setup.py test # or: py.test, nose, coverage run, etc.

Tox-travis

When you are using tox, the TravisCI setup becomes much simpler.

language: python

python:
  - "2.7"
  - "3.4"
  - "3.5"
  - "3.6"

install:
  - pip install tox tox-travis

script:
  - tox

API Reference

Generate requirements from setup.py and requirements-devel.txt.

requirements_builder.requirements_builder.iter_requirements(level, extras, pip_file, setup_fp)[source]

Iterate over requirements.

requirements_builder.requirements_builder.minver_error(pkg_name)[source]

Report error about missing minimum version constraint and exit.

requirements_builder.requirements_builder.parse_pip_file(path)[source]

Parse pip requirements file.

requirements_builder.requirements_builder.parse_set(string)[source]

Parse set from comma separated string.

Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

Types of Contributions

Report Bugs

Report bugs at https://github.com/inveniosoftware/requirements-builder/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.
  • Any details about your local setup that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.

Fix Bugs

Look through the GitHub issues for bugs. Anything tagged with “bug” is open to whoever wants to implement it.

Implement Features

Look through the GitHub issues for features. Anything tagged with “feature” is open to whoever wants to implement it.

Write Documentation

Requirements-Builder could always use more documentation, whether as part of the official Requirements-Builder docs, in docstrings, or even on the web in blog posts, articles, and such.

Submit Feedback

The best way to send feedback is to file an issue at https://github.com/inveniosoftware/requirements-builder/issues.

If you are proposing a feature:

  • Explain in detail how it would work.
  • Keep the scope as narrow as possible, to make it easier to implement.
  • Remember that this is a volunteer-driven project, and that contributions are welcome :)

Get Started!

Ready to contribute? Here’s how to set up requirements-builder for local development.

  1. Fork the requirements-builder repo on GitHub.

  2. Clone your fork locally:

    $ git clone git@github.com:your_name_here/requirements-builder.git
    
  3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:

    $ mkvirtualenv requirements-builder
    $ cd requirements-builder/
    $ python setup.py develop
    
  4. Create a branch for local development:

    $ git checkout -b name-of-your-bugfix-or-feature
    

    Now you can make your changes locally.

  5. When you’re done making changes, check that your changes pass tests, including testing other Python versions with tox:

    $ ./run-tests.sh
    $ tox
    

    The tests will provide you with test coverage and also check PEP8 (code style), PEP257 (documentation), flake8 as well as build the Sphinx documentation and run doctests.

  6. Commit your changes and push your branch to GitHub:

    $ git add .
    $ git commit -s -m "Your detailed description of your changes."
    $ git push origin name-of-your-bugfix-or-feature
    
  7. Submit a pull request through the GitHub website.

Pull Request Guidelines

Before you submit a pull request, check that it meets these guidelines:

  1. The pull request should include tests and must not decrease test coverage.
  2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
  3. The pull request should work for Python 2.6, 2.7, 3.3, 3.4, 3.5 and for PyPy. Check https://travis-ci.org/inveniosoftware/requirements-builder/pull_requests and make sure that the tests pass for all supported Python versions.

Changes

Version 0.2.5 (released 2017-04-11)

Bug fixes

  • Fixes support of recursive requirements files.

Version 0.2.4 (released 2017-03-10)

Bug fixes

  • Fixes issue with upper version requirements being stripped from the output.

Version 0.2.3 (released 2017-03-09)

Bug fixes

  • Fixes the issue with conditions on extra_require not being taken into account.

Version 0.2.2 (released 2017-02-01)

Bug fixes

  • Fixes issue with properly building requirements for packages with version markers.

Improvements

  • Adds YAPF auto-formatting configuration.

Version 0.2.1 (released 2017-01-23)

Bug fixes

  • Accepts non--e packages from devel file.
  • Sphinx 1.5+ drops support for Python 2.6 and 3.3.
  • Adds Python 3.6 support.
  • Makes –extras option accepting comma separated values as described in help. (#14)

Version 0.2.0 (released 2016-09-13)

New features

Bug fixes

  • Fixes problem when the setup.py command try to import the package its about to install in order to get the information like the version. E.g. Django does that.
  • Fixes problem when the setup.py command plays with __file__ to read, exec, or whatever.

Version 0.1.0 (released 2015-10-05)

  • Initial public release

License

Requirements-Builder is free software; you can redistribute it and/or modify it under the terms of the Revised BSD License; see LICENSE file for more details.

Copyright (C) 2015, CERN All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Authors