User documentation¶
PyBuilder Pip Tools is a PyBuilder plugin which generates
*requirements*.txt files from your project plugin/build/install
dependencies and keeps your virtual env in sync with them. This is achieved
with pip-compile and pip-sync from pip-tools. No distinction is made
between plugin and build dependencies; plugin dependencies are treated as build
dependencies.
The plugin adds the pip_sync task and 2 project properties:
$pybuilder_pip_tools_urls and $pybuilder_pip_tools_build_urls.
The properties allow specifying dependency urls for regular and build/plugin
dependencies respectively:
project.build_depends_on('pybuilder', '>0.9.0')
project.get_property('pybuilder_pip_tools_build_urls').extend([
'git+https://github.com/pybuilder/pybuilder.git#egg=pybuilder-0'
])
Urls must have a fragment containing egg={pkg_name}-{version}. version is
unused and can be set to 0, pkg_name must match one of the project’s
(build) dependencies.
The pip_sync task first generates these requirements files (with pip-compile):
requirements.txt- Requirements file generated by
pip-compileusingproject.dependencies(including their version constraints; as specified byproject.depends_on) asrequirements.infile. requirements_development.txt- Analog to
requirements.txt, but overrideproject.dependencieswith their url in$pybuilder_pip_tools_urls, if any. build_requirements.txt- Analog to
requirements.txt, usingproject.build_dependencies(project.build_depends_on) +project.plugin_dependenciesinstead. build_requirements_development.txt- Analog to
requirements.txt, usingproject.build_dependencies,project.plugin_dependenciesand$pybuilder_pip_tools_urlsinstead.
For example, for the snippet above this would generate:
build_requirements.txt:pybuilder==0.9.1 # some version >0.9.0 # pybuilder dependencies, also pinned
build_requirements_development.txt:-e git+https://github.com/pybuilder/pybuilder.git#egg=pybuilder-0>0.9.0 # pybuilder dependencies, pinned Note: ``pip-compile`` only supports ``-e`` urls, so ``-e`` is prepended.
requirements.txt: empty, noproject.dependenciesspecified.requirements_development.txt: empty, noproject.dependenciesspecified.
Finally, pip_sync runs:
pip-sync requirements_development.txt build_requirements_development.txt
The non-development requirements files may come in handy for syncing on a test/build server (E.g. travis, GitLab) or for deployment (E.g. making a self-contained executable).