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
5d229dba
Unverified
Commit
5d229dba
authored
Jun 24, 2020
by
finswimmer
Committed by
GitHub
Jun 24, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2561 from fcoclavero/init-python-version-option
Python version option (`--python`) for `init` script.
parents
6795b88c
c468052d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
0 deletions
+42
-0
docs/docs/cli.md
+1
-0
poetry/console/commands/init.py
+3
-0
tests/console/commands/test_init.py
+38
-0
No files found.
docs/docs/cli.md
View file @
5d229dba
...
...
@@ -81,6 +81,7 @@ poetry init
*
`--name`
: Name of the package.
*
`--description`
: Description of the package.
*
`--author`
: Author of the package.
*
`--python`
Compatible Python versions.
*
`--dependency`
: Package to require with a version constraint. Should be in format
`foo:1.0.0`
.
*
`--dev-dependency`
: Development requirements, see
`--require`
.
...
...
poetry/console/commands/init.py
View file @
5d229dba
...
...
@@ -32,6 +32,7 @@ class InitCommand(Command):
option
(
"name"
,
None
,
"Name of the package."
,
flag
=
False
),
option
(
"description"
,
None
,
"Description of the package."
,
flag
=
False
),
option
(
"author"
,
None
,
"Author name of the package."
,
flag
=
False
),
option
(
"python"
,
None
,
"Compatible Python versions."
,
flag
=
False
),
option
(
"dependency"
,
None
,
...
...
@@ -126,6 +127,8 @@ The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the
question
.
set_validator
(
self
.
_validate_license
)
license
=
self
.
ask
(
question
)
python
=
self
.
option
(
"python"
)
if
not
python
:
current_env
=
SystemEnv
(
Path
(
sys
.
executable
))
default_python
=
"^{}"
.
format
(
"."
.
join
(
str
(
v
)
for
v
in
current_env
.
version_info
[:
2
])
...
...
tests/console/commands/test_init.py
View file @
5d229dba
...
...
@@ -445,3 +445,41 @@ pytest = "^3.6.0"
"""
assert
expected
in
tester
.
io
.
fetch_output
()
def
test_python_option
(
app
,
mocker
,
poetry
):
command
=
app
.
find
(
"init"
)
command
.
_pool
=
poetry
.
pool
mocker
.
patch
(
"poetry.utils._compat.Path.open"
)
p
=
mocker
.
patch
(
"poetry.utils._compat.Path.cwd"
)
p
.
return_value
=
Path
(
__file__
)
tester
=
CommandTester
(
command
)
inputs
=
[
"my-package"
,
# Package name
"1.2.3"
,
# Version
"This is a description"
,
# Description
"n"
,
# Author
"MIT"
,
# License
"n"
,
# Interactive packages
"n"
,
# Interactive dev packages
"
\n
"
,
# Generate
]
tester
.
execute
(
"--python '~2.7 || ^3.6'"
,
inputs
=
"
\n
"
.
join
(
inputs
))
expected
=
"""
\
[tool.poetry]
name = "my-package"
version = "1.2.3"
description = "This is a description"
authors = ["Your Name <you@example.com>"]
license = "MIT"
[tool.poetry.dependencies]
python = "~2.7 || ^3.6"
[tool.poetry.dev-dependencies]
"""
assert
expected
in
tester
.
io
.
fetch_output
()
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