def _pip_compile(*args): """ Performs pip-compile (from piptools) with a twist. We force editable requirements to use GIT repository (parameter obtain=True) so we have setuptools_scm working on them (axado.runner uses setuptools_scm). """ from contextlib import contextmanager @contextmanager def replaced_argv(args): import sys argv = sys.argv sys.argv = [''] + list(args) yield sys.argv = argv from pip.req.req_install import InstallRequirement try: InstallRequirement.update_editable_ except AttributeError: InstallRequirement.update_editable_ = InstallRequirement.update_editable InstallRequirement.update_editable = lambda s, _o: InstallRequirement.update_editable_( s, True) with replaced_argv(args): from piptools.scripts.compile import cli try: cli() except SystemExit as e: return e.code
def compile(self, dst_file, src_files, upgrade=False, rebuild=False, new_code=False): """ Performs pip-compile (from piptools) with a twist. We force editable requirements to use GIT repository (parameter obtain=True) so we have setuptools_scm working on them (we use setuptools_scm). Not sure this is working with piptools 2.X. """ from pip.req.req_install import InstallRequirement try: InstallRequirement.update_editable_ except AttributeError: InstallRequirement.update_editable_ = InstallRequirement.update_editable InstallRequirement.update_editable = lambda s, _o: InstallRequirement.update_editable_( s, True) from piptools.scripts.compile import cli return self.__click_context.invoke( cli, output_file=dst_file, src_files=src_files, upgrade=upgrade, rebuild=rebuild, emit_trusted_host=False, header=False, index=False, )