in src/buildstream_plugins/sources/pip.py [0:0]
def track(self, previous_sources_dir): # pylint: disable=arguments-differ
# XXX pip does not offer any public API other than the CLI tool so it
# is not feasible to correctly parse the requirements file or to check
# which package versions pip is going to install.
# See https://pip.pypa.io/en/stable/user_guide/#using-pip-from-your-program
# for details.
# As a result, we have to wastefully install the packages during track.
with self.tempdir() as tmpdir:
install_args = self.host_pip + [
"download",
"--no-binary",
":all:",
"--index-url",
self.index_url,
"--dest",
tmpdir,
]
for requirement_file in self.requirements_files:
fpath = os.path.join(previous_sources_dir, requirement_file)
install_args += ["-r", fpath]
install_args += self.packages
self.call(install_args, fail="Failed to install python packages")
reqs = self._parse_sdist_names(tmpdir)
return "\n".join(["{}=={}".format(pkg, ver) for pkg, ver in reqs])