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
86036944
Commit
86036944
authored
Apr 29, 2022
by
Arun Babu Neelicattu
Committed by
Bjorn Neergaard
May 05, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cli: add global --no-cache option
parent
bd583981
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
7 deletions
+69
-7
docs/cli.md
+2
-0
src/poetry/console/application.py
+12
-1
src/poetry/factory.py
+28
-5
tests/console/commands/plugin/conftest.py
+5
-1
tests/console/test_application.py
+22
-0
No files found.
docs/cli.md
View file @
86036944
...
@@ -27,6 +27,8 @@ then `--help` combined with any of those can give you more information.
...
@@ -27,6 +27,8 @@ then `--help` combined with any of those can give you more information.
*
`--no-ansi`
: Disable ANSI output.
*
`--no-ansi`
: Disable ANSI output.
*
`--version (-V)`
: Display this application version.
*
`--version (-V)`
: Display this application version.
*
`--no-interaction (-n)`
: Do not ask any interactive question.
*
`--no-interaction (-n)`
: Do not ask any interactive question.
*
`--no-plugins`
: Disables plugins.
*
`--no-cache`
: Disables Poetry source caches.
## new
## new
...
...
src/poetry/console/application.py
View file @
86036944
...
@@ -96,6 +96,7 @@ class Application(BaseApplication):
...
@@ -96,6 +96,7 @@ class Application(BaseApplication):
self
.
_poetry
:
Poetry
|
None
=
None
self
.
_poetry
:
Poetry
|
None
=
None
self
.
_io
:
IO
|
None
=
None
self
.
_io
:
IO
|
None
=
None
self
.
_disable_plugins
=
False
self
.
_disable_plugins
=
False
self
.
_disable_cache
=
False
self
.
_plugins_loaded
=
False
self
.
_plugins_loaded
=
False
dispatcher
=
EventDispatcher
()
dispatcher
=
EventDispatcher
()
...
@@ -117,7 +118,10 @@ class Application(BaseApplication):
...
@@ -117,7 +118,10 @@ class Application(BaseApplication):
return
self
.
_poetry
return
self
.
_poetry
self
.
_poetry
=
Factory
()
.
create_poetry
(
self
.
_poetry
=
Factory
()
.
create_poetry
(
Path
.
cwd
(),
io
=
self
.
_io
,
disable_plugins
=
self
.
_disable_plugins
Path
.
cwd
(),
io
=
self
.
_io
,
disable_plugins
=
self
.
_disable_plugins
,
disable_cache
=
self
.
_disable_cache
,
)
)
return
self
.
_poetry
return
self
.
_poetry
...
@@ -168,6 +172,7 @@ class Application(BaseApplication):
...
@@ -168,6 +172,7 @@ class Application(BaseApplication):
def
_run
(
self
,
io
:
IO
)
->
int
:
def
_run
(
self
,
io
:
IO
)
->
int
:
self
.
_disable_plugins
=
io
.
input
.
parameter_option
(
"--no-plugins"
)
self
.
_disable_plugins
=
io
.
input
.
parameter_option
(
"--no-plugins"
)
self
.
_disable_cache
=
io
.
input
.
has_parameter_option
(
"--no-cache"
)
self
.
_load_plugins
(
io
)
self
.
_load_plugins
(
io
)
...
@@ -347,6 +352,12 @@ class Application(BaseApplication):
...
@@ -347,6 +352,12 @@ class Application(BaseApplication):
Option
(
"--no-plugins"
,
flag
=
True
,
description
=
"Disables plugins."
)
Option
(
"--no-plugins"
,
flag
=
True
,
description
=
"Disables plugins."
)
)
)
definition
.
add_option
(
Option
(
"--no-cache"
,
flag
=
True
,
description
=
"Disables Poetry source caches."
)
)
return
definition
return
definition
def
_get_solution_provider_repository
(
self
)
->
SolutionProviderRepository
:
def
_get_solution_provider_repository
(
self
)
->
SolutionProviderRepository
:
...
...
src/poetry/factory.py
View file @
86036944
from
__future__
import
annotations
from
__future__
import
annotations
import
logging
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
TYPE_CHECKING
from
typing
import
TYPE_CHECKING
from
typing
import
Any
from
typing
import
Any
...
@@ -27,6 +29,9 @@ if TYPE_CHECKING:
...
@@ -27,6 +29,9 @@ if TYPE_CHECKING:
from
poetry.repositories.legacy_repository
import
LegacyRepository
from
poetry.repositories.legacy_repository
import
LegacyRepository
logger
=
logging
.
getLogger
(
__name__
)
class
Factory
(
BaseFactory
):
class
Factory
(
BaseFactory
):
"""
"""
Factory class to create various elements needed by Poetry.
Factory class to create various elements needed by Poetry.
...
@@ -37,6 +42,7 @@ class Factory(BaseFactory):
...
@@ -37,6 +42,7 @@ class Factory(BaseFactory):
cwd
:
Path
|
None
=
None
,
cwd
:
Path
|
None
=
None
,
io
:
IO
|
None
=
None
,
io
:
IO
|
None
=
None
,
disable_plugins
:
bool
=
False
,
disable_plugins
:
bool
=
False
,
disable_cache
:
bool
=
False
,
)
->
Poetry
:
)
->
Poetry
:
if
io
is
None
:
if
io
is
None
:
io
=
NullIO
()
io
=
NullIO
()
...
@@ -79,7 +85,11 @@ class Factory(BaseFactory):
...
@@ -79,7 +85,11 @@ class Factory(BaseFactory):
# Configuring sources
# Configuring sources
self
.
configure_sources
(
self
.
configure_sources
(
poetry
,
poetry
.
local_config
.
get
(
"source"
,
[]),
config
,
io
poetry
,
poetry
.
local_config
.
get
(
"source"
,
[]),
config
,
io
,
disable_cache
=
disable_cache
,
)
)
plugin_manager
=
PluginManager
(
Plugin
.
group
,
disable_plugins
=
disable_plugins
)
plugin_manager
=
PluginManager
(
Plugin
.
group
,
disable_plugins
=
disable_plugins
)
...
@@ -127,10 +137,20 @@ class Factory(BaseFactory):
...
@@ -127,10 +137,20 @@ class Factory(BaseFactory):
@classmethod
@classmethod
def
configure_sources
(
def
configure_sources
(
cls
,
poetry
:
Poetry
,
sources
:
list
[
dict
[
str
,
str
]],
config
:
Config
,
io
:
IO
cls
,
poetry
:
Poetry
,
sources
:
list
[
dict
[
str
,
str
]],
config
:
Config
,
io
:
IO
,
disable_cache
:
bool
=
False
,
)
->
None
:
)
->
None
:
if
disable_cache
:
logger
.
debug
(
"Disabling source caches"
)
for
source
in
sources
:
for
source
in
sources
:
repository
=
cls
.
create_legacy_repository
(
source
,
config
)
repository
=
cls
.
create_legacy_repository
(
source
,
config
,
disable_cache
=
disable_cache
)
is_default
=
bool
(
source
.
get
(
"default"
,
False
))
is_default
=
bool
(
source
.
get
(
"default"
,
False
))
is_secondary
=
bool
(
source
.
get
(
"secondary"
,
False
))
is_secondary
=
bool
(
source
.
get
(
"secondary"
,
False
))
if
io
.
is_debug
():
if
io
.
is_debug
():
...
@@ -154,11 +174,13 @@ class Factory(BaseFactory):
...
@@ -154,11 +174,13 @@ class Factory(BaseFactory):
from
poetry.repositories.pypi_repository
import
PyPiRepository
from
poetry.repositories.pypi_repository
import
PyPiRepository
default
=
not
poetry
.
pool
.
has_primary_repositories
()
default
=
not
poetry
.
pool
.
has_primary_repositories
()
poetry
.
pool
.
add_repository
(
PyPiRepository
(),
default
,
not
default
)
poetry
.
pool
.
add_repository
(
PyPiRepository
(
disable_cache
=
disable_cache
),
default
,
not
default
)
@classmethod
@classmethod
def
create_legacy_repository
(
def
create_legacy_repository
(
cls
,
source
:
dict
[
str
,
str
],
auth_config
:
Config
cls
,
source
:
dict
[
str
,
str
],
auth_config
:
Config
,
disable_cache
:
bool
=
False
)
->
LegacyRepository
:
)
->
LegacyRepository
:
from
poetry.repositories.legacy_repository
import
LegacyRepository
from
poetry.repositories.legacy_repository
import
LegacyRepository
from
poetry.utils.helpers
import
get_cert
from
poetry.utils.helpers
import
get_cert
...
@@ -179,6 +201,7 @@ class Factory(BaseFactory):
...
@@ -179,6 +201,7 @@ class Factory(BaseFactory):
config
=
auth_config
,
config
=
auth_config
,
cert
=
get_cert
(
auth_config
,
name
),
cert
=
get_cert
(
auth_config
,
name
),
client_cert
=
get_client_cert
(
auth_config
,
name
),
client_cert
=
get_client_cert
(
auth_config
,
name
),
disable_cache
=
disable_cache
,
)
)
@classmethod
@classmethod
...
...
tests/console/commands/plugin/conftest.py
View file @
86036944
...
@@ -37,7 +37,11 @@ def installed() -> InstalledRepository:
...
@@ -37,7 +37,11 @@ def installed() -> InstalledRepository:
def
configure_sources_factory
(
repo
:
TestRepository
)
->
SourcesFactory
:
def
configure_sources_factory
(
repo
:
TestRepository
)
->
SourcesFactory
:
def
_configure_sources
(
def
_configure_sources
(
poetry
:
Poetry
,
sources
:
Source
,
config
:
Config
,
io
:
IO
poetry
:
Poetry
,
sources
:
Source
,
config
:
Config
,
io
:
IO
,
disable_cache
:
bool
=
False
,
)
->
None
:
)
->
None
:
pool
=
Pool
()
pool
=
Pool
()
pool
.
add_repository
(
repo
)
pool
.
add_repository
(
repo
)
...
...
tests/console/test_application.py
View file @
86036944
...
@@ -4,6 +4,8 @@ import re
...
@@ -4,6 +4,8 @@ import re
from
typing
import
TYPE_CHECKING
from
typing
import
TYPE_CHECKING
import
pytest
from
cleo.testers.application_tester
import
ApplicationTester
from
cleo.testers.application_tester
import
ApplicationTester
from
entrypoints
import
EntryPoint
from
entrypoints
import
EntryPoint
...
@@ -108,3 +110,23 @@ def test_application_execute_plugin_command_with_plugins_disabled(
...
@@ -108,3 +110,23 @@ def test_application_execute_plugin_command_with_plugins_disabled(
assert
tester
.
io
.
fetch_output
()
==
""
assert
tester
.
io
.
fetch_output
()
==
""
assert
tester
.
io
.
fetch_error
()
==
'
\n
The command "foo" does not exist.
\n
'
assert
tester
.
io
.
fetch_error
()
==
'
\n
The command "foo" does not exist.
\n
'
assert
tester
.
status_code
==
1
assert
tester
.
status_code
==
1
@pytest.mark.parametrize
(
"disable_cache"
,
[
True
,
False
])
def
test_application_verify_source_cache_flag
(
disable_cache
:
bool
):
app
=
Application
()
tester
=
ApplicationTester
(
app
)
command
=
"debug info"
if
disable_cache
:
command
=
f
"{command} --no-cache"
assert
not
app
.
_poetry
tester
.
execute
(
command
)
assert
app
.
poetry
.
pool
.
repositories
for
repo
in
app
.
poetry
.
pool
.
repositories
:
assert
repo
.
_disable_cache
==
disable_cache
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