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
7ab06997
Unverified
Commit
7ab06997
authored
Jun 04, 2022
by
kroeschl
Committed by
GitHub
Jun 04, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: poetry install --all-extras (#5452)
Co-authored-by: Bjorn Neergaard <bjorn@neersighted.com>
parent
3353dfd9
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
1 deletions
+68
-1
docs/cli.md
+4
-1
docs/pyproject.md
+6
-0
src/poetry/console/commands/install.py
+12
-0
tests/console/commands/test_install.py
+46
-0
No files found.
docs/cli.md
View file @
7ab06997
...
@@ -190,11 +190,13 @@ poetry install --only dev
...
@@ -190,11 +190,13 @@ poetry install --only dev
```
```
You can also specify the extras you want installed
You can also specify the extras you want installed
by passing the
`-E|--extras`
option (See
[
Extras
](
{{
<
relref
"
pyproject
#
extras
"
>
}}) for more info)
by passing the
`-E|--extras`
option (See
[
Extras
](
{{
<
relref
"
pyproject
#
extras
"
>
}}) for more info).
Pass
`--all-extras`
to install all defined extras for a project.
```
bash
```
bash
poetry install
--extras
"mysql pgsql"
poetry install
--extras
"mysql pgsql"
poetry install
-E
mysql
-E
pgsql
poetry install
-E
mysql
-E
pgsql
poetry install
--all-extras
```
```
By default
`poetry`
will install your project's package every time you run
`install`
:
By default
`poetry`
will install your project's package every time you run
`install`
:
...
@@ -227,6 +229,7 @@ option is used.
...
@@ -227,6 +229,7 @@ option is used.
*
`--no-root`
: Do not install the root package (your project).
*
`--no-root`
: Do not install the root package (your project).
*
`--dry-run`
: Output the operations but do not execute anything (implicitly enables --verbose).
*
`--dry-run`
: Output the operations but do not execute anything (implicitly enables --verbose).
*
`--extras (-E)`
: Features to install (multiple values allowed).
*
`--extras (-E)`
: Features to install (multiple values allowed).
*
`--all-extras`
: Install all extra features (conflicts with --extras).
*
`--no-dev`
: Do not install dev dependencies. (
**Deprecated**
)
*
`--no-dev`
: Do not install dev dependencies. (
**Deprecated**
)
*
`--dev-only`
: Only install dev dependencies. (
**Deprecated**
)
*
`--dev-only`
: Only install dev dependencies. (
**Deprecated**
)
*
`--remove-untracked`
: Remove dependencies not presented in the lock file. (
**Deprecated**
)
*
`--remove-untracked`
: Remove dependencies not presented in the lock file. (
**Deprecated**
)
...
...
docs/pyproject.md
View file @
7ab06997
...
@@ -384,6 +384,12 @@ poetry install --extras "mysql pgsql"
...
@@ -384,6 +384,12 @@ poetry install --extras "mysql pgsql"
poetry install
-E
mysql
-E
pgsql
poetry install
-E
mysql
-E
pgsql
```
```
Or, you can install all extras with the
`--all-extras`
option:
```
bash
poetry install
--all-extras
```
When installing or specifying Poetry-built packages, the extras defined in this section can be activated
When installing or specifying Poetry-built packages, the extras defined in this section can be activated
as described in
[
PEP 508
](
https://www.python.org/dev/peps/pep-0508/#extras
)
.
as described in
[
PEP 508
](
https://www.python.org/dev/peps/pep-0508/#extras
)
.
...
...
src/poetry/console/commands/install.py
View file @
7ab06997
...
@@ -52,6 +52,7 @@ class InstallCommand(InstallerCommand):
...
@@ -52,6 +52,7 @@ class InstallCommand(InstallerCommand):
flag
=
False
,
flag
=
False
,
multiple
=
True
,
multiple
=
True
,
),
),
option
(
"all-extras"
,
None
,
"Install all extra dependencies."
),
]
]
help
=
"""The <info>install</info> command reads the <comment>poetry.lock</> file from
help
=
"""The <info>install</info> command reads the <comment>poetry.lock</> file from
...
@@ -79,6 +80,17 @@ dependencies and not including the current project, run the command with the
...
@@ -79,6 +80,17 @@ dependencies and not including the current project, run the command with the
self
.
poetry
.
config
.
get
(
"experimental.new-installer"
,
False
)
self
.
poetry
.
config
.
get
(
"experimental.new-installer"
,
False
)
)
)
if
self
.
option
(
"extras"
)
and
self
.
option
(
"all-extras"
):
self
.
line_error
(
"<error>You cannot specify explicit"
" `<fg=yellow;options=bold>--extras</>` while installing"
" using `<fg=yellow;options=bold>--all-extras</>`.</error>"
)
return
1
if
self
.
option
(
"all-extras"
):
extras
=
list
(
self
.
poetry
.
package
.
extras
.
keys
())
else
:
extras
=
[]
extras
=
[]
for
extra
in
self
.
option
(
"extras"
,
[]):
for
extra
in
self
.
option
(
"extras"
,
[]):
if
" "
in
extra
:
if
" "
in
extra
:
...
...
tests/console/commands/test_install.py
View file @
7ab06997
...
@@ -30,6 +30,8 @@ readme = "README.rst"
...
@@ -30,6 +30,8 @@ readme = "README.rst"
[tool.poetry.dependencies]
[tool.poetry.dependencies]
python = "~2.7 || ^3.4"
python = "~2.7 || ^3.4"
fizz = { version = "^1.0", optional = true }
buzz = { version = "^2.0", optional = true }
[tool.poetry.group.foo.dependencies]
[tool.poetry.group.foo.dependencies]
foo = "^1.0"
foo = "^1.0"
...
@@ -48,6 +50,10 @@ optional = true
...
@@ -48,6 +50,10 @@ optional = true
[tool.poetry.group.bam.dependencies]
[tool.poetry.group.bam.dependencies]
bam = "^1.4"
bam = "^1.4"
[tool.poetry.extras]
extras_a = [ "fizz" ]
extras_b = [ "buzz" ]
"""
"""
...
@@ -132,3 +138,43 @@ def test_sync_option_is_passed_to_the_installer(
...
@@ -132,3 +138,43 @@ def test_sync_option_is_passed_to_the_installer(
tester
.
execute
(
"--sync"
)
tester
.
execute
(
"--sync"
)
assert
tester
.
command
.
installer
.
_requires_synchronization
assert
tester
.
command
.
installer
.
_requires_synchronization
def
test_no_all_extras_doesnt_populate_installer
(
tester
:
CommandTester
,
mocker
:
MockerFixture
):
"""
Not passing --all-extras means the installer doesn't see any extras.
"""
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
1
)
tester
.
execute
()
assert
not
tester
.
command
.
installer
.
_extras
def
test_all_extras_populates_installer
(
tester
:
CommandTester
,
mocker
:
MockerFixture
):
"""
The --all-extras option results in extras passed to the installer.
"""
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
1
)
tester
.
execute
(
"--all-extras"
)
assert
tester
.
command
.
installer
.
_extras
==
[
"extras_a"
,
"extras_b"
]
def
test_extras_conlicts_all_extras
(
tester
:
CommandTester
,
mocker
:
MockerFixture
):
"""
The --extras doesn't make sense with --all-extras.
"""
mocker
.
patch
.
object
(
tester
.
command
.
installer
,
"run"
,
return_value
=
0
)
tester
.
execute
(
"--extras foo --all-extras"
)
assert
tester
.
status_code
==
1
assert
(
tester
.
io
.
fetch_error
()
==
"You cannot specify explicit `--extras` while installing using"
" `--all-extras`.
\n
"
)
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