From 8a311804313d1484e29e6f895e68524955d6b953 Mon Sep 17 00:00:00 2001 From: Diego Mora Cespedes Date: Wed, 27 Sep 2017 00:42:32 +0200 Subject: [PATCH 1/7] Display warning message if PYENV_ROOT is not set and abort if installed python is not the desired one --- .gitignore | 1 + pipenv/cli.py | 25 +++++++++++++++++-------- pipenv/environments.py | 4 +++- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 8259196f..739fd3d3 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ build test_project Pipfile.lock /.vscode/ +.idea diff --git a/pipenv/cli.py b/pipenv/cli.py index d869c5e3..3fe47f7d 100644 --- a/pipenv/cli.py +++ b/pipenv/cli.py @@ -46,7 +46,7 @@ from .environments import ( PIPENV_COLORBLIND, PIPENV_NOSPIN, PIPENV_SHELL_FANCY, PIPENV_VENV_IN_PROJECT, PIPENV_USE_SYSTEM, PIPENV_TIMEOUT, PIPENV_SKIP_VALIDATION, PIPENV_HIDE_EMOJIS, PIPENV_INSTALL_TIMEOUT, - PYENV_INSTALLED, PIPENV_YES, PIPENV_DONT_LOAD_ENV, + PYENV_ROOT, PYENV_INSTALLED, PIPENV_YES, PIPENV_DONT_LOAD_ENV, PIPENV_DEFAULT_PYTHON_VERSION, PIPENV_MAX_SUBPROCESS, PIPENV_DONT_USE_PYENV, SESSION_IS_INTERACTIVE, PIPENV_USE_SYSTEM, PIPENV_DOTENV_LOCATION @@ -122,7 +122,6 @@ urllib3.disable_warnings(InsecureRequestWarning) project = Project() - def load_dot_env(): if not PIPENV_DONT_LOAD_ENV: denv = dotenv.find_dotenv(PIPENV_DOTENV_LOCATION or os.sep.join([project.project_directory, '.env'])) @@ -390,13 +389,23 @@ def ensure_python(three=None, python=None): def activate_pyenv(): """Adds all pyenv installations to the PATH.""" if PYENV_INSTALLED: - for found in glob( - '{0}{1}versions{1}*{1}bin'.format( - os.environ.get('PYENV_ROOT'), - os.sep + if PYENV_ROOT: + for found in glob( + '{0}{1}versions{1}*{1}bin'.format( + PYENV_ROOT, + os.sep + ) + ): + add_to_path(found) + else: + click.echo( + '{0}: PYENV_ROOT is not set. New python paths will ' + 'probably not be exported properly after installation.' + ''.format( + crayons.red('Warning', bold=True), + ), err=True ) - ): - add_to_path(found) + global USING_DEFAULT_PYTHON diff --git a/pipenv/environments.py b/pipenv/environments.py index cb2810c0..dfb7fcdd 100644 --- a/pipenv/environments.py +++ b/pipenv/environments.py @@ -78,6 +78,8 @@ PIPENV_INSTALL_TIMEOUT = 60 * 15 PIPENV_DONT_USE_PYENV = os.environ.get('PIPENV_DONT_USE_PYENV') -PYENV_INSTALLED = (bool(os.environ.get('PYENV_SHELL')) or bool(os.environ.get('PYENV_ROOT'))) +PYENV_ROOT = os.environ.get('PYENV_ROOT') + +PYENV_INSTALLED = (bool(os.environ.get('PYENV_SHELL')) or bool(PYENV_ROOT)) SESSION_IS_INTERACTIVE = bool(os.isatty(sys.stdout.fileno())) From 9763fad1efc2c61f580b24084f52365c82847c94 Mon Sep 17 00:00:00 2001 From: Al Johri Date: Wed, 27 Sep 2017 01:06:31 -0400 Subject: [PATCH 2/7] change 'factory-boy' to 'factory_boy' in packages --- pipenv/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipenv/utils.py b/pipenv/utils.py index 29fefb23..16211819 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -132,7 +132,7 @@ packages = [ 'multi-key-dict', 'fuzzywuzzy', 'fasteners', 'youtube-dl', 'pycryptodome', 'smmap', 'gitdb', 'setuptools-git', 'pager', 'python-subunit', 'warlock', 'extras', 'capstone', 'httpretty', - 'factory-boy', 'webtest', 'django-cors-headers', 'codeintel', 'suds', + 'factory_boy', 'webtest', 'django-cors-headers', 'codeintel', 'suds', 'pyodbc', 'geoip2', 'filechunkio', 'fixtures', 'pysocks', 'statsmodels', 'google-auth-httplib2', 'kafka-python', 'applicationinsights', 'yarl', 'cassandra-driver', 'azure-mgmt-compute', 'pathlib', 'python-jwt', 'sh', From 9dac920ddfae7c64b8dd69481c119a5750587756 Mon Sep 17 00:00:00 2001 From: Erin O'Connell Date: Tue, 26 Sep 2017 23:40:13 -0600 Subject: [PATCH 3/7] re-enable some tests and add 2 for new cli arguments --- .env | 1 + tests/test_pipenv.py | 31 +++++++++++++++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 00000000..6e1f61b5 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +HELLO=WORLD \ No newline at end of file diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index f2125bf4..b18b5f25 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -132,20 +132,32 @@ class TestPipenv: with PipenvInstance() as p: assert p.pipenv('--help').out + @pytest.mark.cli + def test_completion(self): + with PipenvInstance() as p: + assert p.pipenv('--completion').out + + @pytest.mark.cli + def test_man(self): + with PipenvInstance() as p: + c = p.pipenv('--man') + assert c.return_code == 0 or c.err + @pytest.mark.install @pytest.mark.setup @pytest.mark.skip(reason="this doesn't work on travis") def test_basic_setup(self): - with PipenvInstance(pipfile=False) as p: - c = p.pipenv('install requests') - assert c.return_code == 0 + with PipenvInstance() as p: + with PipenvInstance(pipfile=False) as p: + c = p.pipenv('install requests') + assert c.return_code == 0 - assert 'requests' in p.pipfile['packages'] - assert 'requests' in p.lockfile['default'] - assert 'chardet' in p.lockfile['default'] - assert 'idna' in p.lockfile['default'] - assert 'urllib3' in p.lockfile['default'] - assert 'certifi' in p.lockfile['default'] + assert 'requests' in p.pipfile['packages'] + assert 'requests' in p.lockfile['default'] + assert 'chardet' in p.lockfile['default'] + assert 'idna' in p.lockfile['default'] + assert 'urllib3' in p.lockfile['default'] + assert 'certifi' in p.lockfile['default'] @pytest.mark.spelling @pytest.mark.skip(reason="this is slightly non-deterministic") @@ -433,7 +445,6 @@ requests = {version = "*"} @pytest.mark.code @pytest.mark.install - @pytest.mark.skip(reason="this doesn't work on travis") def test_code_import_manual(self): with PipenvInstance() as p: From a950e13be0adf27533a8445697f656ed27376ac7 Mon Sep 17 00:00:00 2001 From: Erin O'Connell Date: Tue, 26 Sep 2017 23:43:32 -0600 Subject: [PATCH 4/7] more coverage --- .env | 1 - appveyor.yml | 1 + tests/test_pipenv.py | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 6e1f61b5..00000000 --- a/.env +++ /dev/null @@ -1 +0,0 @@ -HELLO=WORLD \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 398425d4..c17c9150 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,6 +16,7 @@ environment: - PYTHON: "C:\\Python34-x64" PYTHON_VERSION: "3.4.x" + PYTHON_ARCH: "64" - PYTHON: "C:\\Python35-x64" PYTHON_VERSION: "3.5.x" diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index b18b5f25..660938be 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -562,7 +562,7 @@ pytest = "==3.1.1" req_list = ("requests==2.14.0", "flask==0.12.2", "pytest==3.1.1") - c = p.pipenv('lock -r') + c = p.pipenv('lock --requirements') assert c.return_code == 0 for req in req_list: assert req in c.out \ No newline at end of file From a036e73c4a42eaf6c91aefab513f9275dc5b9bc1 Mon Sep 17 00:00:00 2001 From: Erin O'Connell Date: Tue, 26 Sep 2017 23:56:04 -0600 Subject: [PATCH 5/7] only run tests on unix --- tests/test_pipenv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index 660938be..637e5d91 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -522,7 +522,7 @@ requests = {version = "*"} ('/bin/csh', '.csh'), ('/bin/unknown', '')] ) - @pytest.mark.skip(reason="this doesn't work on app veyor") + @pytest.mark.skipif(os.name == 'nt', reason="Not supported to windows") def test_activate_virtualenv(self, shell, extension): orig_shell = os.environ['SHELL'] From f60385e6c948bb21cce3c5ff30031a3bf1137603 Mon Sep 17 00:00:00 2001 From: Erin O'Connell Date: Wed, 27 Sep 2017 00:32:50 -0600 Subject: [PATCH 6/7] enable a test --- tests/test_pipenv.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index 637e5d91..685ad192 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -145,7 +145,6 @@ class TestPipenv: @pytest.mark.install @pytest.mark.setup - @pytest.mark.skip(reason="this doesn't work on travis") def test_basic_setup(self): with PipenvInstance() as p: with PipenvInstance(pipfile=False) as p: From f4f0187e2e4ad98d4538ebc9cf9c923d47365cbd Mon Sep 17 00:00:00 2001 From: Erin O'Connell Date: Wed, 27 Sep 2017 00:43:43 -0600 Subject: [PATCH 7/7] Revert "enable a test" This reverts commit f60385e6c948bb21cce3c5ff30031a3bf1137603. --- tests/test_pipenv.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_pipenv.py b/tests/test_pipenv.py index 685ad192..637e5d91 100644 --- a/tests/test_pipenv.py +++ b/tests/test_pipenv.py @@ -145,6 +145,7 @@ class TestPipenv: @pytest.mark.install @pytest.mark.setup + @pytest.mark.skip(reason="this doesn't work on travis") def test_basic_setup(self): with PipenvInstance() as p: with PipenvInstance(pipfile=False) as p: