Customize Compiled Headers¶
When using pip-compile, users will notice that the generated
requirements.txt files features a header comment which describes the way the
file was generated.
For example:
#
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile --allow-unsafe --strip-extras requirements.in
#
Users have several options which allow them to customize the generation of this header.
Suppress the Header¶
If you don’t want the header at all, pass --no-header and pip-compile will
omit it.
$ pip-compile --no-header requirements.in
foo-example==1.0.0
# via -r requirements.in
Set the Compile Command¶
Suppose you are wrapping the pip-compile command in another script.
You would like to make sure that anyone reading the script knows to use the
wrapper, not a direct pip-compile command.
Updating the recorded command is a great way of communicating how the file is
generated and updated.
Control the recorded command by setting the
CUSTOM_COMPILE_COMMAND environment variable.
$ CUSTOM_COMPILE_COMMAND="./pipcompilewrapper" pip-compile requirements.in
#
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# ./pipcompilewrapper
#
foo-example==4.1.7
# via -r requirements.in