Skip to content
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

Merged
merged 3 commits into from
May 1, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion catkin_virtualenv/cmake/build_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ def delete_bytecode(directory):
package=os.path.basename(root_dir),
requirements_filename=args.requirements,
upgrade_pip=True,
verbose=False,
pip_version="9.0.3",
use_system_packages=True,
python=find_executable('python3') if args.python3 else find_executable('python2'),
extra_pip_arg=['-qq'],
log_file=None,
# TODO(pbovbel) Builtin venv (python3-venv) is not available on trusty. This flag can be re-enabled when
# trusty support is dropped.
# builtin_venv=args.python3,
Expand Down
25 changes: 20 additions & 5 deletions catkin_virtualenv/src/dh_virtualenv/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -36,6 +38,7 @@ def __init__(self,
preinstall=[],
pip_tool='pip',
upgrade_pip=False,
pip_version=None,
index_url=None,
setuptools=False,
python=None,
Expand All @@ -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 = '.'
Expand All @@ -71,8 +75,8 @@ def __init__(self,

self.preinstall = preinstall
self.upgrade_pip = upgrade_pip
self.pip_version = pip_version

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

self.extra_virtualenv_arg = extra_virtualenv_arg
self.log_file = tempfile.NamedTemporaryFile()
self.verbose = verbose
self.setuptools = setuptools
self.python = python
Expand All @@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assign self.log_file=None when log_file is false-y, to avoid having the exposed attributes change based on its __init__ arguments.

Copy link
Member Author

Choose a reason for hiding this comment

The 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing : here and below.

Copy link
Member Author

Choose a reason for hiding this comment

The 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'
Expand Down Expand Up @@ -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])

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The 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))

Expand Down