Skip to content

Commit

Permalink
add ability to override compile command in generated req file
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek Schaller committed Apr 30, 2017
1 parent 5c19840 commit 4f2258e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,28 @@ If you use multiple Python versions, you can run ``pip-compile`` as ``py -X.Y
-m piptools compile ...`` on Windows and ``pythonX.Y -m piptools compile ...``
on other systems.

Configuration
-------------

You might be wrapping the pip-compile command in another script. To avoid confusing
consumers of your custom script you can override the update command generated at the top of
requirements files by setting the `CUSTOM_COMPILE_COMMAND` environment variable.

```console
$ CUSTOM_COMPILE_COMMAND="./pipcompilewrapper" pip-compile requirements.in
#
# This file is autogenerated by pip-compile
# To update, run:
#
# ./pipcompilewrapper
#
flask==0.10.1
itsdangerous==0.24 # via flask
jinja2==2.7.3 # via flask
markupsafe==0.23 # via jinja2
werkzeug==0.10.4 # via flask
```

Example usage for `pip-sync`
============================

Expand Down
28 changes: 16 additions & 12 deletions piptools/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,22 @@ def write_header(self):
yield comment('# This file is autogenerated by pip-compile')
yield comment('# To update, run:')
yield comment('#')
params = []
if not self.emit_index:
params += ['--no-index']
if not self.emit_trusted_host:
params += ['--no-emit-trusted-host']
if not self.annotate:
params += ['--no-annotate']
if self.generate_hashes:
params += ["--generate-hashes"]
params += ['--output-file', self.dst_file]
params += self.src_files
yield comment('# pip-compile {}'.format(' '.join(params)))
custom_cmd = os.environ.get('CUSTOM_COMPILE_COMMAND')
if custom_cmd:
yield comment('# {}'.format(custom_cmd))
else:
params = []
if not self.emit_index:
params += ['--no-index']
if not self.emit_trusted_host:
params += ['--no-emit-trusted-host']
if not self.annotate:
params += ['--no-annotate']
if self.generate_hashes:
params += ["--generate-hashes"]
params += ['--output-file', self.dst_file]
params += self.src_files
yield comment('# pip-compile {}'.format(' '.join(params)))
yield comment('#')

def write_index_options(self):
Expand Down

0 comments on commit 4f2258e

Please sign in to comment.