From 02ff46686008cfc88a0991bef36edc14e2bc0886 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 11 Mar 2018 15:09:33 -0400 Subject: [PATCH 1/4] parallelism Signed-off-by: Kenneth Reitz --- pipenv/core.py | 6 +++++- pipenv/environments.py | 3 +++ pipenv/project.py | 14 ++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/pipenv/core.py b/pipenv/core.py index 4713a9f7..426df5f1 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -47,7 +47,7 @@ from .environments import ( PYENV_INSTALLED, PIPENV_YES, PIPENV_DONT_LOAD_ENV, PIPENV_DEFAULT_PYTHON_VERSION, PIPENV_MAX_SUBPROCESS, PIPENV_DONT_USE_PYENV, SESSION_IS_INTERACTIVE, PIPENV_USE_SYSTEM, - PIPENV_DOTENV_LOCATION, PIPENV_SHELL + PIPENV_DOTENV_LOCATION, PIPENV_SHELL, PIPENV_PYTHON ) # Backport required for earlier versions of Python. @@ -427,6 +427,10 @@ def find_a_system_python(python): def ensure_python(three=None, python=None): + # Support for the PIPENV_PYTHON environment variable. + if PIPENV_PYTHON and python is False and three is None: + python = PIPENV_PYTHON + def abort(): click.echo( 'You can specify specific versions of Python with:\n {0}'.format( diff --git a/pipenv/environments.py b/pipenv/environments.py index a8745a9a..ea032f4a 100644 --- a/pipenv/environments.py +++ b/pipenv/environments.py @@ -10,6 +10,9 @@ os.environ.pop('__PYVENV_LAUNCHER__', None) # Shell compatibility mode, for mis-configured shells. PIPENV_SHELL_FANCY = bool(os.environ.get('PIPENV_SHELL_FANCY')) +# Support for both Python 2 and Python 3 at the same time. +PIPENV_PYTHON = os.environ.get('PIPENV_PYTHON') + # Create the virtualenv in the project, instead of with pew. PIPENV_VENV_IN_PROJECT = bool(os.environ.get('PIPENV_VENV_IN_PROJECT')) or os.path.isdir('.venv') diff --git a/pipenv/project.py b/pipenv/project.py index 8ea1d472..6871e361 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -16,7 +16,7 @@ from pip import ConfigOptionParser from .utils import ( mkdir_p, convert_deps_from_pip, pep423_name, recase_file, find_requirements, is_file, is_vcs, python_version, cleanup_toml, - is_installable_file, is_valid_url, normalize_drive + is_installable_file, is_valid_url, normalize_drive, python_version ) from .environments import ( PIPENV_MAX_DEPTH, @@ -24,7 +24,8 @@ from .environments import ( PIPENV_VENV_IN_PROJECT, PIPENV_VIRTUALENV, PIPENV_NO_INHERIT, - PIPENV_TEST_INDEX + PIPENV_TEST_INDEX, + PIPENV_PYTHON ) if PIPENV_PIPFILE: @@ -37,7 +38,7 @@ if PIPENV_PIPFILE: class Project(object): """docstring for Project""" - def __init__(self, which=None, chdir=True): + def __init__(self, which=None, python_version=None, chdir=True): super(Project, self).__init__() self._name = None self._virtualenv_location = None @@ -47,6 +48,7 @@ class Project(object): self._requirements_location = None self._original_dir = os.path.abspath(os.curdir) self.which = which + self.python_version = python_version # Hack to skip this during pipenv run, or -r. if ('run' not in sys.argv) and chdir: @@ -161,7 +163,11 @@ class Project(object): # If the pipfile was located at '/home/user/MY_PROJECT/Pipfile', # the name of its virtualenv will be 'my-project-wyUfYPqE' - return sanitized + '-' + encoded_hash + + if PIPENV_PYTHON: + return sanitized + '-' + encoded_hash + '-' + PIPENV_PYTHON + else: + return sanitized + '-' + encoded_hash @property def virtualenv_location(self): From 7904e8ed35b6e9dd16f33a4b314e146624a9e648 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 11 Mar 2018 15:12:18 -0400 Subject: [PATCH 2/4] test both 2.7 and 3.6 locally, with pipenv! --- run-tests.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/run-tests.sh b/run-tests.sh index 88976069..aeb8799c 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -49,7 +49,9 @@ else pip install -e "$(pwd)" --upgrade-strategy=only-if-needed echo "Installing dependencies…" - pipenv install --dev + PIPENV_PYTHON=2.7 pipenv install --dev + PIPENV_PYTHON=3.6 pipenv install --dev + fi # Use tap output if in a CI environment, otherwise just run the tests. @@ -58,5 +60,6 @@ if [[ "$TAP_OUTPUT" ]]; then pipenv run time pytest -v -n auto tests -m "$TEST_SUITE" --tap-stream | tee report.tap else echo "$ pipenv run time pytest -v -n auto tests -m \"$TEST_SUITE\"" - pipenv run time pytest -v -n auto tests -m "$TEST_SUITE" + PIPENV_PYTHON=2.7 pipenv run time pytest -v -n auto tests -m "$TEST_SUITE" + PIPENV_PYTHON=3.6 pipenv run time pytest -v -n auto tests -m "$TEST_SUITE" fi \ No newline at end of file From 651afb480f6606f1821bc34ce9f0ec7863afb02b Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 11 Mar 2018 15:20:36 -0400 Subject: [PATCH 3/4] improve test script Signed-off-by: Kenneth Reitz --- run-tests.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/run-tests.sh b/run-tests.sh index aeb8799c..bce2b8a3 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -8,6 +8,9 @@ set -e PYPI_VENDOR_DIR="$(pwd)/tests/pypi/" export PYPI_VENDOR_DIR +prefix() { + sed "s/^/ $1: /" +} if [[ ! -z "$TEST_SUITE" ]]; then echo "Using TEST_SUITE=$TEST_SUITE" @@ -60,6 +63,9 @@ if [[ "$TAP_OUTPUT" ]]; then pipenv run time pytest -v -n auto tests -m "$TEST_SUITE" --tap-stream | tee report.tap else echo "$ pipenv run time pytest -v -n auto tests -m \"$TEST_SUITE\"" - PIPENV_PYTHON=2.7 pipenv run time pytest -v -n auto tests -m "$TEST_SUITE" - PIPENV_PYTHON=3.6 pipenv run time pytest -v -n auto tests -m "$TEST_SUITE" + PIPENV_PYTHON=2.7 pipenv run time pytest -v -n auto tests -m "$TEST_SUITE" | prefix 2.7 & + PIPENV_PYTHON=3.6 pipenv run time pytest -v -n auto tests -m "$TEST_SUITE" | prefix 3.6 + + # Cleanup junk. + rm -fr .venv fi \ No newline at end of file From a2866d631f0498c0c4d5f3aa895f44f073fb5d09 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 11 Mar 2018 15:22:26 -0400 Subject: [PATCH 4/4] run-tests Signed-off-by: Kenneth Reitz --- run-tests.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/run-tests.sh b/run-tests.sh index bce2b8a3..3987db88 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -63,9 +63,11 @@ if [[ "$TAP_OUTPUT" ]]; then pipenv run time pytest -v -n auto tests -m "$TEST_SUITE" --tap-stream | tee report.tap else echo "$ pipenv run time pytest -v -n auto tests -m \"$TEST_SUITE\"" - PIPENV_PYTHON=2.7 pipenv run time pytest -v -n auto tests -m "$TEST_SUITE" | prefix 2.7 & - PIPENV_PYTHON=3.6 pipenv run time pytest -v -n auto tests -m "$TEST_SUITE" | prefix 3.6 - + # PIPENV_PYTHON=2.7 pipenv run time pytest -v -n auto tests -m "$TEST_SUITE" | prefix 2.7 & + # PIPENV_PYTHON=3.6 pipenv run time pytest -v -n auto tests -m "$TEST_SUITE" | prefix 3.6 + # Better to run them sequentially. + PIPENV_PYTHON=2.7 pipenv run time pytest -v -n auto tests -m "$TEST_SUITE" + PIPENV_PYTHON=3.6 pipenv run time pytest -v -n auto tests -m "$TEST_SUITE" # Cleanup junk. rm -fr .venv fi \ No newline at end of file