https://github.com/ambv/black
This commit is contained in:
2018-03-14 17:00:29 -04:00
parent eb342c82d6
commit c2f7f697ee
13 changed files with 851 additions and 468 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
[dev-packages]
"pipenv" = {path = ".", editable = true}
pipenv = {path = ".", editable = true}
"flake8" = ">=3.3.0,<4"
pytest = "*"
mock = "*"
@@ -9,10 +9,10 @@ twine = "*"
sphinx-click = "*"
pytest-xdist = "*"
click = "*"
"pytest-pypy" = {path = "./tests/pytest-pypi", editable = true}
pytest-pypy = {path = "./tests/pytest-pypi", editable = true}
pytest-tap = "*"
stdeb = {version="*", sys_platform="== 'linux'"}
black = {git = "https://github.com/ambv/black.git", python_version = "=='3.6'"}
[packages]
Generated
+18 -37
View File
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "8afda0c2d419e24053d9a9cf8392ccb946c024a58a26a1d8b7948315348d03ef"
"sha256": "6b77ca7e54fbb6febca620c0fb96c0b6ba17aed618c1eaa7e7cba8604a1b3f84"
},
"pipfile-spec": 6,
"requires": {},
@@ -43,6 +43,10 @@
],
"version": "==2.5.3"
},
"black": {
"git": "https://github.com/ambv/black.git",
"python_version": "=='3.6'"
},
"certifi": {
"hashes": [
"sha256:14131608ad2fd56836d33a71ee60fa1c82bc9d2c8d98b7bdbc631fe1b3cd1296",
@@ -62,23 +66,9 @@
"sha256:29f99fc6125fbc931b758dc053b3114e55c77a6e4c6c3a2674a2dc986016381d",
"sha256:f15516df478d5a56180fbf80e68f206010e6d160fc39fa508b65e035fd75130b"
],
"index": "pypi",
"version": "==6.7"
},
"colorama": {
"hashes": [
"sha256:463f8483208e921368c9f306094eb6f725c6ca42b0f97e313cb5d5512459feda",
"sha256:48eb22f4f8461b1df5734a074b57042430fb06e1d61bd1e11b078c0fe6d7a1f1"
],
"markers": "sys_platform == 'win32'",
"version": "==0.3.9"
},
"configparser": {
"hashes": [
"sha256:5308b47021bc2340965c371f0f058cc6971a04502638d4244225c49d80db273a"
],
"markers": "python_version < '3.2'",
"version": "==3.5.0"
},
"docutils": {
"hashes": [
"sha256:02aec4bd92ab067f6ff27a38a38a41173bf01bed8f89157768c1573f53e474a6",
@@ -87,16 +77,6 @@
],
"version": "==0.14"
},
"enum34": {
"hashes": [
"sha256:2d81cbbe0e73112bdfe6ef8576f2238f2ba27dd0d55752a776c41d38b7da2850",
"sha256:644837f692e5f550741432dd3f223bbb9852018674981b1664e5dc339387588a",
"sha256:6bd0f6ad48ec2aa117d3d141940d484deccda84d4fcd884f5c3d93c23ecd8c79",
"sha256:8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1"
],
"markers": "python_version < '3.4'",
"version": "==1.1.6"
},
"execnet": {
"hashes": [
"sha256:a7a84d5fa07a089186a329528f127c9d73b9de57f1a1131b82bb5320ee651f6a",
@@ -109,6 +89,7 @@
"sha256:7253265f7abd8b313e3892944044a365e3f4ac3fcdcfb4298f55ee9ddf188ba0",
"sha256:c7841163e2b576d435799169b78703ad6ac1bbb0f199994fc05f700b2a90ea37"
],
"index": "pypi",
"version": "==3.5.0"
},
"flask": {
@@ -118,14 +99,6 @@
],
"version": "==0.12.2"
},
"funcsigs": {
"hashes": [
"sha256:330cc27ccbf7f1e992e69fef78261dc7c6569012cf397db8d3de0234e6c937ca",
"sha256:a7bb0f2cf3a3fd1ab2732cb49eba4252c2af4240442415b4abce3b87022a8f50"
],
"markers": "python_version < '3.0'",
"version": "==1.0.2"
},
"idna": {
"hashes": [
"sha256:2c6a5de3089009e3da7c5dde64a141dbc8551d5b7f6cf4ed7c2568d0cc520a8f",
@@ -171,6 +144,7 @@
"sha256:5ce3c71c5545b472da17b72268978914d0252980348636840bd34a00b5cc96c1",
"sha256:b158b6df76edd239b8208d481dc46b6afd45a846b7812ff0ce58971cf5bc8bba"
],
"index": "pypi",
"version": "==2.0.0"
},
"packaging": {
@@ -200,10 +174,10 @@
},
"pkginfo": {
"hashes": [
"sha256:31a49103180ae1518b65d3f4ce09c784e2bc54e338197668b4fb7dc539521024",
"sha256:bb1a6aeabfc898f5df124e7e00303a5b3ec9a489535f346bfbddb081af93f89e"
"sha256:5878d542a4b3f237e359926384f1dde4e099c9f5525d236b1840cf704fa8d474",
"sha256:a39076cb3eb34c333a0dd390b568e9e1e881c7bf2cc0aee12120636816f55aee"
],
"version": "==1.4.1"
"version": "==1.4.2"
},
"pluggy": {
"hashes": [
@@ -256,6 +230,7 @@
"sha256:062027955bccbc04d2fcd5d79690947e018ba31abe4c90b2c6721abec734261b",
"sha256:117bad36c1a787e1a8a659df35de53ba05f9f3398fb9e4ac17e80ad5903eb8c5"
],
"index": "pypi",
"version": "==3.4.2"
},
"pytest-forked": {
@@ -274,6 +249,7 @@
"sha256:06ff3ca882b69814f20e36533157394372479c91c21233964dab52c071faf8d3",
"sha256:ea621f3ab77c12dc662ad6daeeb0152cfab522e2ef968d90500cf4c0a59dc965"
],
"index": "pypi",
"version": "==2.2"
},
"pytest-xdist": {
@@ -281,6 +257,7 @@
"sha256:be2662264b035920ba740ed6efb1c816a83c8a22253df7766d129f6a7bfdbd35",
"sha256:e8f5744acc270b3e7d915bdb4d5f471670f049b6fbd163d4cbd52203b075d30f"
],
"index": "pypi",
"version": "==1.22.2"
},
"pytz": {
@@ -330,6 +307,7 @@
"sha256:11f271e7a9398385ed730e90f0bb41dc3815294bdcd395b46ed2d033bc2e7d87",
"sha256:4064ea6c56feeb268838cb8fbbee507d0c3d5d92fa63a7df935a916b52c9e2f5"
],
"index": "pypi",
"version": "==1.5.5"
},
"sphinx-click": {
@@ -337,6 +315,7 @@
"sha256:612a00b497e0434271d2ef808369d627d0002936d66ec21e11c07e79f886fbd5",
"sha256:fcab79e81120256f21ae86e099186a78abfe0fff45002b33ed04ccf38dba8490"
],
"index": "pypi",
"version": "==1.0.4"
},
"sphinxcontrib-websupport": {
@@ -350,6 +329,7 @@
"hashes": [
"sha256:0ed2c2cc6b8ba21da7d646c6f37ca60b22e9e4950e3cec6bcd9c2e7e57e3747e"
],
"index": "pypi",
"markers": "sys_platform == 'linux'",
"version": "==0.8.5"
},
@@ -372,6 +352,7 @@
"sha256:c3540f2b98667698412b0dc9f5e40c8c1a08a9e79e255c9c21339105eb4ca57a",
"sha256:eff86e20fdffef8abb0b638784c62d0348dac4c80380907e39b732c56e9192fb"
],
"index": "pypi",
"version": "==1.10.0"
},
"urllib3": {
+1 -6
View File
@@ -2,29 +2,24 @@
# |__/||~~\|--|/~\\ /
# | ||__/|__| |\/
# |
import os
import sys
PIPENV_ROOT = os.path.dirname(os.path.realpath(__file__))
PIPENV_VENDOR = os.sep.join([PIPENV_ROOT, 'vendor'])
PIPENV_PATCHED = os.sep.join([PIPENV_ROOT, 'patched'])
# Inject vendored directory into system path.
sys.path.insert(0, PIPENV_VENDOR)
# Inject patched directory into system path.
sys.path.insert(0, PIPENV_PATCHED)
# Hack to make things work better.
try:
if 'concurrency' in sys.modules:
del sys.modules['concurrency']
except Exception:
pass
from .cli import cli
from . import resolver
from .import resolver
if __name__ == '__main__':
cli()
-2
View File
@@ -1,7 +1,5 @@
# ___ ( ) ___ ___ __
# // ) ) / / // ) ) //___) ) // ) ) || / /
# //___/ / / / //___/ / // // / / || / /
# // / / // ((____ // / / ||/ /
__version__ = '11.7.4'
+615 -210
View File
File diff suppressed because it is too large Load Diff
+8 -34
View File
@@ -5,54 +5,41 @@ from appdirs import user_cache_dir
# Prevent invalid shebangs with Homebrew-installed Python:
# https://bugs.python.org/issue22490
os.environ.pop('__PYVENV_LAUNCHER__', None)
# Shell compatibility mode, for mis-configured shells.
PIPENV_SHELL_FANCY = bool(os.environ.get('PIPENV_SHELL_FANCY'))
# Support for both Python 2 and Python 3 at the same time.
PIPENV_PYTHON = os.environ.get('PIPENV_PYTHON')
# Create the virtualenv in the project, instead of with pew.
PIPENV_VENV_IN_PROJECT = bool(os.environ.get('PIPENV_VENV_IN_PROJECT')) or os.path.isdir('.venv')
PIPENV_VENV_IN_PROJECT = bool(
os.environ.get('PIPENV_VENV_IN_PROJECT')
) or os.path.isdir(
'.venv'
)
# Overwrite all index funcitonality.
PIPENV_TEST_INDEX = os.environ.get('PIPENV_TEST_INDEX')
# No color mode, for unfun people.
PIPENV_COLORBLIND = bool(os.environ.get('PIPENV_COLORBLIND'))
# Disable spinner for better test and deploy logs (for the unworthy).
PIPENV_NOSPIN = bool(os.environ.get('PIPENV_NOSPIN'))
# Tells Pipenv how many rounds of resolving to do for Pip-Tools.
PIPENV_MAX_ROUNDS = int(os.environ.get('PIPENV_MAX_ROUNDS', '16'))
# Specify a custom Pipfile location.
PIPENV_PIPFILE = os.environ.get('PIPENV_PIPFILE')
# Tells Pipenv which Python to default to, when none is provided.
PIPENV_DEFAULT_PYTHON_VERSION = os.environ.get('PIPENV_DEFAULT_PYTHON_VERSION')
# Tells Pipenv to not load .env files.
PIPENV_DONT_LOAD_ENV = bool(os.environ.get('PIPENV_DONT_LOAD_ENV'))
# Tell Pipenv to default to yes at all prompts.
PIPENV_YES = bool(os.environ.get('PIPENV_YES'))
# Tells Pipenv how many subprocesses to use when installing.
PIPENV_MAX_SUBPROCESS = int(os.environ.get('PIPENV_MAX_SUBPROCESS', '16'))
# User-configurable max-depth for Pipfile searching.
# Note: +1 because of a temporary bug in Pipenv.
PIPENV_MAX_DEPTH = int(os.environ.get('PIPENV_MAX_DEPTH', '3')) + 1
# Tell Pipenv not to inherit parent directories (for development, mostly).
PIPENV_NO_INHERIT = 'PIPENV_NO_INHERIT' in os.environ
if PIPENV_NO_INHERIT:
PIPENV_MAX_DEPTH = 2
# Tells Pipenv to use the virtualenv-provided pip instead.
PIPENV_VIRTUALENV = None
PIPENV_USE_SYSTEM = False
@@ -60,45 +47,32 @@ if 'PIPENV_ACTIVE' not in os.environ:
if 'PIPENV_IGNORE_VIRTUALENVS' not in os.environ:
PIPENV_VIRTUALENV = os.environ.get('VIRTUAL_ENV')
PIPENV_USE_SYSTEM = bool(os.environ.get('VIRTUAL_ENV'))
# Tells Pipenv to use hashing mode.
PIPENV_USE_HASHES = True
# Tells Pipenv to skip case-checking (slow internet connections).
PIPENV_SKIP_VALIDATION = True
# Tells Pipenv where to load .env from.
PIPENV_DOTENV_LOCATION = os.environ.get('PIPENV_DOTENV_LOCATION')
# Use shell compatibility mode when using venv in project mode.
if PIPENV_VENV_IN_PROJECT:
PIPENV_SHELL_COMPAT = True
# Disable spinner on Windows.
if os.name == 'nt':
PIPENV_NOSPIN = True
# Disable the spinner on Travis-Ci (and friends).
if 'CI' in os.environ:
PIPENV_NOSPIN = True
PIPENV_HIDE_EMOJIS = bool(os.environ.get('PIPENV_HIDE_EMOJIS'))
if os.name == 'nt':
PIPENV_HIDE_EMOJIS = True
# Tells Pipenv how long to wait for virtualenvs to be created in seconds.
PIPENV_TIMEOUT = int(os.environ.get('PIPENV_TIMEOUT', 120))
PIPENV_INSTALL_TIMEOUT = 60 * 15
PIPENV_DONT_USE_PYENV = os.environ.get('PIPENV_DONT_USE_PYENV')
PYENV_ROOT = os.environ.get('PYENV_ROOT', os.path.expanduser('~/.pyenv'))
PYENV_INSTALLED = (bool(os.environ.get('PYENV_SHELL')) or bool(os.environ.get('PYENV_ROOT')))
PYENV_INSTALLED = (
bool(os.environ.get('PYENV_SHELL')) or bool(os.environ.get('PYENV_ROOT'))
)
SESSION_IS_INTERACTIVE = bool(os.isatty(sys.stdout.fileno()))
PIPENV_SHELL = os.environ.get('SHELL') or os.environ.get('PYENV_SHELL')
PIPENV_CACHE_DIR = os.environ.get('PIPENV_CACHE_DIR', user_cache_dir('pipenv'))
+2 -10
View File
@@ -9,6 +9,7 @@ from .__version__ import __version__
from .core import project, system_which, find_python_in_path, python_version
from .pep508checker import lookup
def main():
print('<details><summary>$ python -m pipenv.help output</summary>')
print('Pipenv version: `{0!r}`'.format(__version__))
@@ -23,7 +24,6 @@ def main():
found = find_python_in_path(python_v)
if found:
print(' - `{0}`: `{1}`'.format(python_v, found))
found = system_which('python{0}'.format(python_v), mult=True)
if found:
for f in found:
@@ -33,9 +33,6 @@ def main():
found = system_which(p, mult=True)
for f in found:
print(' - `{0}`: `{1}`'.format(python_version(f), f))
print('')
print('PEP 508 Information:')
print('')
@@ -43,31 +40,26 @@ def main():
pprint(lookup)
print('```')
print('')
print('System environment variables:')
print('')
for key in os.environ:
print(' - `{0}`'.format(key))
print('')
print(u'Pipenvspecific environment variables:')
print('')
for key in os.environ:
if key.startswith('PIPENV'):
print(' - `{0}`: `{1}`'.format(key, os.environ[key]))
print('')
print(u'Debugspecific environment variables:')
print('')
for key in ('PATH', 'SHELL', 'EDITOR', 'LANG', 'PWD', 'VIRTUAL_ENV'):
if key in os.environ:
print(' - `{0}`: `{1}`'.format(key, os.environ[key]))
print('')
print('')
print('---------------------------')
print('')
if project.pipfile_exists:
print(u'Contents of `Pipfile` ({0!r}):'.format(project.pipfile_location))
print('')
@@ -76,7 +68,6 @@ def main():
print(f.read())
print('```')
print('')
if project.lockfile_exists:
print('')
print(u'Contents of `Pipfile.lock` ({0!r}):'.format(project.lockfile_location))
@@ -87,5 +78,6 @@ def main():
print('```')
print('</details>')
if __name__ == '__main__':
main()
+1 -4
View File
@@ -18,13 +18,11 @@ if hasattr(sys, 'implementation'):
implementation_version = format_full_version(sys.implementation.version)
else:
implementation_version = '0'
# Default to cpython for 2.7.
if hasattr(sys, 'implementation'):
implementation_name = sys.implementation.name
else:
implementation_name = 'cpython'
lookup = {
'os_name': os.name,
'sys_platform': sys.platform,
@@ -36,8 +34,7 @@ lookup = {
'python_version': platform.python_version()[:3],
'python_full_version': platform.python_version(),
'implementation_name': implementation_name,
'implementation_version': implementation_version
'implementation_version': implementation_version,
}
if __name__ == '__main__':
print(json.dumps(lookup))
-1
View File
@@ -7,7 +7,6 @@ PIPENV_PATCHED = os.sep.join([PIPENV_ROOT, 'patched'])
import pew
if __name__ == '__main__':
sys.path.insert(0, PIPENV_VENDOR)
sys.path.insert(0, PIPENV_PATCHED)
+18 -11
View File
@@ -4,7 +4,6 @@ import json
import logging
os.environ['PIP_PYTHON_PATH'] = sys.executable
for _dir in ('vendor', 'patched', '..'):
dirpath = os.path.sep.join([os.path.dirname(__file__), _dir])
sys.path.insert(0, dirpath)
@@ -13,19 +12,19 @@ for _dir in ('vendor', 'patched', '..'):
def which(*args, **kwargs):
return sys.executable
def main():
is_verbose = '--verbose' in ' '.join(sys.argv)
do_pre = '--pre' in ' '.join(sys.argv)
do_clear = '--clear' in ' '.join(sys.argv)
is_debug = '--debug' in ' '.join(sys.argv)
new_sys_argv = []
for v in sys.argv:
if v.startswith('--'):
continue
else:
new_sys_argv.append(v)
sys.argv = new_sys_argv
import pipenv.core
@@ -35,27 +34,35 @@ def main():
if is_debug:
# Shit's getting real at this point.
logging.getLogger('pip9').setLevel(logging.DEBUG)
if 'PIPENV_PACKAGES' in os.environ:
packages = os.environ['PIPENV_PACKAGES'].strip().split('\n')
else:
packages = sys.argv[1:]
for i, package in enumerate(packages):
if package.startswith('--'):
del packages[i]
project = pipenv.core.project
def resolve(packages, pre, sources, verbose, clear):
import pipenv.utils
return pipenv.utils.resolve_deps(packages, which, project=project, pre=pre, sources=sources, clear=clear, verbose=verbose)
results = resolve(packages, pre=do_pre, sources=project.sources, verbose=is_verbose, clear=do_clear)
return pipenv.utils.resolve_deps(
packages,
which,
project=project,
pre=pre,
sources=sources,
clear=clear,
verbose=verbose,
)
results = resolve(
packages,
pre=do_pre,
sources=project.sources,
verbose=is_verbose,
clear=do_clear,
)
print('RESULTS:')
if results:
print(json.dumps(results))
else:
+9 -23
View File
@@ -1,6 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import codecs
import os
import sys
@@ -9,18 +8,14 @@ from shutil import rmtree
from setuptools import find_packages, setup, Command
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = '\n' + f.read()
about = {}
with open(os.path.join(here, "pipenv", "__version__.py")) as f:
exec(f.read(), about)
exec (f.read(), about)
if sys.argv[-1] == "publish":
os.system("python setup.py sdist bdist_wheel upload")
sys.exit()
required = [
'pip>=9.0.1',
'certifi',
@@ -29,14 +24,13 @@ required = [
'virtualenv-clone>=0.2.5',
'pathlib;python_version<"3.4"',
'requests[security];python_version<"3.0"',
'ordereddict;python_version<"3.0"'
'ordereddict;python_version<"3.0"',
]
# https://pypi.python.org/pypi/stdeb/0.8.5#quickstart-2-just-tell-me-the-fastest-way-to-make-a-deb
class DebCommand(Command):
"""Support for setup.py deb"""
description = 'Build and publish the .deb package.'
user_options = []
@@ -55,12 +49,12 @@ class DebCommand(Command):
try:
self.status('Removing previous builds…')
rmtree(os.path.join(here, 'deb_dist'))
except FileNotFoundError:
pass
self.status(u'Creating debian mainfest…')
os.system('python setup.py --command-packages=stdeb.command sdist_dsc -z artful --package3=pipenv --depends3=python3-virtualenv-clone')
os.system(
'python setup.py --command-packages=stdeb.command sdist_dsc -z artful --package3=pipenv --depends3=python3-virtualenv-clone'
)
self.status(u'Building .deb…')
os.chdir('deb_dist/pipenv-{0}'.format(about['__version__']))
os.system('dpkg-buildpackage -rfakeroot -uc -us')
@@ -68,7 +62,6 @@ class DebCommand(Command):
class UploadCommand(Command):
"""Support setup.py publish."""
description = 'Build and publish the package.'
user_options = []
@@ -89,17 +82,13 @@ class UploadCommand(Command):
rmtree(os.path.join(here, 'dist'))
except FileNotFoundError:
pass
self.status('Building Source distribution…')
os.system('{0} setup.py sdist'.format(sys.executable))
self.status('Uploading the package to PyPi via Twine…')
os.system('twine upload dist/*')
self.status('Pushing git tags…')
os.system('git tag v{0}'.format(about['__version__']))
os.system('git push --tags')
sys.exit()
@@ -116,8 +105,8 @@ setup(
'console_scripts': [
'pipenv=pipenv:cli',
'pewtwo=pipenv.patched.pew.pew:pew',
'pipenv-resolver=pipenv.resolver:main'
],
'pipenv-resolver=pipenv.resolver:main',
]
},
install_requires=required,
extras_require={},
@@ -133,10 +122,7 @@ setup(
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy'
'Programming Language :: Python :: Implementation :: PyPy',
],
cmdclass={
'upload': UploadCommand,
'deb': DebCommand
},
cmdclass={'upload': UploadCommand, 'deb': DebCommand},
)
+147 -96
View File
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
import os
import pytest
from mock import patch, Mock
@@ -8,57 +7,67 @@ import pipenv.utils
class TestUtils:
"""Test utility functions in pipenv"""
@pytest.mark.utils
def test_convert_deps_to_pip(self):
# requests = '*'
deps = {'requests': '*'}
deps = pipenv.utils.convert_deps_to_pip(deps, r=False)
assert deps[0] == 'requests'
# requests = {}
deps = {'requests': {}}
deps = pipenv.utils.convert_deps_to_pip(deps, r=False)
assert deps[0] == 'requests'
# requests = { extras = ['socks'] }
deps = {'requests': {'extras': ['socks']}}
deps = pipenv.utils.convert_deps_to_pip(deps, r=False)
assert deps[0] == 'requests[socks]'
# Django = '>1.10'
deps = {'django': '>1.10'}
deps = pipenv.utils.convert_deps_to_pip(deps, r=False)
assert deps[0] == 'django>1.10'
# Pinned version with Extras
deps = {'requests': {'extras': ['socks'], 'version': '>1.10'}}
deps = pipenv.utils.convert_deps_to_pip(deps, r=False)
assert deps[0] == 'requests[socks]>1.10'
# pinax = { git = 'git://github.com/pinax/pinax.git', ref = '1.4', editable = true }
deps = {'pinax': {'git': 'git://github.com/pinax/pinax.git', 'ref': '1.4', 'editable': True}}
deps = {
'pinax': {
'git': 'git://github.com/pinax/pinax.git',
'ref': '1.4',
'editable': True,
}
}
deps = pipenv.utils.convert_deps_to_pip(deps, r=False)
assert deps[0] == '-e git+git://github.com/pinax/pinax.git@1.4#egg=pinax'
# pinax = { git = 'git://github.com/pinax/pinax.git', ref = '1.4'}
deps = {'pinax': {'git': 'git://github.com/pinax/pinax.git', 'ref': '1.4'}}
deps = pipenv.utils.convert_deps_to_pip(deps, r=False)
assert deps[0] == 'git+git://github.com/pinax/pinax.git@1.4#egg=pinax'
# test hashes
deps = {'FooProject': {'version': '==1.2', 'hash': 'sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'}}
deps = {
'FooProject': {
'version': '==1.2',
'hash': 'sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824',
}
}
deps = pipenv.utils.convert_deps_to_pip(deps, r=False)
assert deps[0] == 'FooProject==1.2 --hash=sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'
assert deps[
0
] == 'FooProject==1.2 --hash=sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'
# test everything
deps = {'FooProject': {'version': '==1.2', 'extras': ['stuff'], 'hash': 'sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'}}
deps = {
'FooProject': {
'version': '==1.2',
'extras': ['stuff'],
'hash': 'sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824',
}
}
deps = pipenv.utils.convert_deps_to_pip(deps, r=False)
assert deps[0] == 'FooProject[stuff]==1.2 --hash=sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'
assert deps[
0
] == 'FooProject[stuff]==1.2 --hash=sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'
# test unicode values
deps = {u'django': u'==1.10'}
deps = pipenv.utils.convert_deps_to_pip(deps, r=False)
@@ -66,43 +75,47 @@ class TestUtils:
@pytest.mark.utils
def test_convert_from_pip(self):
# requests
dep = 'requests'
dep = pipenv.utils.convert_deps_from_pip(dep)
assert dep == {'requests': '*'}
# Django>1.10
dep = 'Django>1.10'
dep = pipenv.utils.convert_deps_from_pip(dep)
assert dep == {'Django': '>1.10'}
# requests[socks]
dep = 'requests[socks]'
dep = pipenv.utils.convert_deps_from_pip(dep)
assert dep == {'requests': {'extras': ['socks']}}
# requests[socks] w/ version
dep = 'requests[socks]==1.10'
dep = pipenv.utils.convert_deps_from_pip(dep)
assert dep == {'requests': {'extras': ['socks'], 'version': '==1.10'}}
dep = '-e svn+svn://svn.myproject.org/svn/MyProject#egg=MyProject'
dep = pipenv.utils.convert_deps_from_pip(dep)
assert dep == {u'MyProject': {u'svn': u'svn://svn.myproject.org/svn/MyProject', 'editable': True}}
assert dep == {
u'MyProject': {
u'svn': u'svn://svn.myproject.org/svn/MyProject', 'editable': True
}
}
# mercurial repository with commit reference
dep = 'hg+http://hg.myproject.org/MyProject@da39a3ee5e6b#egg=MyProject'
dep = pipenv.utils.convert_deps_from_pip(dep)
assert dep == {'MyProject': {'hg': 'http://hg.myproject.org/MyProject', 'ref': 'da39a3ee5e6b'}}
assert dep == {
'MyProject': {
'hg': 'http://hg.myproject.org/MyProject', 'ref': 'da39a3ee5e6b'
}
}
# vcs dependency with extras_require
dep = 'git+https://github.com/requests/requests.git@master#egg=requests[security]'
dep = pipenv.utils.convert_deps_from_pip(dep)
assert dep == {'requests': {'git': 'https://github.com/requests/requests.git',
'ref': 'master',
'extras': ['security']}}
assert dep == {
'requests': {
'git': 'https://github.com/requests/requests.git',
'ref': 'master',
'extras': ['security'],
}
}
# vcs dependency without #egg
dep = 'git+https://github.com/kennethreitz/requests.git'
with pytest.raises(ValueError) as e:
@@ -110,27 +123,37 @@ class TestUtils:
assert 'pipenv requires an #egg fragment for vcs' in str(e)
@pytest.mark.utils
@pytest.mark.parametrize('version, specified_ver, expected', [
('*', '*', True),
('2.1.6', '==2.1.4', False),
('20160913', '>=20140815', True),
('1.4', {'svn': 'svn://svn.myproj.org/svn/MyProj', 'version': '==1.4'}, True),
('2.13.0', {'extras': ['socks'], 'version': '==2.12.4'}, False)
])
@pytest.mark.parametrize(
'version, specified_ver, expected',
[
('*', '*', True),
('2.1.6', '==2.1.4', False),
('20160913', '>=20140815', True),
(
'1.4',
{'svn': 'svn://svn.myproj.org/svn/MyProj', 'version': '==1.4'},
True,
),
('2.13.0', {'extras': ['socks'], 'version': '==2.12.4'}, False),
],
)
def test_is_required_version(self, version, specified_ver, expected):
assert pipenv.utils.is_required_version(version, specified_ver) is expected
@pytest.mark.utils
@pytest.mark.parametrize('entry, expected', [
({'git': 'package.git', 'ref': 'v0.0.1'}, True),
({'hg': 'https://package.com/package', 'ref': 'v1.2.3'}, True),
('*', False),
({'some_value': 5, 'other_value': object()}, False),
('package', False),
('git+https://github.com/requests/requests.git#egg=requests', True),
('git+git@github.com:requests/requests.git#egg=requests', True),
('gitdb2', False)
])
@pytest.mark.parametrize(
'entry, expected',
[
({'git': 'package.git', 'ref': 'v0.0.1'}, True),
({'hg': 'https://package.com/package', 'ref': 'v1.2.3'}, True),
('*', False),
({'some_value': 5, 'other_value': object()}, False),
('package', False),
('git+https://github.com/requests/requests.git#egg=requests', True),
('git+git@github.com:requests/requests.git#egg=requests', True),
('gitdb2', False),
],
)
@pytest.mark.vcs
def test_is_vcs(self, entry, expected):
assert pipenv.utils.is_vcs(entry) is expected
@@ -141,19 +164,22 @@ class TestUtils:
'packages': {
'requests': {'git': 'https://github.com/kennethreitz/requests.git'},
'Flask': '*',
'tablib': {'path': '.', 'editable': True}
'tablib': {'path': '.', 'editable': True},
},
'dev-packages': {
'Django': '==1.10',
'click': {'svn': 'https://svn.notareal.com/click'},
'crayons': {'hg': 'https://hg.alsonotreal.com/crayons'}
}
'crayons': {'hg': 'https://hg.alsonotreal.com/crayons'},
},
}
split_dict = pipenv.utils.split_file(pipfile_dict)
assert list(split_dict['packages'].keys()) == ['Flask']
assert split_dict['packages-vcs'] == {'requests': {'git': 'https://github.com/kennethreitz/requests.git'}}
assert split_dict['packages-editable'] == {'tablib': {'path': '.', 'editable': True}}
assert split_dict['packages-vcs'] == {
'requests': {'git': 'https://github.com/kennethreitz/requests.git'}
}
assert split_dict['packages-editable'] == {
'tablib': {'path': '.', 'editable': True}
}
assert list(split_dict['dev-packages'].keys()) == ['Django']
assert 'click' in split_dict['dev-packages-vcs']
assert 'crayons' in split_dict['dev-packages-vcs']
@@ -167,13 +193,18 @@ class TestUtils:
assert pipenv.utils.python_version("/dev/null") is None
@pytest.mark.utils
@pytest.mark.parametrize('version_output, version', [
('Python 3.6.2', '3.6.2'),
('Python 3.6.2 :: Continuum Analytics, Inc.', '3.6.2'),
('Python 3.6.20 :: Continuum Analytics, Inc.', '3.6.20'),
])
@pytest.mark.parametrize(
'version_output, version',
[
('Python 3.6.2', '3.6.2'),
('Python 3.6.2 :: Continuum Analytics, Inc.', '3.6.2'),
('Python 3.6.20 :: Continuum Analytics, Inc.', '3.6.20'),
],
)
@patch('delegator.run')
def test_python_version_output_variants(self, mocked_delegator, version_output, version):
def test_python_version_output_variants(
self, mocked_delegator, version_output, version
):
run_ret = Mock()
run_ret.out = version_output
mocked_delegator.return_value = run_ret
@@ -195,21 +226,27 @@ class TestUtils:
assert pipenv.utils.is_valid_url(not_url) is False
@pytest.mark.utils
@pytest.mark.parametrize('input_path, expected', [
('artifacts/file.zip', './artifacts/file.zip'),
('./artifacts/file.zip', './artifacts/file.zip'),
('../otherproject/file.zip', './../otherproject/file.zip')
])
@pytest.mark.parametrize(
'input_path, expected',
[
('artifacts/file.zip', './artifacts/file.zip'),
('./artifacts/file.zip', './artifacts/file.zip'),
('../otherproject/file.zip', './../otherproject/file.zip'),
],
)
@pytest.mark.skipif(os.name == 'nt', reason='Nix-based file paths tested')
def test_nix_converted_relative_path(self, input_path, expected):
assert pipenv.utils.get_converted_relative_path(input_path) == expected
@pytest.mark.utils
@pytest.mark.parametrize('input_path, expected', [
('artifacts/file.zip', '.\\artifacts\\file.zip'),
('./artifacts/file.zip', '.\\artifacts\\file.zip'),
('../otherproject/file.zip', '.\\..\\otherproject\\file.zip')
])
@pytest.mark.parametrize(
'input_path, expected',
[
('artifacts/file.zip', '.\\artifacts\\file.zip'),
('./artifacts/file.zip', '.\\artifacts\\file.zip'),
('../otherproject/file.zip', '.\\..\\otherproject\\file.zip'),
],
)
@pytest.mark.skipif(os.name != 'nt', reason='Windows-based file paths tested')
def test_win_converted_relative_path(self, input_path, expected):
assert pipenv.utils.get_converted_relative_path(input_path) == expected
@@ -242,27 +279,37 @@ twine = "*"
assert new_toml[-1] == '\n'
@pytest.mark.utils
@pytest.mark.parametrize('input_path, expected', [
('c:\\Program Files\\Python36\\python.exe',
'C:\\Program Files\\Python36\\python.exe'),
('C:\\Program Files\\Python36\\python.exe',
'C:\\Program Files\\Python36\\python.exe'),
('\\\\host\\share\\file.zip', '\\\\host\\share\\file.zip'),
('artifacts\\file.zip', 'artifacts\\file.zip'),
('.\\artifacts\\file.zip', '.\\artifacts\\file.zip'),
('..\\otherproject\\file.zip', '..\\otherproject\\file.zip'),
])
@pytest.mark.parametrize(
'input_path, expected',
[
(
'c:\\Program Files\\Python36\\python.exe',
'C:\\Program Files\\Python36\\python.exe',
),
(
'C:\\Program Files\\Python36\\python.exe',
'C:\\Program Files\\Python36\\python.exe',
),
('\\\\host\\share\\file.zip', '\\\\host\\share\\file.zip'),
('artifacts\\file.zip', 'artifacts\\file.zip'),
('.\\artifacts\\file.zip', '.\\artifacts\\file.zip'),
('..\\otherproject\\file.zip', '..\\otherproject\\file.zip'),
],
)
@pytest.mark.skipif(os.name != 'nt', reason='Windows file paths tested')
def test_win_normalize_drive(self, input_path, expected):
assert pipenv.utils.normalize_drive(input_path) == expected
@pytest.mark.utils
@pytest.mark.parametrize('input_path, expected', [
('/usr/local/bin/python', '/usr/local/bin/python'),
('artifacts/file.zip', 'artifacts/file.zip'),
('./artifacts/file.zip', './artifacts/file.zip'),
('../otherproject/file.zip', '../otherproject/file.zip'),
])
@pytest.mark.parametrize(
'input_path, expected',
[
('/usr/local/bin/python', '/usr/local/bin/python'),
('artifacts/file.zip', 'artifacts/file.zip'),
('./artifacts/file.zip', './artifacts/file.zip'),
('../otherproject/file.zip', '../otherproject/file.zip'),
],
)
@pytest.mark.skipif(os.name == 'nt', reason='*nix file paths tested')
def test_nix_normalize_drive(self, input_path, expected):
assert pipenv.utils.normalize_drive(input_path) == expected
@@ -271,35 +318,39 @@ twine = "*"
@pytest.mark.requirements
def test_get_requirements(self):
# Test eggs in URLs
url_with_egg = pipenv.utils.get_requirement('https://github.com/IndustriaTech/django-user-clipboard/archive/0.6.1.zip#egg=django-user-clipboard')
url_with_egg = pipenv.utils.get_requirement(
'https://github.com/IndustriaTech/django-user-clipboard/archive/0.6.1.zip#egg=django-user-clipboard'
)
assert url_with_egg.uri == 'https://github.com/IndustriaTech/django-user-clipboard/archive/0.6.1.zip'
assert url_with_egg.name == 'django-user-clipboard'
# Test URLs without eggs pointing at installable zipfiles
url = pipenv.utils.get_requirement('https://github.com/kennethreitz/tablib/archive/0.12.1.zip')
url = pipenv.utils.get_requirement(
'https://github.com/kennethreitz/tablib/archive/0.12.1.zip'
)
assert url.uri == 'https://github.com/kennethreitz/tablib/archive/0.12.1.zip'
# Test VCS urls with refs and eggnames
vcs_url = pipenv.utils.get_requirement('git+https://github.com/kennethreitz/tablib.git@master#egg=tablib')
vcs_url = pipenv.utils.get_requirement(
'git+https://github.com/kennethreitz/tablib.git@master#egg=tablib'
)
assert vcs_url.vcs == 'git' and vcs_url.name == 'tablib' and vcs_url.revision == 'master'
assert vcs_url.uri == 'git+https://github.com/kennethreitz/tablib.git'
# Test normal package requirement
normal = pipenv.utils.get_requirement('tablib')
assert normal.name == 'tablib'
# Pinned package requirement
spec = pipenv.utils.get_requirement('tablib==0.12.1')
assert spec.name == 'tablib' and spec.specs == [('==', '0.12.1')]
# Test complex package with both extras and markers
extras_markers = pipenv.utils.get_requirement("requests[security]; os_name=='posix'")
extras_markers = pipenv.utils.get_requirement(
"requests[security]; os_name=='posix'"
)
assert extras_markers.extras == ['security']
assert extras_markers.name == 'requests'
assert extras_markers.markers == "os_name=='posix'"
# Test VCS uris get generated correctly, retain git+git@ if supplied that way, and are named according to egg fragment
git_reformat = pipenv.utils.get_requirement('-e git+git@github.com:pypa/pipenv.git#egg=pipenv')
git_reformat = pipenv.utils.get_requirement(
'-e git+git@github.com:pypa/pipenv.git#egg=pipenv'
)
assert git_reformat.uri == 'git+git@github.com:pypa/pipenv.git'
assert git_reformat.name == 'pipenv'
assert git_reformat.editable
+29 -31
View File
@@ -1,31 +1,29 @@
# Make sure we use the patched packages.
import pipenv # noqa
from prettytoml import lexer
from prettytoml.elements.atomic import AtomicElement
from prettytoml.elements.metadata import (
WhitespaceElement, PunctuationElement, CommentElement,
)
from prettytoml.elements.table import TableElement
def test_table():
initial_toml = """id=42 # My id\nage=14"""
tokens = tuple(lexer.tokenize(initial_toml))
table = TableElement([
AtomicElement(tokens[0:1]),
PunctuationElement(tokens[1:2]),
AtomicElement(tokens[2:3]),
WhitespaceElement(tokens[3:4]),
CommentElement(tokens[4:6]),
AtomicElement(tokens[6:7]),
PunctuationElement(tokens[7:8]),
AtomicElement(tokens[8:9]),
])
assert set(table.items()) == {('id', 42), ('age', 14)}
del table['id']
assert set(table.items()) == {('age', 14)}
# Make sure we use the patched packages.
import pipenv # noqa
from prettytoml import lexer
from prettytoml.elements.atomic import AtomicElement
from prettytoml.elements.metadata import (
WhitespaceElement, PunctuationElement, CommentElement
)
from prettytoml.elements.table import TableElement
def test_table():
initial_toml = """id=42 # My id\nage=14"""
tokens = tuple(lexer.tokenize(initial_toml))
table = TableElement(
[
AtomicElement(tokens[0:1]),
PunctuationElement(tokens[1:2]),
AtomicElement(tokens[2:3]),
WhitespaceElement(tokens[3:4]),
CommentElement(tokens[4:6]),
AtomicElement(tokens[6:7]),
PunctuationElement(tokens[7:8]),
AtomicElement(tokens[8:9]),
]
)
assert set(table.items()) == {('id', 42), ('age', 14)}
del table['id']
assert set(table.items()) == {('age', 14)}