Skip to content

Commit

Permalink
Extend docs for extracting requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Sep 9, 2023
1 parent 174d56a commit 75b3baf
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -272,21 +272,23 @@ allowing a script to specify a custom package index:
import my_private_package
...
Supplying parameters to Pip
---------------------------
Extracting Requirements
-----------------------

If you've been using ``pip-run``, you may have defined some requirements
in the ``__requires__`` variable or ``# Requirements:`` section of a
script, but now you wish to install those
to a more permanent environment. pip-run provides a routine to facilitate
After having used ``pip-run`` to run scripts, it may be desirable to extract the requirements from the ``__requires__`` variable or ``# Requirements:`` section of a
script to install those more permanently. pip-run provides a routine to facilitate
this case::

$ python -m pip_run.read-deps script.py
my_dependency
$ py -m pip_run.read-deps examples/pydragon
requests beautifulsoup4 cowsay

On Unix, it is possible to pipe this result directly to pip::

$ pip install $(py -m pip_run.read-deps examples/pydragon)

If you're on Unix, you may pipe this result directly to pip::
To generate a requirements.txt file, specify a newline separator::

$ pip install $(python -m pip_run.read-deps script.py)
$ py -m pip_run.read-deps --separator newline examples/pydragon > requirements.txt

And since `pipenv <https://docs.pipenv.org/>`_ uses the same syntax,
the same technique works for pipenv::
Expand Down

0 comments on commit 75b3baf

Please sign in to comment.