Skip to content

Commit 67fca3f

Browse files
committed
Add --install-options and --global-options to the requirements file parser
This allows lines such as the following to exist in requirements files: INITools==0.2 --install-options="--prefix=/opt" virtualenv>=1 --global-options="--no-user-cfg" In addition, the requirements file parser was overhauled with simplicity and clarity in mind.
1 parent 5a32a4d commit 67fca3f

File tree

5 files changed

+432
-113
lines changed

5 files changed

+432
-113
lines changed

Diff for: docs/reference/pip_install.rst

+23-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Each line of the requirements file indicates something to be installed,
2525
and like arguments to :ref:`pip install`, the following forms are supported::
2626

2727
<requirement specifier>
28+
<requirement specifier> [--install-options="..."] [--global-options="..."]
2829
<archive url/path>
2930
[-e] <local project path>
3031
[-e] <vcs project url>
@@ -41,6 +42,9 @@ A line that begins with ``#`` is treated as a comment and ignored. Whitespace
4142
followed by a ``#`` causes the ``#`` and the remainder of the line to be
4243
treated as a comment.
4344

45+
A line ending in an unescaped ``\`` is treated as a line continuation
46+
and the newline following it is effectively ignored.
47+
4448
Additionally, the following Package Index Options are supported:
4549

4650
* :ref:`-i, --index-url <--index-url>`
@@ -89,6 +93,25 @@ Some Examples:
8993
Don't use single or double quotes in a ``requirements.txt`` file.
9094

9195

96+
.. _`Per-requirement Overrides`:
97+
98+
Per-requirement Overrides
99+
+++++++++++++++++++++++++
100+
101+
It is possible to set ``--install-options`` and ``--global-options``
102+
for each requirement in the requirements file:
103+
104+
::
105+
106+
FooProject >= 1.2 --install-options="--prefix='/usr/local'" \
107+
--global-options="--no-user-cfg"
108+
109+
The above translates roughly into running FooProject's ``setup.py``
110+
script as:
111+
112+
::
113+
114+
python setup.py --no-user-cfg install --prefix='/usr/local'
92115

93116

94117
.. _`Pre Release Versions`:
@@ -506,5 +529,3 @@ Examples
506529
::
507530

508531
$ pip install --pre SomePackage
509-
510-

Diff for: pip/exceptions.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@ class DistributionNotFound(InstallationError):
1818
"""Raised when a distribution cannot be found to satisfy a requirement"""
1919

2020

21+
class RequirementsFileParseError(PipError):
22+
"""Raised when an invalid state is encountered during requirement file
23+
parsing."""
24+
25+
2126
class BestVersionAlreadyInstalled(PipError):
2227
"""Raised when the most up-to-date version of a package is already
23-
installed. """
28+
installed."""
2429

2530

2631
class BadCommand(PipError):

0 commit comments

Comments
 (0)