From bad0846246b8522e4cd3d563822b45a41c6e1d8f Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Thu, 28 May 2020 21:50:26 +0800 Subject: [PATCH 1/5] Don't check against root directory --- pipenv/core.py | 8 -------- pipenv/project.py | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/pipenv/core.py b/pipenv/core.py index 1938e7f5..10508044 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -568,14 +568,6 @@ def ensure_project( system = True if not project.pipfile_exists and deploy: raise exceptions.PipfileNotFound - # Fail if working under / - if not project.name: - click.echo( - "{0}: Pipenv is not intended to work under the root directory, " - "please choose another path.".format(crayons.red("ERROR")), - err=True - ) - sys.exit(1) # Skip virtualenv creation when --system was used. if not system: ensure_virtualenv( diff --git a/pipenv/project.py b/pipenv/project.py index 40b6b263..54d51a65 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -685,8 +685,8 @@ class Project(object): from .vendor.pip_shims.shims import ( ConfigOptionParser, make_option_group, index_group ) - - config_parser = ConfigOptionParser(name=self.name) + # Inherit the pip's index configuration of install command. + config_parser = ConfigOptionParser(name="install") config_parser.add_option_group(make_option_group(index_group, config_parser)) install = config_parser.option_groups[0] indexes = ( From f6567bb328a5da780706338a9ca517e5a8658611 Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Thu, 28 May 2020 21:54:33 +0800 Subject: [PATCH 2/5] add news entry --- news/4273.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/4273.bugfix.rst diff --git a/news/4273.bugfix.rst b/news/4273.bugfix.rst new file mode 100644 index 00000000..a6140178 --- /dev/null +++ b/news/4273.bugfix.rst @@ -0,0 +1 @@ +Fix a bug that Pipenv rejects to work under the root directory. From 3f4abadac255d527f94c8fa60590e1472acd814b Mon Sep 17 00:00:00 2001 From: frostming Date: Fri, 29 May 2020 11:02:33 +0800 Subject: [PATCH 3/5] Use InstallCommand to fetch options --- pipenv/project.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/pipenv/project.py b/pipenv/project.py index 54d51a65..3d88c897 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -682,18 +682,10 @@ class Project(object): def create_pipfile(self, python=None): """Creates the Pipfile, filled with juicy defaults.""" - from .vendor.pip_shims.shims import ( - ConfigOptionParser, make_option_group, index_group - ) + from .vendor.pip_shims.shims import InstallCommand # Inherit the pip's index configuration of install command. - config_parser = ConfigOptionParser(name="install") - config_parser.add_option_group(make_option_group(index_group, config_parser)) - install = config_parser.option_groups[0] - indexes = ( - " ".join(install.get_option("--extra-index-url").default) - .lstrip("\n") - .split("\n") - ) + command = InstallCommand() + indexes = command.cmd_opts.get_option("--extra-index-url").default sources = [DEFAULT_SOURCE] for i, index in enumerate(indexes): if not index: From ac0e152a80103e3fe88d79af68193df93e11c82d Mon Sep 17 00:00:00 2001 From: frostming Date: Fri, 29 May 2020 13:01:53 +0800 Subject: [PATCH 4/5] Ignore errors removing user cache dir --- pipenv/core.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pipenv/core.py b/pipenv/core.py index 10508044..ed968383 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -126,9 +126,6 @@ def do_clear(): try: vistir.path.rmtree(PIPENV_CACHE_DIR, onerror=vistir.path.handle_remove_readonly) - vistir.path.rmtree( - locations.USER_CACHE_DIR, onerror=vistir.path.handle_remove_readonly - ) except OSError as e: # Ignore FileNotFoundError. This is needed for Python 2.7. import errno @@ -136,6 +133,8 @@ def do_clear(): if e.errno == errno.ENOENT: pass raise + # Other processes may be writing into this directory simultaneously. + vistir.path.rmtree(locations.USER_CACHE_DIR, ignore_errors=True) def load_dot_env(): From dffcac123352249a7b5e40158a94663e9f1c1342 Mon Sep 17 00:00:00 2001 From: frostming Date: Fri, 29 May 2020 14:18:13 +0800 Subject: [PATCH 5/5] Only ignore errors for CI builds --- pipenv/core.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pipenv/core.py b/pipenv/core.py index ed968383..a90afa60 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -126,6 +126,12 @@ def do_clear(): try: vistir.path.rmtree(PIPENV_CACHE_DIR, onerror=vistir.path.handle_remove_readonly) + # Other processes may be writing into this directory simultaneously. + vistir.path.rmtree( + locations.USER_CACHE_DIR, + ignore_errors=environments.PIPENV_IS_CI, + onerror=vistir.path.handle_remove_readonly + ) except OSError as e: # Ignore FileNotFoundError. This is needed for Python 2.7. import errno @@ -133,8 +139,6 @@ def do_clear(): if e.errno == errno.ENOENT: pass raise - # Other processes may be writing into this directory simultaneously. - vistir.path.rmtree(locations.USER_CACHE_DIR, ignore_errors=True) def load_dot_env():