mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Fix create_pipfile version parsing
Signed-off-by: Dan Ryan <dan@danryan.co>
This commit is contained in:
+12
-6
@@ -44,6 +44,7 @@ from .environments import (
|
||||
PIPENV_VIRTUALENV,
|
||||
PIPENV_TEST_INDEX,
|
||||
PIPENV_PYTHON,
|
||||
PIPENV_DEFAULT_PYTHON_VERSION,
|
||||
)
|
||||
|
||||
|
||||
@@ -578,12 +579,17 @@ class Project(object):
|
||||
u'dev-packages': {},
|
||||
}
|
||||
# Default requires.
|
||||
required_python = python or self.which(
|
||||
'python', self.virtualenv_location
|
||||
)
|
||||
data[u'requires'] = {
|
||||
'python_version': python_version(required_python)[: len('2.7')]
|
||||
}
|
||||
required_python = python
|
||||
if not python:
|
||||
if self.virtualenv_location:
|
||||
required_python = self.which('python', self.virtualenv_location)
|
||||
else:
|
||||
required_python = self.which('python')
|
||||
version = python_version(required_python) or PIPENV_DEFAULT_PYTHON_VERSION
|
||||
if version and len(version) >= 3:
|
||||
data[u'requires'] = {
|
||||
'python_version': version[: len('2.7')]
|
||||
}
|
||||
self.write_toml(data, 'Pipfile')
|
||||
|
||||
def write_toml(self, data, path=None):
|
||||
|
||||
+5
-4
@@ -220,12 +220,13 @@ def python_version(path_to_python):
|
||||
c = delegator.run([path_to_python, '--version'], block=False)
|
||||
except Exception:
|
||||
return None
|
||||
if c.return_code != 0:
|
||||
return None
|
||||
c.block()
|
||||
version = parse_python_version(c.out.strip() or c.err.strip())
|
||||
if not version:
|
||||
try:
|
||||
version = u'{major}.{minor}.{micro}'.format(**version)
|
||||
except TypeError:
|
||||
return None
|
||||
return u'{major}.{minor}.{micro}'.format(**version)
|
||||
return version
|
||||
|
||||
|
||||
def escape_grouped_arguments(s):
|
||||
|
||||
Reference in New Issue
Block a user