From b1d3aec5d2da9d011892131e7af425b2422d5d2f Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Fri, 2 Nov 2018 11:17:33 -0400 Subject: [PATCH] Don't write build artifacts to cwd - Fixes #3106 Signed-off-by: Dan Ryan --- news/3106.bugfix.rst | 1 + pipenv/utils.py | 6 +++++- pipenv/vendor/requirementslib/utils.py | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 news/3106.bugfix.rst diff --git a/news/3106.bugfix.rst b/news/3106.bugfix.rst new file mode 100644 index 00000000..70c0917f --- /dev/null +++ b/news/3106.bugfix.rst @@ -0,0 +1 @@ +Pipenv will avoid leaving build artifacts in the current working directory. diff --git a/pipenv/utils.py b/pipenv/utils.py index 84c72979..c2f2a9d8 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -295,7 +295,11 @@ def actually_resolve_deps( hashes = { ireq: pypi._hash_cache.get_hash(ireq.link) for ireq in constraints if getattr(ireq, "link", None) - and ireq.link.is_artifact and not is_pypi_url(ireq.link.url) + # We can only hash artifacts, but we don't want normal pypi artifcats since the + # normal resolver handles those + and ireq.link.is_artifact and not is_pypi_url(ireq.link.url) and not + # We also don't want to try to hash directories as this will fail (editable deps) + (ireq.link.scheme == "file" and os.path.isdir(ireq.link.path)) } try: results = resolver.resolve(max_rounds=environments.PIPENV_MAX_ROUNDS) diff --git a/pipenv/vendor/requirementslib/utils.py b/pipenv/vendor/requirementslib/utils.py index 75a05ce0..291c30ae 100644 --- a/pipenv/vendor/requirementslib/utils.py +++ b/pipenv/vendor/requirementslib/utils.py @@ -186,7 +186,14 @@ def ensure_setup_py(base_dir): if not base_dir: base_dir = create_tracked_tempdir(prefix="requirementslib-setup") base_dir = Path(base_dir) + if base_dir.exists() and base_dir.name == "setup.py": + base_dir = base_dir.parent + elif not (base_dir.exists() and base_dir.is_dir()): + base_dir = base_dir.parent + if not (base_dir.exists() and base_dir.is_dir()): + base_dir = base_dir.parent setup_py = base_dir.joinpath("setup.py") + is_new = False if setup_py.exists() else True if not setup_py.exists(): setup_py.write_text(u"")