-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issues due to pip 10 release #14
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
# along with dh-virtualenv. If not, see | ||
# <http://www.gnu.org/licenses/>. | ||
|
||
# Note for catkin_virtualenv users: local changes from upstream are marked with (pbovbel) | ||
|
||
import os | ||
import re | ||
import shutil | ||
|
@@ -36,6 +38,7 @@ def __init__(self, | |
preinstall=[], | ||
pip_tool='pip', | ||
upgrade_pip=False, | ||
pip_version=None, | ||
index_url=None, | ||
setuptools=False, | ||
python=None, | ||
|
@@ -47,14 +50,15 @@ def __init__(self, | |
use_system_packages=False, | ||
skip_install=False, | ||
install_suffix=None, | ||
log_file=tempfile.NamedTemporaryFile().name, | ||
requirements_filename='requirements.txt'): | ||
|
||
self.package = package | ||
|
||
install_root = os.environ.get(ROOT_ENV_KEY, DEFAULT_INSTALL_DIR) | ||
self.install_suffix = install_suffix | ||
|
||
# (pbovbel): this is the only modification to dh_virtualenv source | ||
# (pbovbel): override the debian_root directory to allow a custom install path | ||
# self.debian_root = os.path.join( | ||
# 'debian', package, install_root.lstrip('/')) | ||
self.debian_root = '.' | ||
|
@@ -71,8 +75,8 @@ def __init__(self, | |
|
||
self.preinstall = preinstall | ||
self.upgrade_pip = upgrade_pip | ||
self.pip_version = pip_version | ||
self.extra_virtualenv_arg = extra_virtualenv_arg | ||
self.log_file = tempfile.NamedTemporaryFile() | ||
self.verbose = verbose | ||
self.setuptools = setuptools | ||
self.python = python | ||
|
@@ -98,12 +102,21 @@ def __init__(self, | |
self.pip_args.extend([ | ||
'--extra-index-url={0}'.format(url) for url in extra_urls | ||
]) | ||
self.pip_args.append('--log={0}'.format(os.path.abspath(self.log_file.name))) | ||
|
||
# (pbovbel): make logging optional, since --log overrides -q flag for pip | ||
if log_file: | ||
self.log_file = log_file | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would assign There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
self.pip_args.append('--log={0}'.format(os.path.abspath(self.log_file))) | ||
|
||
# Keep a copy with well-suported options only (for upgrading pip itself) | ||
self.pip_upgrade_args = self.pip_args[:] | ||
|
||
# Add in any user supplied pip args | ||
self.pip_args.extend(extra_pip_arg) | ||
|
||
# (pbovbel) Update pip_upgrade_args to keep flags like -q | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing : here and below. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reworded |
||
self.pip_upgrade_args = self.pip_args | ||
|
||
@classmethod | ||
def from_options(cls, package, options): | ||
verbose = options.verbose or os.environ.get('DH_VERBOSE') == '1' | ||
|
@@ -170,9 +183,11 @@ def install_dependencies(self): | |
# along lines of setuptools), but that does not get installed | ||
# by default virtualenv. | ||
if self.upgrade_pip: | ||
# (pbovbel) allow pinning the pip version | ||
pip_package = 'pip==' + self.pip_version if self.pip_version else 'pip' | ||
# First, bootstrap pip with a reduced option set (well-supported options) | ||
print(self.pip_preinstall_prefix + self.pip_upgrade_args + ['-U', 'pip']) | ||
subprocess.check_call(self.pip_preinstall_prefix + self.pip_upgrade_args + ['-U', 'pip']) | ||
print(self.pip_preinstall_prefix + self.pip_upgrade_args + ['-U', pip_package]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Easier to keep these strings in sync if you assigned it to a variable and used it for both, but I recognize that means diverging from upstream. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's the concern |
||
subprocess.check_call(self.pip_preinstall_prefix + self.pip_upgrade_args + ['-U', pip_package]) | ||
if self.preinstall: | ||
subprocess.check_call(self.pip_preinstall(*self.preinstall)) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this have a
# (pbovbel): allow pinning the pip version
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done