Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
49846247
Unverified
Commit
49846247
authored
Oct 23, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handling of Python versions compatibility
parent
69f2f6db
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
63 additions
and
3 deletions
+63
-3
CHANGELOG.md
+1
-0
poetry/console/commands/env_command.py
+17
-0
poetry/console/commands/init.py
+11
-1
poetry/console/commands/new.py
+12
-1
poetry/utils/env.py
+16
-0
tests/console/commands/test_init.py
+1
-1
tests/console/conftest.py
+5
-0
No files found.
CHANGELOG.md
View file @
49846247
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
-
Fixed installation of Poetry git dependencies with a build system.
-
Fixed installation of Poetry git dependencies with a build system.
-
Fixed possible errors when resolving dependencies for specific packages.
-
Fixed possible errors when resolving dependencies for specific packages.
-
Fixed handling of Python versions compatibility.
## [0.12.4] - 2018-10-21
## [0.12.4] - 2018-10-21
...
...
poetry/console/commands/env_command.py
View file @
49846247
...
@@ -8,10 +8,27 @@ class EnvCommand(Command):
...
@@ -8,10 +8,27 @@ class EnvCommand(Command):
super
(
EnvCommand
,
self
)
.
__init__
()
super
(
EnvCommand
,
self
)
.
__init__
()
def
initialize
(
self
,
i
,
o
):
def
initialize
(
self
,
i
,
o
):
from
poetry.semver
import
parse_constraint
from
poetry.utils.env
import
Env
from
poetry.utils.env
import
Env
super
(
EnvCommand
,
self
)
.
initialize
(
i
,
o
)
super
(
EnvCommand
,
self
)
.
initialize
(
i
,
o
)
# Checking compatibility of the current environment with
# the python dependency specified in pyproject.toml
current_env
=
Env
.
get
()
supported_python
=
self
.
poetry
.
package
.
python_constraint
current_python
=
parse_constraint
(
"."
.
join
(
str
(
v
)
for
v
in
current_env
.
version_info
[:
3
])
)
if
not
supported_python
.
allows
(
current_python
):
raise
RuntimeError
(
"The current Python version ({}) is not supported by the project ({})
\n
"
"Please activate a compatible Python version."
.
format
(
current_python
,
self
.
poetry
.
package
.
python_versions
)
)
self
.
_env
=
Env
.
create_venv
(
self
.
_env
=
Env
.
create_venv
(
o
,
self
.
poetry
.
package
.
name
,
cwd
=
self
.
poetry
.
file
.
parent
o
,
self
.
poetry
.
package
.
name
,
cwd
=
self
.
poetry
.
file
.
parent
)
)
...
...
poetry/console/commands/init.py
View file @
49846247
...
@@ -37,6 +37,7 @@ The <info>init</info> command creates a basic <comment>pyproject.toml</> file in
...
@@ -37,6 +37,7 @@ The <info>init</info> command creates a basic <comment>pyproject.toml</> file in
def
handle
(
self
):
def
handle
(
self
):
from
poetry.layouts
import
layout
from
poetry.layouts
import
layout
from
poetry.utils._compat
import
Path
from
poetry.utils._compat
import
Path
from
poetry.utils.env
import
Env
from
poetry.vcs.git
import
GitConfig
from
poetry.vcs.git
import
GitConfig
if
(
Path
.
cwd
()
/
"pyproject.toml"
)
.
exists
():
if
(
Path
.
cwd
()
/
"pyproject.toml"
)
.
exists
():
...
@@ -101,7 +102,16 @@ The <info>init</info> command creates a basic <comment>pyproject.toml</> file in
...
@@ -101,7 +102,16 @@ The <info>init</info> command creates a basic <comment>pyproject.toml</> file in
question
.
validator
=
self
.
_validate_license
question
.
validator
=
self
.
_validate_license
license
=
self
.
ask
(
question
)
license
=
self
.
ask
(
question
)
question
=
self
.
create_question
(
"Compatible Python versions [*]: "
,
default
=
"*"
)
current_env
=
Env
.
get
()
default_python
=
"^{}"
.
format
(
"."
.
join
(
str
(
v
)
for
v
in
current_env
.
version_info
[:
2
])
)
question
=
self
.
create_question
(
"Compatible Python versions [<comment>{}</comment>]: "
.
format
(
default_python
),
default
=
default_python
,
)
python
=
self
.
ask
(
question
)
python
=
self
.
ask
(
question
)
self
.
line
(
""
)
self
.
line
(
""
)
...
...
poetry/console/commands/new.py
View file @
49846247
...
@@ -14,6 +14,7 @@ class NewCommand(Command):
...
@@ -14,6 +14,7 @@ class NewCommand(Command):
def
handle
(
self
):
def
handle
(
self
):
from
poetry.layouts
import
layout
from
poetry.layouts
import
layout
from
poetry.utils._compat
import
Path
from
poetry.utils._compat
import
Path
from
poetry.utils.env
import
Env
from
poetry.vcs.git
import
GitConfig
from
poetry.vcs.git
import
GitConfig
if
self
.
option
(
"src"
):
if
self
.
option
(
"src"
):
...
@@ -44,7 +45,17 @@ class NewCommand(Command):
...
@@ -44,7 +45,17 @@ class NewCommand(Command):
if
author_email
:
if
author_email
:
author
+=
" <{}>"
.
format
(
author_email
)
author
+=
" <{}>"
.
format
(
author_email
)
layout_
=
layout_
(
name
,
"0.1.0"
,
author
=
author
,
readme_format
=
readme_format
)
current_env
=
Env
.
get
()
default_python
=
"^{}"
.
format
(
"."
.
join
(
str
(
v
)
for
v
in
current_env
.
version_info
[:
2
])
)
layout_
=
layout_
(
name
,
"0.1.0"
,
author
=
author
,
readme_format
=
readme_format
,
python
=
default_python
,
)
layout_
.
create
(
path
)
layout_
.
create
(
path
)
self
.
line
(
self
.
line
(
...
...
poetry/utils/env.py
View file @
49846247
...
@@ -516,3 +516,19 @@ class NullEnv(SystemEnv):
...
@@ -516,3 +516,19 @@ class NullEnv(SystemEnv):
def
_bin
(
self
,
bin
):
def
_bin
(
self
,
bin
):
return
bin
return
bin
class
MockEnv
(
NullEnv
):
def
__init__
(
self
,
version_info
=
(
3
,
7
,
0
),
python_implementation
=
"cpython"
):
super
(
MockEnv
,
self
)
.
__init__
()
self
.
_version_info
=
version_info
self
.
_python_implementation
=
python_implementation
@property
def
version_info
(
self
):
# type: () -> Tuple[int]
return
self
.
_version_info
@property
def
python_implementation
(
self
):
# type: () -> str
return
self
.
_python_implementation
tests/console/commands/test_init.py
View file @
49846247
...
@@ -148,7 +148,7 @@ description = ""
...
@@ -148,7 +148,7 @@ description = ""
authors = ["Your Name <you@example.com>"]
authors = ["Your Name <you@example.com>"]
[tool.poetry.dependencies]
[tool.poetry.dependencies]
python = "
*
"
python = "
^3.7
"
[tool.poetry.dev-dependencies]
[tool.poetry.dev-dependencies]
"""
"""
...
...
tests/console/conftest.py
View file @
49846247
...
@@ -17,6 +17,8 @@ from poetry.packages import Locker as BaseLocker
...
@@ -17,6 +17,8 @@ from poetry.packages import Locker as BaseLocker
from
poetry.repositories
import
Pool
from
poetry.repositories
import
Pool
from
poetry.repositories
import
Repository
from
poetry.repositories
import
Repository
from
poetry.utils._compat
import
Path
from
poetry.utils._compat
import
Path
from
poetry.utils.env
import
Env
from
poetry.utils.env
import
MockEnv
from
poetry.utils.toml_file
import
TomlFile
from
poetry.utils.toml_file
import
TomlFile
...
@@ -48,6 +50,8 @@ def installed():
...
@@ -48,6 +50,8 @@ def installed():
@pytest.fixture
(
autouse
=
True
)
@pytest.fixture
(
autouse
=
True
)
def
setup
(
mocker
,
installer
,
installed
):
def
setup
(
mocker
,
installer
,
installed
):
Env
.
_env
=
MockEnv
()
# Set Installer's installer
# Set Installer's installer
p
=
mocker
.
patch
(
"poetry.installation.installer.Installer._get_installer"
)
p
=
mocker
.
patch
(
"poetry.installation.installer.Installer._get_installer"
)
p
.
return_value
=
installer
p
.
return_value
=
installer
...
@@ -74,6 +78,7 @@ def setup(mocker, installer, installed):
...
@@ -74,6 +78,7 @@ def setup(mocker, installer, installed):
os
.
environ
.
clear
()
os
.
environ
.
clear
()
os
.
environ
.
update
(
environ
)
os
.
environ
.
update
(
environ
)
Env
.
_env
=
None
class
Application
(
BaseApplication
):
class
Application
(
BaseApplication
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment