From e2b8d544d2e0b4717a5564ab8c6226be034b79ed Mon Sep 17 00:00:00 2001 From: craynic Date: Tue, 9 Oct 2018 17:39:55 +0800 Subject: [PATCH 1/6] fix virtualenv assertion bug introduced in 999761130e910bb211c75467d66be7db7547e7fe. --- pipenv/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipenv/core.py b/pipenv/core.py index b0cd9aa50e..d2ac5db4e7 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -106,7 +106,7 @@ def spinner(): def which(command, location=None, allow_global=False): if not allow_global and location is None: location = project.virtualenv_location or os.environ.get("VIRTUAL_ENV", "") - if not location and os.path.exists(location): + if not (location and os.path.exists(location)): raise RuntimeError("virtualenv not created nor specified") if not allow_global: if os.name == "nt": From e137d4334a5d225a06bf41b21e2eef746c19c3cb Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Tue, 9 Oct 2018 16:52:40 -0400 Subject: [PATCH 2/6] Add news entry - Fixes #2957 Signed-off-by: Dan Ryan --- news/2957.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/2957.bugfix diff --git a/news/2957.bugfix b/news/2957.bugfix new file mode 100644 index 0000000000..cf0311c6cc --- /dev/null +++ b/news/2957.bugfix @@ -0,0 +1 @@ +Fixed a bug which caused executable discovery to fail when running inside a virtualenv. From b06ba8b3b28d78753211608aef385e63b907d0bd Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Tue, 9 Oct 2018 17:34:40 -0400 Subject: [PATCH 3/6] Fix virtualenv installation Signed-off-by: Dan Ryan --- pipenv/core.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pipenv/core.py b/pipenv/core.py index d2ac5db4e7..cc4ba51f05 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -105,9 +105,12 @@ def spinner(): def which(command, location=None, allow_global=False): if not allow_global and location is None: - location = project.virtualenv_location or os.environ.get("VIRTUAL_ENV", "") - if not (location and os.path.exists(location)): - raise RuntimeError("virtualenv not created nor specified") + if project.virtualenv_exists: + location = project.virtualenv_location + else: + location = os.environ.get("VIRTUAL_ENV", None) + if not (location and os.path.exists(location)) and not allow_global: + raise RuntimeError("location not created nor specified") if not allow_global: if os.name == "nt": p = find_windows_executable(os.path.join(location, "Scripts"), command) @@ -2325,6 +2328,7 @@ def do_check( def do_graph(bare=False, json=False, json_tree=False, reverse=False): import pipdeptree + try: python_path = which("python") except AttributeError: From be0594ed5eac9ce068731c5e320703de5bef53da Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Tue, 9 Oct 2018 19:25:02 -0400 Subject: [PATCH 4/6] Fix graph import - Fixes #2952 Signed-off-by: Dan Ryan --- news/2952.bugfix | 1 + pipenv/vendor/pipdeptree.py | 2 ++ .../patches/vendor/pipdeptree-updated-pip18.patch | 14 ++++++++------ 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 news/2952.bugfix diff --git a/news/2952.bugfix b/news/2952.bugfix new file mode 100644 index 0000000000..df640991bc --- /dev/null +++ b/news/2952.bugfix @@ -0,0 +1 @@ +Fixed a bug with importing local vendored dependencies when running ``pipenv graph``. diff --git a/pipenv/vendor/pipdeptree.py b/pipenv/vendor/pipdeptree.py index 9cce0325e7..2082fc8a36 100644 --- a/pipenv/vendor/pipdeptree.py +++ b/pipenv/vendor/pipdeptree.py @@ -13,6 +13,8 @@ except ImportError: from ordereddict import OrderedDict +pardir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +sys.path.append(pardir) from pipenv.vendor.pip_shims import get_installed_distributions, FrozenRequirement import pkg_resources diff --git a/tasks/vendoring/patches/vendor/pipdeptree-updated-pip18.patch b/tasks/vendoring/patches/vendor/pipdeptree-updated-pip18.patch index e3ff9bbf29..01501e6244 100644 --- a/tasks/vendoring/patches/vendor/pipdeptree-updated-pip18.patch +++ b/tasks/vendoring/patches/vendor/pipdeptree-updated-pip18.patch @@ -1,17 +1,19 @@ diff --git a/pipenv/vendor/pipdeptree.py b/pipenv/vendor/pipdeptree.py -index 7820aa5..9cce032 100644 +index 7820aa5..2082fc8 100644 --- a/pipenv/vendor/pipdeptree.py +++ b/pipenv/vendor/pipdeptree.py -@@ -13,11 +13,7 @@ try: +@@ -13,11 +13,9 @@ try: except ImportError: from ordereddict import OrderedDict -try: -- from pipenv.patched.notpip._internal import get_installed_distributions -- from pipenv.patched.notpip._internal.operations.freeze import FrozenRequirement +- from pip._internal import get_installed_distributions +- from pip._internal.operations.freeze import FrozenRequirement -except ImportError: -- from pipenv.patched.notpip import get_installed_distributions, FrozenRequirement +- from pip import get_installed_distributions, FrozenRequirement ++pardir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) ++sys.path.append(pardir) +from pipenv.vendor.pip_shims import get_installed_distributions, FrozenRequirement import pkg_resources - # inline: + # inline: From b37d537e7ff00c7c96209159f457702edcdf747c Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Tue, 9 Oct 2018 20:44:52 -0400 Subject: [PATCH 5/6] Fix patch Signed-off-by: Dan Ryan --- .../vendoring/patches/vendor/pipdeptree-updated-pip18.patch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/vendoring/patches/vendor/pipdeptree-updated-pip18.patch b/tasks/vendoring/patches/vendor/pipdeptree-updated-pip18.patch index 01501e6244..778405e488 100644 --- a/tasks/vendoring/patches/vendor/pipdeptree-updated-pip18.patch +++ b/tasks/vendoring/patches/vendor/pipdeptree-updated-pip18.patch @@ -7,10 +7,10 @@ index 7820aa5..2082fc8 100644 from ordereddict import OrderedDict -try: -- from pip._internal import get_installed_distributions -- from pip._internal.operations.freeze import FrozenRequirement +- from pipenv.patched.notpip._internal import get_installed_distributions +- from pipenv.patched.notpip._internal.operations.freeze import FrozenRequirement -except ImportError: -- from pip import get_installed_distributions, FrozenRequirement +- from pipenv.patched.notpip import get_installed_distributions, FrozenRequirement +pardir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +sys.path.append(pardir) +from pipenv.vendor.pip_shims import get_installed_distributions, FrozenRequirement From f5f084bb5e6c2a49bcecb30f5113160b9c44a4de Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Tue, 9 Oct 2018 22:05:55 -0400 Subject: [PATCH 6/6] remove trailing whitespace from patch Signed-off-by: Dan Ryan --- tasks/vendoring/patches/vendor/pipdeptree-updated-pip18.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/vendoring/patches/vendor/pipdeptree-updated-pip18.patch b/tasks/vendoring/patches/vendor/pipdeptree-updated-pip18.patch index 778405e488..d479ebfa39 100644 --- a/tasks/vendoring/patches/vendor/pipdeptree-updated-pip18.patch +++ b/tasks/vendoring/patches/vendor/pipdeptree-updated-pip18.patch @@ -16,4 +16,4 @@ index 7820aa5..2082fc8 100644 +from pipenv.vendor.pip_shims import get_installed_distributions, FrozenRequirement import pkg_resources - # inline: + # inline: