Metadata-Version: 2.1
Name: requirementslib
Version: 1.4.2
Summary: A tool for converting between pip-style and pipfile requirements.
Home-page: https://github.com/sarugaku/requirementslib
Author: Dan Ryan
Author-email: dan@danryan.co
License: MIT
Keywords: pipfile,requirements.txt,pip,requirementslib,pipenv,lockfile,dependency resolver,resolver,dependencies
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Requires-Python: >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*
Description-Content-Type: text/x-rst
Requires-Dist: appdirs
Requires-Dist: attrs
Requires-Dist: cached-property
Requires-Dist: colorama
Requires-Dist: distlib (>=0.2.8)
Requires-Dist: first
Requires-Dist: orderedmultidict
Requires-Dist: packaging
Requires-Dist: pep517
Requires-Dist: pip-shims (>=0.3.2)
Requires-Dist: plette[validation]
Requires-Dist: requests
Requires-Dist: setuptools (>=40.8)
Requires-Dist: six
Requires-Dist: tomlkit (>=0.5.3)
Requires-Dist: vistir (>=0.3.1)
Requires-Dist: scandir ; python_version < "3.5"
Requires-Dist: typing ; python_version < "3.5"
Provides-Extra: dev
Requires-Dist: vulture ; extra == 'dev'
Requires-Dist: flake8 ; extra == 'dev'
Requires-Dist: rope ; extra == 'dev'
Requires-Dist: isort ; extra == 'dev'
Requires-Dist: invoke ; extra == 'dev'
Requires-Dist: twine ; extra == 'dev'
Requires-Dist: flake8-bugbear ; (python_version >= "3.5") and extra == 'dev'
Requires-Dist: black ; (python_version >= "3.6") and extra == 'dev'
Provides-Extra: tests
Requires-Dist: pytest ; extra == 'tests'
Requires-Dist: coverage ; extra == 'tests'
Requires-Dist: twine ; extra == 'tests'
Requires-Dist: readme-renderer[md] ; extra == 'tests'
Requires-Dist: pytest-xdist ; extra == 'tests'
Requires-Dist: pytest-cov ; extra == 'tests'
Requires-Dist: pytest-timeout ; extra == 'tests'
Requires-Dist: pytest-annotate ; extra == 'tests'
Provides-Extra: typing
Requires-Dist: mypy-extensions ; extra == 'typing'
Requires-Dist: pyannotate ; extra == 'typing'
Requires-Dist: mypy ; (python_version >= "3.4") and extra == 'typing'
Requires-Dist: mypytools ; (python_version >= "3.4") and extra == 'typing'
Requires-Dist: monkeytype ; (python_version >= "3.4") and extra == 'typing'
Requires-Dist: pytype ; (python_version >= "3.4") and extra == 'typing'
Requires-Dist: typed-ast ; (python_version >= "3.4") and extra == 'typing'

RequirementsLib: Requirement Management Library for Pip and Pipenv

.. image:: https://img.shields.io/pypi/v/requirementslib.svg
    :target: https://pypi.org/project/requirementslib

.. image:: https://img.shields.io/pypi/l/requirementslib.svg
    :target: https://pypi.org/project/requirementslib

.. image:: https://travis-ci.org/sarugaku/requirementslib.svg?branch=master
    :target: https://travis-ci.org/sarugaku/requirementslib

.. image:: https://ci.appveyor.com/api/projects/status/hntt25rbnr5yiwmf/branch/master?svg=true
    :target: https://ci.appveyor.com/project/sarugaku/requirementslib

.. image:: https://img.shields.io/pypi/pyversions/requirementslib.svg
    :target: https://pypi.org/project/requirementslib

.. image:: https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg
    :target: https://saythanks.io/to/techalchemy

.. image:: https://readthedocs.org/projects/requirementslib/badge/?version=master
    :target: http://requirementslib.readthedocs.io/en/master/?badge=master
    :alt: Documentation Status

🐉 Installation
==================

Install from `PyPI`_:

.. code:: console

    $ pipenv install requirementslib

Install from `Github`_:

.. code:: console

    $ pipenv install -e git+https://github.com/sarugaku/requirementslib.git#egg=requirementslib


.. _PyPI: https://www.pypi.org/project/requirementslib
.. _Github: https://github.com/sarugaku/requirementslib


.. _`Summary`:

🐉 Summary
============

RequirementsLib provides a simple layer for building and interacting with
requirements in both the `Pipfile <https://github.com/pypa/pipfile/>`_ format
and the `requirements.txt <https://github.com/pypa/pip/>`_ format.  This library
was originally built for converting between these formats in `Pipenv <https://github.com/pypa/pipenv>`_.

.. _`Usage`:

🐉 Usage
=========

Importing a lockfile into your *setup.py* file
-----------------------------------------------------

You can use RequirementsLib to import your lockfile into your setup file for including your
**install_requires** dependencies:

.. code-block:: pycon

    from requirementslib import Lockfile
    lockfile = Lockfile.create('/path/to/project/dir')
    install_requires = lockfile.as_requirements(dev=False)


Interacting with a *Pipfile* directly
-------------------------------------------

You can also interact directly with a Pipfile:

.. code-block:: pycon

    >>> from requirementslib import Pipfile
    >>> pf = Pipfile.load('/home/hawk/git/pypa-pipenv')
    >>> pf.sections
    [Section(name='packages', requirements=[]), Section(name='dev-packages', requirements=[Requirement(name='pipenv', vcs=None, req=FileRequirement(setup_path=None, path='.', editable=True, uri='file:///home/hawk/git/pypa-pipenv', link=<Link file:///home/hawk/git/pypa-pipenv>, name='pipenv', req=<Requirement: "-e file:///home/hawk/git/pypa-pipenv">), markers='', specifiers=None, index=None, editable=True, hashes=[], extras=None),...]


And you can even write it back out into Pipfile's native format:

.. code-block:: pycon

    >>> print(pf.dump(to_dict=False))
    [packages]

    [dev-packages]
    pipenv = {path = ".", editable = true}
    flake8 = ">=3.3.0,<4"
    pytest = "*"
    mock = "*"

    [scripts]
    tests = "bash ./run-tests.sh"

    [pipenv]
    allow_prereleases = true


Create a requirement object from *requirements.txt* format
------------------------------------------------------------------

.. code-block:: pycon

    >>> from requirementslib import Requirement
    >>> r = Requirement.from_line('-e git+https://github.com/pypa/pipenv.git@master#egg=pipenv')
    >>> print(r)
    Requirement(name='pipenv', vcs='git', req=VCSRequirement(editable=True, uri='git+https://github.com/pypa/pipenv.git', path=None, vcs='git', ref='master', subdirectory=None, name='pipenv', link=<Link git+https://github.com/pypa/pipenv.git@master#egg=pipenv>, req=<Requirement: "-e git+https://github.com/pypa/pipenv.git@master#egg=pipenv">), markers=None, specifiers=None, index=None, editable=True, hashes=[], extras=[])

    >>> r.as_pipfile()
    {'pipenv': {'editable': True, 'ref': 'master', 'git': 'https://github.com/pypa/pipenv.git'}}


Or move from *Pipfile* format to *requirements.txt*:

.. code-block:: pycon

    >>> r = Requirement.from_pipfile(name='pythonfinder', indexes=[], pipfile={'path': '../pythonfinder', 'editable': True})
    >>> r.as_line()
    '-e ../pythonfinder'


Resolving Editable Package Dependencies
---------------------------------------------

Requirementslib also can resolve the dependencies of editable packages by calling the ``run_requires`` method.
This method returns a detailed dictionary containing metadata parsed from the package built in
a transient folder (unless it is already on the system or the call is run in a virtualenv).

The output of ``run_requires`` is very detailed and in most cases will be sufficient:

.. code-block:: pycon

    >>> from pprint import pprint
    >>> from requirementslib.models.requirements import Requirement
    >>> r = Requirement.from_line("-e git+git@github.com:sarugaku/vistir.git#egg=vistir[spinner]")
    >>> setup_info_dict = r.run_requires()
    >>> from pprint import pprint
    >>> pprint(setup_info_dict)
    {'base_dir': '/tmp/requirementslib-t_ftl6no-src/src/vistir',
    'build_backend': 'setuptools.build_meta',
    'build_requires': ['setuptools>=36.2.2', 'wheel>=0.28.0'],
    'extra_kwargs': {'build_dir': '/tmp/requirementslib-t_ftl6no-src/src',
                    'download_dir': '/home/hawk/.cache/pipenv/pkgs',
                    'src_dir': '/tmp/requirementslib-t_ftl6no-src/src',
                    'wheel_download_dir': '/home/hawk/.cache/pipenv/wheels'},
    'extras': {'spinner': [Requirement.parse('cursor'),
                            Requirement.parse('yaspin')],
                'tests': [Requirement.parse('pytest'),
                        Requirement.parse('pytest-xdist'),
                        Requirement.parse('pytest-cov'),
                        Requirement.parse('pytest-timeout'),
                        Requirement.parse('hypothesis-fspaths'),
                        Requirement.parse('hypothesis')]},
    'ireq': <InstallRequirement object: vistir[spinner] from git+ssh://git@github.com/sarugaku/vistir.git#egg=vistir editable=True>,
    'name': 'vistir',
    'pyproject': PosixPath('/tmp/requirementslib-t_ftl6no-src/src/vistir/pyproject.toml'),
    'python_requires': '>=2.6,!=3.0,!=3.1,!=3.2,!=3.3',
    'requires': {'backports.functools_lru_cache;python_version<="3.4"': Requirement.parse('backports.functools_lru_cache; python_version <= "3.4"'),
                'backports.shutil_get_terminal_size;python_version<"3.3"': Requirement.parse('backports.shutil_get_terminal_size; python_version < "3.3"'),
                'backports.weakref;python_version<"3.3"': Requirement.parse('backports.weakref; python_version < "3.3"'),
                'colorama': Requirement.parse('colorama'),
                'pathlib2;python_version<"3.5"': Requirement.parse('pathlib2; python_version < "3.5"'),
                'requests': Requirement.parse('requests'),
                'six': Requirement.parse('six'),
                'spinner': [Requirement.parse('cursor'),
                            Requirement.parse('yaspin')]},
    'setup_cfg': PosixPath('/tmp/requirementslib-t_ftl6no-src/src/vistir/setup.cfg'),
    'setup_py': PosixPath('/tmp/requirementslib-t_ftl6no-src/src/vistir/setup.py')}


As a side-effect of calls to ``run_requires``, new metadata is made available on the
requirement itself via the property ``requirement.req.dependencies``:


.. code-block:: pycon

    >>> pprint(r.req.dependencies)
    ({'backports.functools_lru_cache;python_version<="3.4"': Requirement.parse('backports.functools_lru_cache; python_version <= "3.4"'),
    'backports.shutil_get_terminal_size;python_version<"3.3"': Requirement.parse('backports.shutil_get_terminal_size; python_version < "3.3"'),
    'backports.weakref;python_version<"3.3"': Requirement.parse('backports.weakref; python_version < "3.3"'),
    'colorama': Requirement.parse('colorama'),
    'pathlib2;python_version<"3.5"': Requirement.parse('pathlib2; python_version < "3.5"'),
    'requests': Requirement.parse('requests'),
    'six': Requirement.parse('six'),
    'spinner': [Requirement.parse('cursor'), Requirement.parse('yaspin')]},
    [],
    ['setuptools>=36.2.2', 'wheel>=0.28.0'])


🐉 Integrations
==================

* `Pip <https://github.com/pypa/pip>`_
* `Pipenv <https://github.com/pypa/pipenv>`_
* `Pipfile`_


