From 2a9bb815ffee3e9576c9e431921f733860d7cf14 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Mon, 18 Jun 2018 20:14:32 -0400 Subject: [PATCH 1/9] Updated changelog Signed-off-by: Dan Ryan --- CHANGELOG.rst | 8 ++++++-- tasks/release.py | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3bfe4e0d..5ad4fcd8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,5 +1,5 @@ -2018.05.18 (2018-06-17) -======================= +2018.6.0.dev0 (2018-06-18) +========================== Features & Improvements @@ -78,6 +78,10 @@ Bug Fixes - VCS dependencies are now manually obtained only if they do not match the requested ref. `#2304 `_ +- Added error handling functionality to properly cope with single-digit ``Requires-Python`` metatdata with no specifiers. `#2377 `_ + +- ``pipenv update`` will now always run the resolver and lock before ensuring your dependencies are in sync with your lockfile. `#2379 `_ + Vendored Libraries ------------------ diff --git a/tasks/release.py b/tasks/release.py index 78d0ace6..260e46ac 100644 --- a/tasks/release.py +++ b/tasks/release.py @@ -53,10 +53,14 @@ def upload_dists(ctx): @invoke.task -def generate_changelog(ctx, commit=False): +def generate_changelog(ctx, commit=False, draft=False): log('Generating changelog...') - ctx.run('towncrier') + if draft: + commit = False + log('Writing draft to file...') + ctx.run('towncrier --draft > CHANGELOG.rst') if commit: + ctx.run('towncrier') log('Committing...') ctx.run('git add .') ctx.run('git commit -m "Update changelog."') From 252be3257823fd13e722c8aa8c944be898fc37bb Mon Sep 17 00:00:00 2001 From: Max Krivich Date: Wed, 20 Jun 2018 13:17:13 +0300 Subject: [PATCH 2/9] Fix cli option usage error Fix IndexError exception when `more_packages` is empty and add the more informal message for argument usage. To reproduce this issue `pipenv install -e` --- pipenv/core.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pipenv/core.py b/pipenv/core.py index be67c8f5..faa54807 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -1889,6 +1889,8 @@ def do_install( # Capture -e argument and assign it to following package_name. more_packages = list(more_packages) if package_name == '-e': + if not more_packages: + raise click.BadArgumentUsage('Please provide path to setup.py') package_name = ' '.join([package_name, more_packages.pop(0)]) # capture indexes and extra indexes line = [package_name] + more_packages From ebb07002d2399f8c22e703be05a4ee9b3108d886 Mon Sep 17 00:00:00 2001 From: Max Krivich Date: Wed, 20 Jun 2018 13:51:03 +0300 Subject: [PATCH 3/9] Fix empty indexes in cli param Add extra check for -i option for fix `AttributeError: 'NoneType'` To reproduce this bug `pipenv install -i` --- pipenv/core.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pipenv/core.py b/pipenv/core.py index faa54807..d98ca6e4 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -1897,6 +1897,8 @@ def do_install( index_indicators = ['-i', '--index', '--extra-index-url'] index, extra_indexes = None, None if more_packages and any(more_packages[0].startswith(s) for s in index_indicators): + if len(more_packages) < 2: + raise click.BadArgumentUsage('Please provide index value') line, index = split_argument(' '.join(line), short='i', long_='index', num=1) line, extra_indexes = split_argument(line, long_='extra-index-url') package_names = line.split() From 64c5ad9907a8437550e6a4ca703e527799bb6959 Mon Sep 17 00:00:00 2001 From: Max Krivich Date: Wed, 20 Jun 2018 16:43:24 +0300 Subject: [PATCH 4/9] Change exception message --- pipenv/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipenv/core.py b/pipenv/core.py index d98ca6e4..3f8cdc17 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -1890,7 +1890,7 @@ def do_install( more_packages = list(more_packages) if package_name == '-e': if not more_packages: - raise click.BadArgumentUsage('Please provide path to setup.py') + raise click.BadArgumentUsage('Please provide path to editable package') package_name = ' '.join([package_name, more_packages.pop(0)]) # capture indexes and extra indexes line = [package_name] + more_packages From 0353b81b98a4fddf818c47b58d421246f86b6cf9 Mon Sep 17 00:00:00 2001 From: Max Krivich Date: Wed, 20 Jun 2018 17:54:20 +0300 Subject: [PATCH 5/9] Update too complex if statement Quick refactor for improve readability of code --- pipenv/core.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pipenv/core.py b/pipenv/core.py index 3f8cdc17..0dcc7ed2 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -1893,13 +1893,14 @@ def do_install( raise click.BadArgumentUsage('Please provide path to editable package') package_name = ' '.join([package_name, more_packages.pop(0)]) # capture indexes and extra indexes - line = [package_name] + more_packages + line = ' '.join([package_name] + more_packages).strip() index_indicators = ['-i', '--index', '--extra-index-url'] index, extra_indexes = None, None - if more_packages and any(more_packages[0].startswith(s) for s in index_indicators): - if len(more_packages) < 2: - raise click.BadArgumentUsage('Please provide index value') - line, index = split_argument(' '.join(line), short='i', long_='index', num=1) + if any(line.endswith(s) for s in index_indicators): + # check if cli option is not end of command + raise click.BadArgumentUsage('Please provide index value') + if any(s in line for s in index_indicators): + line, index = split_argument(line, short='i', long_='index', num=1) line, extra_indexes = split_argument(line, long_='extra-index-url') package_names = line.split() package_name = package_names[0] From 0ef4929098fa1df236ed8ba63f0572900d4795ea Mon Sep 17 00:00:00 2001 From: Max Krivich Date: Wed, 20 Jun 2018 18:24:36 +0300 Subject: [PATCH 6/9] Fix CI errors --- pipenv/core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pipenv/core.py b/pipenv/core.py index 0dcc7ed2..d97e89a7 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -1893,7 +1893,8 @@ def do_install( raise click.BadArgumentUsage('Please provide path to editable package') package_name = ' '.join([package_name, more_packages.pop(0)]) # capture indexes and extra indexes - line = ' '.join([package_name] + more_packages).strip() + line = [package_name] + more_packages + line = ' '.join(str(s) for s in line).strip() index_indicators = ['-i', '--index', '--extra-index-url'] index, extra_indexes = None, None if any(line.endswith(s) for s in index_indicators): From c76b95db34b8aecae63636695b17961736a7e8d9 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Fri, 22 Jun 2018 02:04:37 -0400 Subject: [PATCH 7/9] Add test for `install -e` Signed-off-by: Dan Ryan --- news/2388.feature | 1 + tests/integration/test_install_basic.py | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 news/2388.feature diff --git a/news/2388.feature b/news/2388.feature new file mode 100644 index 00000000..2286baf7 --- /dev/null +++ b/news/2388.feature @@ -0,0 +1 @@ +Massive internal improvements to requirements parsing codebase, resolver, and error messaging. diff --git a/tests/integration/test_install_basic.py b/tests/integration/test_install_basic.py index bd0b96c3..a6798aa3 100644 --- a/tests/integration/test_install_basic.py +++ b/tests/integration/test_install_basic.py @@ -299,3 +299,13 @@ name = 'mockpi' assert c.return_code == 0 assert p.pipfile['source'][0]['url'] == '${PYPI_URL}/simple' assert p.lockfile['_meta']['sources'][0]['url'] == '${PYPI_URL}/simple' + + +@pytest.mark.editable +@pytest.mark.badparameter +@pytest.mark.install +def test_editable_no_args(PipenvInstance): + with PipenvInstance() as p: + c = p.pipenv('install -e') + assert c.return_code != 0 + assert 'Please provide path to editable package' in c.err From 1ce00f922a1ce84bd0a1421ef66ca5db8ee321f8 Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Wed, 20 Jun 2018 00:27:15 +0800 Subject: [PATCH 8/9] Ensure environs are strings on Python2 + Windows Patch based on theskumar/python-dotenv#101 by @greyli. --- pipenv/vendor/dotenv/main.py | 7 +++++++ .../vendor/dotenv-windows-unicode.patch | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tasks/vendoring/patches/vendor/dotenv-windows-unicode.patch diff --git a/pipenv/vendor/dotenv/main.py b/pipenv/vendor/dotenv/main.py index 3d1bd72f..75f49c4a 100644 --- a/pipenv/vendor/dotenv/main.py +++ b/pipenv/vendor/dotenv/main.py @@ -94,6 +94,13 @@ class DotEnv(): for k, v in self.dict().items(): if k in os.environ and not override: continue + # With Python 2 on Windows, ensuree environment variables are + # system strings to avoid "TypeError: environment can only contain + # strings" in Python's subprocess module. + if sys.version_info.major < 3 and sys.platform == 'win32': + from pipenv.utils import fs_str + k = fs_str(k) + v = fs_str(v) os.environ[k] = v return True diff --git a/tasks/vendoring/patches/vendor/dotenv-windows-unicode.patch b/tasks/vendoring/patches/vendor/dotenv-windows-unicode.patch new file mode 100644 index 00000000..c090e885 --- /dev/null +++ b/tasks/vendoring/patches/vendor/dotenv-windows-unicode.patch @@ -0,0 +1,18 @@ +diff --git a/pipenv/vendor/dotenv/main.py b/pipenv/vendor/dotenv/main.py +index 3d1bd72f..75f49c4a 100644 +--- a/pipenv/vendor/dotenv/main.py ++++ b/pipenv/vendor/dotenv/main.py +@@ -94,6 +94,13 @@ class DotEnv(): + for k, v in self.dict().items(): + if k in os.environ and not override: + continue ++ # With Python 2 on Windows, ensuree environment variables are ++ # system strings to avoid "TypeError: environment can only contain ++ # strings" in Python's subprocess module. ++ if sys.version_info.major < 3 and sys.platform == 'win32': ++ from pipenv.utils import fs_str ++ k = fs_str(k) ++ v = fs_str(v) + os.environ[k] = v + + return True From 154f13a26a65415fa9785afb21bd4ec66eb09841 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Fri, 22 Jun 2018 03:07:37 -0400 Subject: [PATCH 9/9] Added news entry for patch Signed-off-by: Dan Ryan --- news/2386.bugfix | 1 + news/2386.vendor | 1 + 2 files changed, 2 insertions(+) create mode 100644 news/2386.bugfix create mode 100644 news/2386.vendor diff --git a/news/2386.bugfix b/news/2386.bugfix new file mode 100644 index 00000000..ae0e87c7 --- /dev/null +++ b/news/2386.bugfix @@ -0,0 +1 @@ +Patched ``python-dotenv`` to ensure that environment variables always get encoded to the filesystem encoding. diff --git a/news/2386.vendor b/news/2386.vendor new file mode 100644 index 00000000..ae0e87c7 --- /dev/null +++ b/news/2386.vendor @@ -0,0 +1 @@ +Patched ``python-dotenv`` to ensure that environment variables always get encoded to the filesystem encoding.