From f52c54e20a6d389af66b7d253c4ca5138e2b40e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Rafael?= Date: Sat, 7 Oct 2017 20:05:15 -0300 Subject: [PATCH 01/16] Ensure python is installed before deleting existing virtual env --- pipenv/cli.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pipenv/cli.py b/pipenv/cli.py index 6742cca4..71359332 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -565,11 +565,15 @@ def ensure_virtualenv(three=None, python=None, site_packages=False): # If --three, --two, or --python were passed... elif (python) or (three is not None) or (site_packages is not False): + + USING_DEFAULT_PYTHON = False + + # Ensure python is installed before deleting existing virtual env + ensure_python(three=three, python=python) + click.echo(crayons.red('Virtualenv already exists!'), err=True) click.echo(crayons.normal(u'Removing existing virtualenv…', bold=True), err=True) - USING_DEFAULT_PYTHON = False - # Remove the virtualenv. cleanup_virtualenv(bare=True) From 1504d1fffb3f75ed0177820aa37ac53ea4ef7b4e Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Thu, 12 Oct 2017 17:44:40 -0400 Subject: [PATCH 02/16] Add fix for windwos paths * Fixes #865 --- pipenv/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pipenv/utils.py b/pipenv/utils.py index 3fea5fab..d7a6d630 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -340,6 +340,9 @@ def shellquote(s): """Prepares a string for the shell (on Windows too!)""" if s is None: return None + # Additional escaping for windows paths + if os.name == 'nt': + s = "{}".format(s.replace("\\", "\\\\")) return '"' + s.replace("'", "'\\''") + '"' @@ -850,8 +853,7 @@ def get_windows_path(*args): """Sanitize a path for windows environments Accepts an arbitrary list of arguments and makes a clean windows path""" - clean_path = os.path.join(*args) - return os.path.normpath(clean_path) + return os.path.normpath(os.path.join(*args)) def find_windows_executable(bin_path, exe_name): From 0ea624466089fc88a013d1453bc5b6854e0c62bf Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Fri, 13 Oct 2017 03:25:08 -0400 Subject: [PATCH 03/16] Shells with PIPENV_IGNORE_VIRTUALENVS on win * Allow PIPENV_IGNORE_VIRTUALENVS to work with pipenv shell * Fixes #894 --- pipenv/cli.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/pipenv/cli.py b/pipenv/cli.py index 031f373e..99a2456d 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -25,7 +25,7 @@ import pipdeptree import requirements import semver import flake8.main.cli - +import pew from pipreqs import pipreqs from blindspin import spinner from urllib3.exceptions import InsecureRequestWarning @@ -2012,8 +2012,14 @@ def do_shell(three=None, python=False, fancy=False, shell_args=None): # Standard (properly configured shell) mode: else: + if PIPENV_VENV_IN_PROJECT: + # use .venv as the target virtualenv name + workon_name = '.venv' + else: + workon_name = project.virtualenv_name + cmd = 'pew' - args = ["workon", project.virtualenv_name] + args = ["workon", workon_name] # Grab current terminal dimensions to replace the hardcoded default # dimensions of pexpect @@ -2032,9 +2038,12 @@ def do_shell(three=None, python=False, fancy=False, shell_args=None): # Windows! except AttributeError: import subprocess - p = subprocess.Popen([cmd] + list(args), shell=True, universal_newlines=True) - p.communicate() - sys.exit(p.returncode) + # Tell pew to use the project directory as its workon_home + with pew.pew.temp_environ(): + os.environ['WORKON_HOME'] = project.project_directory + p = subprocess.Popen([cmd] + list(args), shell=True, universal_newlines=True) + p.communicate() + sys.exit(p.returncode) # Activate the virtualenv if in compatibility mode. if compat: From 51a82b4caede90753ef78bc4d33290a02b116eda Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Fri, 13 Oct 2017 18:33:14 -0400 Subject: [PATCH 04/16] Fix import failures using pew and psutil * Borrow the temp_environ context manager from pew * This avoids importing it which breaks on windows --- pipenv/cli.py | 6 ++---- pipenv/utils.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/pipenv/cli.py b/pipenv/cli.py index 99a2456d..154fd593 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -25,19 +25,17 @@ import pipdeptree import requirements import semver import flake8.main.cli -import pew from pipreqs import pipreqs from blindspin import spinner from urllib3.exceptions import InsecureRequestWarning from pip.req.req_file import parse_requirements from click_didyoumean import DYMCommandCollection - from .project import Project from .utils import ( convert_deps_from_pip, convert_deps_to_pip, is_required_version, proper_case, pep423_name, split_vcs, resolve_deps, shellquote, is_vcs, python_version, suggest_package, find_windows_executable, is_file, - prepare_pip_source_args + prepare_pip_source_args, temp_environ ) from .__version__ import __version__ from . import pep508checker, progress @@ -2039,7 +2037,7 @@ def do_shell(three=None, python=False, fancy=False, shell_args=None): except AttributeError: import subprocess # Tell pew to use the project directory as its workon_home - with pew.pew.temp_environ(): + with temp_environ(): os.environ['WORKON_HOME'] = project.project_directory p = subprocess.Popen([cmd] + list(args), shell=True, universal_newlines=True) p.communicate() diff --git a/pipenv/utils.py b/pipenv/utils.py index 3fea5fab..3008a728 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -22,6 +22,7 @@ try: except ImportError: from urlparse import urlparse +from contextlib import contextmanager from piptools.resolver import Resolver from piptools.repositories.pypi import PyPIRepository from piptools.scripts.compile import get_pip_command @@ -913,3 +914,16 @@ def find_requirements(max_depth=3): if os.path.isfile(r): return r raise RuntimeError('No requirements.txt found!') + + +# Borrowed from pew to avoid importing pew which imports psutil +# See https://github.com/berdario/pew/blob/master/pew/_utils.py#L82 +@contextmanager +def temp_environ(): + """Allow the ability to set os.environ temporarily""" + environ = dict(os.environ) + try: + yield + finally: + os.environ.clear() + os.environ.update(environ) From 3b93076aa5a8b3dcb44ffb6a034d3d6930ea4d9c Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Fri, 13 Oct 2017 18:47:51 -0400 Subject: [PATCH 05/16] Only tweak workon_home if PIPENV_VENV_IN_PROJECT * Otherwise we probably wont find the right virtualenv with pew --- pipenv/cli.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pipenv/cli.py b/pipenv/cli.py index 154fd593..817f467c 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -2038,7 +2038,8 @@ def do_shell(three=None, python=False, fancy=False, shell_args=None): import subprocess # Tell pew to use the project directory as its workon_home with temp_environ(): - os.environ['WORKON_HOME'] = project.project_directory + if PIPENV_VENV_IN_PROJECT: + os.environ['WORKON_HOME'] = project.project_directory p = subprocess.Popen([cmd] + list(args), shell=True, universal_newlines=True) p.communicate() sys.exit(p.returncode) From 19f7056d2c17a4f89e3a6532f535dc06924609a2 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Fri, 13 Oct 2017 20:34:01 -0400 Subject: [PATCH 06/16] Use context managers for test environment vars --- tests/test_pipenv.py | 51 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index c2355e5c..2ca867f5 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -6,6 +6,7 @@ import json import pytest from pipenv.cli import activate_virtualenv +from pipenv.utils import temp_environ from pipenv.vendor import toml from pipenv.vendor import delegator from pipenv.project import Project @@ -271,33 +272,32 @@ class TestPipenv: @pytest.mark.run @pytest.mark.install def test_multiprocess_bug_and_install(self): - os.environ['PIPENV_MAX_SUBPROCESS'] = '2' + with temp_environ(): + os.environ['PIPENV_MAX_SUBPROCESS'] = '2' - with PipenvInstance() as p: - with open(p.pipfile_path, 'w') as f: - contents = """ + with PipenvInstance() as p: + with open(p.pipfile_path, 'w') as f: + contents = """ [packages] requests = "*" records = "*" tpfd = "*" - """.strip() - f.write(contents) + """.strip() + f.write(contents) - c = p.pipenv('install') - assert c.return_code == 0 + c = p.pipenv('install') + assert c.return_code == 0 - assert 'requests' in p.lockfile['default'] - assert 'idna' in p.lockfile['default'] - assert 'urllib3' in p.lockfile['default'] - assert 'certifi' in p.lockfile['default'] - assert 'records' in p.lockfile['default'] - assert 'tpfd' in p.lockfile['default'] - assert 'parse' in p.lockfile['default'] + assert 'requests' in p.lockfile['default'] + assert 'idna' in p.lockfile['default'] + assert 'urllib3' in p.lockfile['default'] + assert 'certifi' in p.lockfile['default'] + assert 'records' in p.lockfile['default'] + assert 'tpfd' in p.lockfile['default'] + assert 'parse' in p.lockfile['default'] - c = p.pipenv('run python -c "import requests; import idna; import certifi; import records; import tpfd; import parse;"') - assert c.return_code == 0 - - del os.environ['PIPENV_MAX_SUBPROCESS'] + c = p.pipenv('run python -c "import requests; import idna; import certifi; import records; import tpfd; import parse;"') + assert c.return_code == 0 @pytest.mark.sequential @pytest.mark.install @@ -445,14 +445,13 @@ requests = {version = "*"} @pytest.mark.dotvenv def test_venv_in_project(self): - os.environ['PIPENV_VENV_IN_PROJECT'] = '1' - with PipenvInstance() as p: - c = p.pipenv('install requests') - assert c.return_code == 0 + with temp_environ(): + os.environ['PIPENV_VENV_IN_PROJECT'] = '1' + with PipenvInstance() as p: + c = p.pipenv('install requests') + assert c.return_code == 0 - assert p.path in p.pipenv('--venv').out - - del os.environ['PIPENV_VENV_IN_PROJECT'] + assert p.path in p.pipenv('--venv').out @pytest.mark.run @pytest.mark.dotenv From f7f16d1e3befdb52c86e23fedf85cbeb0b40c513 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Fri, 13 Oct 2017 23:50:49 -0400 Subject: [PATCH 07/16] Add tests for nested venvs on windows --- tests/test_pipenv.py | 45 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index 2ca867f5..943b648d 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -6,7 +6,7 @@ import json import pytest from pipenv.cli import activate_virtualenv -from pipenv.utils import temp_environ +from pipenv.utils import temp_environ, get_windows_path from pipenv.vendor import toml from pipenv.vendor import delegator from pipenv.project import Project @@ -453,6 +453,49 @@ requests = {version = "*"} assert p.path in p.pipenv('--venv').out + @pytest.mark.dotvenv + @pytest.mark.install + @pytest.mark.complex + @pytest.mark.shell + @pytest.mark.windows + @pytest.mark.pew + def test_shell_nested_venv_in_project(self): + import subprocess + with temp_environ(): + os.environ['PIPENV_VENV_IN_PROJECT'] = '1' + os.environ['PIPENV_IGNORE_VIRTUALENVS'] = '1' + with PipenvInstance() as p: + # Signal to pew to look in the project directory for the environment + os.environ['WORKON_HOME'] = p.path + c = p.pipenv('install requests') + assert c.return_code == 0 + assert 'requests' in p.pipfile['packages'] + assert 'requests' in p.lockfile['default'] + # Check that .venv now shows in pew's managed list + pew_list = delegator.run('pew ls') + assert '.venv' in pew_list.out + # Check for the venv directory + c = delegator.run('pew dir .venv') + # Compare pew's virtualenv path to what we expect + venv_path = get_windows_path(p.path, '.venv') + # os.path.normpath will normalize slashes + assert os.path.normpath(venv_path) == os.path.normpath(c.out.strip()) + # Have pew run 'pip freeze' in the virtualenv + # This is functionally the same as spawning a subshell + # If we can do this we can theoretically amke a subshell + args = ['pew', 'in', '.venv', 'pip', 'freeze'] + process = subprocess.Popen( + args, + shell=True, + universal_newlines=True, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + out, _ = process.communicate() + assert any(req.startswith('requests') for req in out.splitlines()) is True + + @pytest.mark.run @pytest.mark.dotenv def test_env(self): From 4fe1bf223cd137226849d090842c4f86e4f0da03 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Sat, 14 Oct 2017 03:06:59 -0400 Subject: [PATCH 08/16] Add enviroment context for compat shell --- pipenv/cli.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pipenv/cli.py b/pipenv/cli.py index 817f467c..f8b07cd6 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -2024,14 +2024,18 @@ def do_shell(three=None, python=False, fancy=False, shell_args=None): terminal_dimensions = get_terminal_size() try: - c = pexpect.spawn( - cmd, - args, - dimensions=( - terminal_dimensions.lines, - terminal_dimensions.columns + with temp_environ(): + if PIPENV_VENV_IN_PROJECT: + os.environ['WORKON_HOME'] = project.project_directory + + c = pexpect.spawn( + cmd, + args, + dimensions=( + terminal_dimensions.lines, + terminal_dimensions.columns + ) ) - ) # Windows! except AttributeError: From 26cd52bccc64951a8e0259182cb5734b80095d5e Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Sat, 14 Oct 2017 03:07:20 -0400 Subject: [PATCH 09/16] Fix tests for windows venv nested shells --- tests/test_pipenv.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index 943b648d..e56b89ac 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -464,9 +464,11 @@ requests = {version = "*"} with temp_environ(): os.environ['PIPENV_VENV_IN_PROJECT'] = '1' os.environ['PIPENV_IGNORE_VIRTUALENVS'] = '1' - with PipenvInstance() as p: + os.environ['PIPENV_SHELL_COMPAT'] = '1' + with PipenvInstance(chdir=True) as p: # Signal to pew to look in the project directory for the environment os.environ['WORKON_HOME'] = p.path + project = Project() c = p.pipenv('install requests') assert c.return_code == 0 assert 'requests' in p.pipfile['packages'] @@ -477,23 +479,25 @@ requests = {version = "*"} # Check for the venv directory c = delegator.run('pew dir .venv') # Compare pew's virtualenv path to what we expect - venv_path = get_windows_path(p.path, '.venv') + venv_path = get_windows_path(project.project_directory, '.venv') # os.path.normpath will normalize slashes - assert os.path.normpath(venv_path) == os.path.normpath(c.out.strip()) + assert venv_path == os.path.normpath(c.out.strip()) # Have pew run 'pip freeze' in the virtualenv # This is functionally the same as spawning a subshell # If we can do this we can theoretically amke a subshell - args = ['pew', 'in', '.venv', 'pip', 'freeze'] - process = subprocess.Popen( - args, - shell=True, - universal_newlines=True, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE - ) - out, _ = process.communicate() - assert any(req.startswith('requests') for req in out.splitlines()) is True + # This test doesn't work on *nix + if os.name == 'nt': + args = ['pew', 'in', '.venv', 'pip', 'freeze'] + process = subprocess.Popen( + args, + shell=True, + universal_newlines=True, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + out, _ = process.communicate() + assert any(req.startswith('requests') for req in out.splitlines()) is True @pytest.mark.run From f4497408397d6095cfd50c8447b4803e1f223b0d Mon Sep 17 00:00:00 2001 From: NighTurs Date: Sun, 15 Oct 2017 15:47:19 +0300 Subject: [PATCH 10/16] Add cacert.pem from requests to releases. Fixes #871 --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index 2543d7c3..b4651aa7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ include README.rst LICENSE NOTICES HISTORY.txt pipenv/patched/safety.zip +include pipenv/patched/pip/_vendor/requests/cacert.pem include pipenv/vendor/pipreqs/stdlib include pipenv/vendor/pipreqs/mapping include pipenv/pipenv.1 From aeafce54a60c5c5fa8df941df800449051c064bb Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Sun, 15 Oct 2017 19:45:54 -0400 Subject: [PATCH 11/16] Add tests for windows paths with spaces --- tests/test_utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_utils.py b/tests/test_utils.py index e68d9888..176e94ef 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +import os import pytest from mock import patch, Mock @@ -165,3 +166,10 @@ class TestUtils: run_ret.out = version_output mocked_delegator.return_value = run_ret assert pipenv.utils.python_version('some/path') == version + + @pytest.mark.windows + @pytest.mark.skipif(os.name != 'nt', reason='Windows test only') + def test_windows_shellquote(self): + test_path = 'C:\Program Files\Python36\python.exe' + expected_path = '"C:\\\\Program Files\\\\Python36\\\\python.exe"' + assert pipenv.utils.shellquote(test_path) == expected_path From 20ee4de8d387901bce4f35c43b6dadc24ef143f6 Mon Sep 17 00:00:00 2001 From: Marvin Steadfast Date: Mon, 16 Oct 2017 14:24:04 +0200 Subject: [PATCH 12/16] Uses ONBUILD in Dockerfile to install deps while building Copies `Pipfile` and `Pipefile.lock`, installs deps on building a docker image using the official pipenv image. --- Dockerfile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7ea90e59..c2a74c37 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,24 @@ -FROM python:3.6.2 +FROM python:3.6.3 # -- Install Pipenv: -RUN pip install pipenv --upgrade +RUN set -ex && pip install pipenv --upgrade # -- Install Application into container: -RUN mkdir /app +RUN set -ex && mkdir /app + WORKDIR /app +# -- Adding Pipfiles +ONBUILD COPY Pipfile Pipfile +ONBUILD COPY Pipfile.lock Pipfile.lock + +# -- Install dependencies: +ONBUILD RUN set -ex && pipenv install --deploy --system + # -------------------- # - Using This File: - # -------------------- # FROM kennethreitz/pipenv -# COPY Pipfile Pipfile -# COPY Pipfile.lock Pipfile.lock # COPY . /app - -# -- Install dependencies: -# RUN pipenv install --deploy --system - -ENTRYPOINT [] -CMD [ "/bin/bash" ] \ No newline at end of file From 06182dda8bf58cc4d11b192f0525425429615e84 Mon Sep 17 00:00:00 2001 From: Dario Bertini Date: Tue, 17 Oct 2017 00:52:44 +0100 Subject: [PATCH 13/16] Document Nix installation option --- docs/install.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/install.rst b/docs/install.rst index 22fff395..4e82c1b6 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -220,6 +220,16 @@ To upgrade pipenv at any time:: This will install both ``pipenv`` and ``pew`` (one of our dependencies) in an isolated virtualenv, so it doesn't interfere with the rest of your Python installation! +.. _more_proper_installation: + +☤ Referentially Transparent Installation of Pipenv +================================================== + +Nix provides atomic upgrades and rollbacks, it's reliable and reproducible thanks to keeping all dependencies isolated all the way down to libc. + +`Once installed `_ simply run:: + + $ nix-env --install --attr pipenv .. _pragmatic_installation: From ccebde4e26efcb3ac761625aa0b14a42028caa9a Mon Sep 17 00:00:00 2001 From: Kris Date: Tue, 17 Oct 2017 16:54:33 -0400 Subject: [PATCH 14/16] Add failing test --- tests/test_pipenv.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index c2355e5c..507770f1 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -227,6 +227,36 @@ class TestPipenv: c = p.pipenv('run python -m requests.help') assert c.return_code > 0 + @pytest.mark.files + @pytest.mark.run + @pytest.mark.uninstall + def test_uninstall_all_local_files(self): + file_name = 'tablib-0.12.1.tar.gz' + # Not sure where travis/appveyor run tests from + test_dir = os.path.dirname(os.path.abspath(__file__)) + source_path = os.path.abspath(os.path.join(test_dir, 'test_artifacts', file_name)) + + with PipenvInstance() as p: + shutil.copy(source_path, os.path.join(p.path, file_name)) + os.mkdir(os.path.join(p.path, "tablib")) + + c = p.pipenv('install {}'.format(file_name)) + key = [k for k in p.pipfile['packages'].keys()][0] + dep = p.pipfile['packages'][key] + + assert 'file' in dep or 'path' in dep + assert c.return_code == 0 + + key = [k for k in p.lockfile['default'].keys()][0] + dep = p.lockfile['default'][key] + + assert 'file' in dep or 'path' in dep + + c = p.pipenv('uninstall --all --verbose') + assert c.return_code == 0 + assert 'tablib' in c.out + assert 'tablib' not in p.pipfile['packages'] + @pytest.mark.extras @pytest.mark.install def test_extras_install(self): From 0a48fa090e2535041e5280511a6a2f1696de6797 Mon Sep 17 00:00:00 2001 From: Kris Date: Tue, 17 Oct 2017 16:57:43 -0400 Subject: [PATCH 15/16] Fix conversion of file deps --- pipenv/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pipenv/utils.py b/pipenv/utils.py index 3fea5fab..39e3bc65 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -530,8 +530,8 @@ def convert_deps_from_pip(dep): # File installs. - if (req.uri or (os.path.exists(req.path) if req.path else False) or - os.path.exists(req.name)) and not req.vcs: + if (req.uri or (os.path.isfile(req.path) if req.path else False) or + os.path.isfile(req.name)) and not req.vcs: # Assign a package name to the file, last 7 of it's sha256 hex digest. if not req.uri and not req.path: req.path = os.path.abspath(req.name) From 025972c7923d1063d19c723073523da903e67c0b Mon Sep 17 00:00:00 2001 From: Kris Date: Tue, 17 Oct 2017 22:12:17 -0400 Subject: [PATCH 16/16] Simplify test --- tests/test_pipenv.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index 507770f1..3a78c390 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -239,19 +239,7 @@ class TestPipenv: with PipenvInstance() as p: shutil.copy(source_path, os.path.join(p.path, file_name)) os.mkdir(os.path.join(p.path, "tablib")) - c = p.pipenv('install {}'.format(file_name)) - key = [k for k in p.pipfile['packages'].keys()][0] - dep = p.pipfile['packages'][key] - - assert 'file' in dep or 'path' in dep - assert c.return_code == 0 - - key = [k for k in p.lockfile['default'].keys()][0] - dep = p.lockfile['default'][key] - - assert 'file' in dep or 'path' in dep - c = p.pipenv('uninstall --all --verbose') assert c.return_code == 0 assert 'tablib' in c.out