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
9ab25813
Unverified
Commit
9ab25813
authored
Mar 20, 2020
by
Sébastien Eustace
Committed by
GitHub
Mar 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge master into develop (#2206)" (#2208)
This reverts commit
bf12e427
.
parent
bf12e427
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
19 additions
and
197 deletions
+19
-197
.pre-commit-config.yaml
+2
-2
CHANGELOG.md
+1
-0
docs/docs/cli.md
+0
-12
poetry/console/commands/add.py
+1
-12
poetry/console/commands/cache/cache.py
+1
-3
poetry/console/commands/cache/clear.py
+5
-3
poetry/console/commands/cache/list.py
+0
-21
poetry/console/commands/init.py
+4
-7
poetry/locations.py
+0
-3
poetry/repositories/legacy_repository.py
+2
-2
poetry/repositories/pypi_repository.py
+2
-2
poetry/version/version_selector.py
+1
-2
tests/console/commands/test_add.py
+0
-68
tests/console/commands/test_cache.py
+0
-60
No files found.
.pre-commit-config.yaml
View file @
9ab25813
...
@@ -9,8 +9,8 @@ repos:
...
@@ -9,8 +9,8 @@ repos:
hooks
:
hooks
:
-
id
:
flake8
-
id
:
flake8
-
repo
:
https://github.com/
timothycrosley/
isort
-
repo
:
https://github.com/
pre-commit/mirrors-
isort
rev
:
4.3.21
rev
:
v
4.3.21
hooks
:
hooks
:
-
id
:
isort
-
id
:
isort
additional_dependencies
:
[
toml
]
additional_dependencies
:
[
toml
]
...
...
CHANGELOG.md
View file @
9ab25813
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
-
Fixed an error when parsing some git URLs (
[
#2018
](
https://github.com/python-poetry/poetry/pull/2018
)
).
-
Fixed an error when parsing some git URLs (
[
#2018
](
https://github.com/python-poetry/poetry/pull/2018
)
).
## [1.0.3] - 2020-01-31
## [1.0.3] - 2020-01-31
### Fixed
### Fixed
...
...
docs/docs/cli.md
View file @
9ab25813
...
@@ -452,15 +452,3 @@ The `env` command regroups sub commands to interact with the virtualenvs
...
@@ -452,15 +452,3 @@ The `env` command regroups sub commands to interact with the virtualenvs
associated with a specific project.
associated with a specific project.
See
[
Managing environments
](
./managing-environments.md
)
for more information about these commands.
See
[
Managing environments
](
./managing-environments.md
)
for more information about these commands.
## cache
The `
cache
` command regroups sub commands to interact with Poetry's cache.
### cache list
The `
cache list
` command lists Poetry's available caches.
```bash
poetry cache list
``
`
poetry/console/commands/add.py
View file @
9ab25813
...
@@ -33,12 +33,6 @@ class AddCommand(EnvCommand, InitCommand):
...
@@ -33,12 +33,6 @@ class AddCommand(EnvCommand, InitCommand):
"Platforms for which the dependency must be installed."
,
"Platforms for which the dependency must be installed."
,
flag
=
False
,
flag
=
False
,
),
),
option
(
"source"
,
None
,
"Name of the source to use to install the package."
,
flag
=
False
,
),
option
(
"allow-prereleases"
,
None
,
"Accept prereleases."
),
option
(
"allow-prereleases"
,
None
,
"Accept prereleases."
),
option
(
option
(
"dry-run"
,
"dry-run"
,
...
@@ -92,9 +86,7 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
...
@@ -92,9 +86,7 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
raise
ValueError
(
"Package {} is already present"
.
format
(
name
))
raise
ValueError
(
"Package {} is already present"
.
format
(
name
))
requirements
=
self
.
_determine_requirements
(
requirements
=
self
.
_determine_requirements
(
packages
,
packages
,
allow_prereleases
=
self
.
option
(
"allow-prereleases"
)
allow_prereleases
=
self
.
option
(
"allow-prereleases"
),
source
=
self
.
option
(
"source"
),
)
)
for
_constraint
in
requirements
:
for
_constraint
in
requirements
:
...
@@ -131,9 +123,6 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
...
@@ -131,9 +123,6 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
if
self
.
option
(
"platform"
):
if
self
.
option
(
"platform"
):
constraint
[
"platform"
]
=
self
.
option
(
"platform"
)
constraint
[
"platform"
]
=
self
.
option
(
"platform"
)
if
self
.
option
(
"source"
):
constraint
[
"source"
]
=
self
.
option
(
"source"
)
if
len
(
constraint
)
==
1
and
"version"
in
constraint
:
if
len
(
constraint
)
==
1
and
"version"
in
constraint
:
constraint
=
constraint
[
"version"
]
constraint
=
constraint
[
"version"
]
...
...
poetry/console/commands/cache/cache.py
View file @
9ab25813
from
poetry.console.commands.cache.list
import
CacheListCommand
from
..command
import
Command
from
..command
import
Command
from
.clear
import
CacheClearCommand
from
.clear
import
CacheClearCommand
...
@@ -9,7 +7,7 @@ class CacheCommand(Command):
...
@@ -9,7 +7,7 @@ class CacheCommand(Command):
name
=
"cache"
name
=
"cache"
description
=
"Interact with Poetry's cache"
description
=
"Interact with Poetry's cache"
commands
=
[
CacheClearCommand
()
,
CacheListCommand
()
]
commands
=
[
CacheClearCommand
()]
def
handle
(
self
):
def
handle
(
self
):
return
self
.
call
(
"help"
,
self
.
_config
.
name
)
return
self
.
call
(
"help"
,
self
.
_config
.
name
)
poetry/console/commands/cache/clear.py
View file @
9ab25813
...
@@ -16,17 +16,19 @@ class CacheClearCommand(Command):
...
@@ -16,17 +16,19 @@ class CacheClearCommand(Command):
def
handle
(
self
):
def
handle
(
self
):
from
cachy
import
CacheManager
from
cachy
import
CacheManager
from
poetry.locations
import
REPOSITORY_CACHE_DIR
from
poetry.locations
import
CACHE_DIR
from
poetry.utils._compat
import
Path
cache
=
self
.
argument
(
"cache"
)
cache
=
self
.
argument
(
"cache"
)
parts
=
cache
.
split
(
":"
)
parts
=
cache
.
split
(
":"
)
root
=
parts
[
0
]
root
=
parts
[
0
]
cache_dir
=
REPOSITORY_CACHE_DIR
/
root
base_cache
=
Path
(
CACHE_DIR
)
/
"cache"
/
"repositories"
cache_dir
=
base_cache
/
root
try
:
try
:
cache_dir
.
relative_to
(
REPOSITORY_CACHE_DIR
)
cache_dir
.
relative_to
(
base_cache
)
except
ValueError
:
except
ValueError
:
raise
ValueError
(
"{} is not a valid repository cache"
.
format
(
root
))
raise
ValueError
(
"{} is not a valid repository cache"
.
format
(
root
))
...
...
poetry/console/commands/cache/list.py
deleted
100644 → 0
View file @
bf12e427
import
os
from
..command
import
Command
class
CacheListCommand
(
Command
):
name
=
"list"
description
=
"List Poetry's caches."
def
handle
(
self
):
from
poetry.locations
import
REPOSITORY_CACHE_DIR
if
os
.
path
.
exists
(
str
(
REPOSITORY_CACHE_DIR
)):
caches
=
list
(
sorted
(
REPOSITORY_CACHE_DIR
.
iterdir
()))
if
caches
:
for
cache
in
caches
:
self
.
line
(
"<info>{}</>"
.
format
(
cache
.
name
))
return
0
self
.
line
(
"<warning>No caches found</>"
)
poetry/console/commands/init.py
View file @
9ab25813
...
@@ -203,7 +203,7 @@ The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the
...
@@ -203,7 +203,7 @@ The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the
f
.
write
(
content
)
f
.
write
(
content
)
def
_determine_requirements
(
def
_determine_requirements
(
self
,
requires
,
allow_prereleases
=
False
,
source
=
None
self
,
requires
,
allow_prereleases
=
False
):
# type: (List[str], bool) -> List[Dict[str, str]]
):
# type: (List[str], bool) -> List[Dict[str, str]]
if
not
requires
:
if
not
requires
:
requires
=
[]
requires
=
[]
...
@@ -299,9 +299,7 @@ The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the
...
@@ -299,9 +299,7 @@ The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the
elif
"version"
not
in
requirement
:
elif
"version"
not
in
requirement
:
# determine the best version automatically
# determine the best version automatically
name
,
version
=
self
.
_find_best_version_for_package
(
name
,
version
=
self
.
_find_best_version_for_package
(
requirement
[
"name"
],
requirement
[
"name"
],
allow_prereleases
=
allow_prereleases
allow_prereleases
=
allow_prereleases
,
source
=
source
,
)
)
requirement
[
"version"
]
=
version
requirement
[
"version"
]
=
version
requirement
[
"name"
]
=
name
requirement
[
"name"
]
=
name
...
@@ -316,7 +314,6 @@ The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the
...
@@ -316,7 +314,6 @@ The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the
requirement
[
"name"
],
requirement
[
"name"
],
requirement
[
"version"
],
requirement
[
"version"
],
allow_prereleases
=
allow_prereleases
,
allow_prereleases
=
allow_prereleases
,
source
=
source
,
)
)
requirement
[
"name"
]
=
name
requirement
[
"name"
]
=
name
...
@@ -326,13 +323,13 @@ The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the
...
@@ -326,13 +323,13 @@ The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the
return
result
return
result
def
_find_best_version_for_package
(
def
_find_best_version_for_package
(
self
,
name
,
required_version
=
None
,
allow_prereleases
=
False
,
source
=
None
self
,
name
,
required_version
=
None
,
allow_prereleases
=
False
):
# type: (...) -> Tuple[str, str]
):
# type: (...) -> Tuple[str, str]
from
poetry.version.version_selector
import
VersionSelector
from
poetry.version.version_selector
import
VersionSelector
selector
=
VersionSelector
(
self
.
_get_pool
())
selector
=
VersionSelector
(
self
.
_get_pool
())
package
=
selector
.
find_best_candidate
(
package
=
selector
.
find_best_candidate
(
name
,
required_version
,
allow_prereleases
=
allow_prereleases
,
source
=
source
name
,
required_version
,
allow_prereleases
=
allow_prereleases
)
)
if
not
package
:
if
not
package
:
...
...
poetry/locations.py
View file @
9ab25813
from
.utils._compat
import
Path
from
.utils.appdirs
import
user_cache_dir
from
.utils.appdirs
import
user_cache_dir
from
.utils.appdirs
import
user_config_dir
from
.utils.appdirs
import
user_config_dir
CACHE_DIR
=
user_cache_dir
(
"pypoetry"
)
CACHE_DIR
=
user_cache_dir
(
"pypoetry"
)
CONFIG_DIR
=
user_config_dir
(
"pypoetry"
)
CONFIG_DIR
=
user_config_dir
(
"pypoetry"
)
REPOSITORY_CACHE_DIR
=
Path
(
CACHE_DIR
)
/
"cache"
/
"repositories"
poetry/repositories/legacy_repository.py
View file @
9ab25813
...
@@ -15,7 +15,7 @@ from cachy import CacheManager
...
@@ -15,7 +15,7 @@ from cachy import CacheManager
import
poetry.packages
import
poetry.packages
from
poetry.locations
import
REPOSITORY_
CACHE_DIR
from
poetry.locations
import
CACHE_DIR
from
poetry.packages
import
Package
from
poetry.packages
import
Package
from
poetry.packages
import
dependency_from_pep_508
from
poetry.packages
import
dependency_from_pep_508
from
poetry.packages.utils.link
import
Link
from
poetry.packages.utils.link
import
Link
...
@@ -174,7 +174,7 @@ class LegacyRepository(PyPiRepository):
...
@@ -174,7 +174,7 @@ class LegacyRepository(PyPiRepository):
self
.
_client_cert
=
client_cert
self
.
_client_cert
=
client_cert
self
.
_cert
=
cert
self
.
_cert
=
cert
self
.
_inspector
=
Inspector
()
self
.
_inspector
=
Inspector
()
self
.
_cache_dir
=
REPOSITORY_CACHE_DIR
/
name
self
.
_cache_dir
=
Path
(
CACHE_DIR
)
/
"cache"
/
"repositories"
/
name
self
.
_cache
=
CacheManager
(
self
.
_cache
=
CacheManager
(
{
{
"default"
:
"releases"
,
"default"
:
"releases"
,
...
...
poetry/repositories/pypi_repository.py
View file @
9ab25813
...
@@ -15,7 +15,7 @@ from requests import get
...
@@ -15,7 +15,7 @@ from requests import get
from
requests
import
session
from
requests
import
session
from
requests.exceptions
import
TooManyRedirects
from
requests.exceptions
import
TooManyRedirects
from
poetry.locations
import
REPOSITORY_
CACHE_DIR
from
poetry.locations
import
CACHE_DIR
from
poetry.packages
import
Package
from
poetry.packages
import
Package
from
poetry.packages
import
dependency_from_pep_508
from
poetry.packages
import
dependency_from_pep_508
from
poetry.packages.utils.link
import
Link
from
poetry.packages.utils.link
import
Link
...
@@ -57,7 +57,7 @@ class PyPiRepository(RemoteRepository):
...
@@ -57,7 +57,7 @@ class PyPiRepository(RemoteRepository):
self
.
_disable_cache
=
disable_cache
self
.
_disable_cache
=
disable_cache
self
.
_fallback
=
fallback
self
.
_fallback
=
fallback
release_cache_dir
=
REPOSITORY_CACHE_DIR
/
"pypi"
release_cache_dir
=
Path
(
CACHE_DIR
)
/
"cache"
/
"repositories"
/
"pypi"
self
.
_cache
=
CacheManager
(
self
.
_cache
=
CacheManager
(
{
{
"default"
:
"releases"
,
"default"
:
"releases"
,
...
...
poetry/version/version_selector.py
View file @
9ab25813
...
@@ -15,7 +15,6 @@ class VersionSelector(object):
...
@@ -15,7 +15,6 @@ class VersionSelector(object):
package_name
,
# type: str
package_name
,
# type: str
target_package_version
=
None
,
# type: Union[str, None]
target_package_version
=
None
,
# type: Union[str, None]
allow_prereleases
=
False
,
# type: bool
allow_prereleases
=
False
,
# type: bool
source
=
None
,
# type: str
):
# type: (...) -> Union[Package, bool]
):
# type: (...) -> Union[Package, bool]
"""
"""
Given a package name and optional version,
Given a package name and optional version,
...
@@ -27,7 +26,7 @@ class VersionSelector(object):
...
@@ -27,7 +26,7 @@ class VersionSelector(object):
constraint
=
parse_constraint
(
"*"
)
constraint
=
parse_constraint
(
"*"
)
candidates
=
self
.
_pool
.
find_packages
(
candidates
=
self
.
_pool
.
find_packages
(
package_name
,
constraint
,
allow_prereleases
=
True
,
repository
=
source
package_name
,
constraint
,
allow_prereleases
=
True
)
)
only_prereleases
=
all
([
c
.
version
.
is_prerelease
()
for
c
in
candidates
])
only_prereleases
=
all
([
c
.
version
.
is_prerelease
()
for
c
in
candidates
])
...
...
tests/console/commands/test_add.py
View file @
9ab25813
...
@@ -4,8 +4,6 @@ import pytest
...
@@ -4,8 +4,6 @@ import pytest
from
cleo.testers
import
CommandTester
from
cleo.testers
import
CommandTester
from
poetry.repositories.legacy_repository
import
LegacyRepository
from
poetry.semver
import
Version
from
poetry.utils._compat
import
Path
from
poetry.utils._compat
import
Path
from
tests.helpers
import
get_dependency
from
tests.helpers
import
get_dependency
from
tests.helpers
import
get_package
from
tests.helpers
import
get_package
...
@@ -636,72 +634,6 @@ Package operations: 1 install, 0 updates, 0 removals
...
@@ -636,72 +634,6 @@ Package operations: 1 install, 0 updates, 0 removals
}
}
def
test_add_constraint_with_source
(
app
,
poetry
,
installer
):
repo
=
LegacyRepository
(
name
=
"my-index"
,
url
=
"https://my-index.fake"
)
repo
.
add_package
(
get_package
(
"cachy"
,
"0.2.0"
))
repo
.
_cache
.
store
(
"matches"
)
.
put
(
"cachy:0.2.0"
,
[
Version
.
parse
(
"0.2.0"
)],
5
)
poetry
.
pool
.
add_repository
(
repo
)
command
=
app
.
find
(
"add"
)
tester
=
CommandTester
(
command
)
tester
.
execute
(
"cachy=0.2.0 --source my-index"
)
expected
=
"""
\
Updating dependencies
Resolving dependencies...
Writing lock file
Package operations: 1 install, 0 updates, 0 removals
- Installing cachy (0.2.0)
"""
assert
expected
==
tester
.
io
.
fetch_output
()
assert
len
(
installer
.
installs
)
==
1
content
=
app
.
poetry
.
file
.
read
()[
"tool"
][
"poetry"
]
assert
"cachy"
in
content
[
"dependencies"
]
assert
content
[
"dependencies"
][
"cachy"
]
==
{
"version"
:
"0.2.0"
,
"source"
:
"my-index"
,
}
def
test_add_constraint_with_source_that_does_not_exist
(
app
):
command
=
app
.
find
(
"add"
)
tester
=
CommandTester
(
command
)
with
pytest
.
raises
(
ValueError
)
as
e
:
tester
.
execute
(
"foo --source i-dont-exist"
)
assert
'Repository "i-dont-exist" does not exist.'
==
str
(
e
.
value
)
def
test_add_constraint_not_found_with_source
(
app
,
poetry
,
mocker
):
repo
=
LegacyRepository
(
name
=
"my-index"
,
url
=
"https://my-index.fake"
)
mocker
.
patch
.
object
(
repo
,
"find_packages"
,
return_value
=
[])
poetry
.
pool
.
add_repository
(
repo
)
pypi
=
poetry
.
pool
.
repositories
[
0
]
pypi
.
add_package
(
get_package
(
"cachy"
,
"0.2.0"
))
command
=
app
.
find
(
"add"
)
tester
=
CommandTester
(
command
)
with
pytest
.
raises
(
ValueError
)
as
e
:
tester
.
execute
(
"cachy --source my-index"
)
assert
"Could not find a matching version of package cachy"
==
str
(
e
.
value
)
def
test_add_to_section_that_does_no_exist_yet
(
app
,
repo
,
installer
):
def
test_add_to_section_that_does_no_exist_yet
(
app
,
repo
,
installer
):
command
=
app
.
find
(
"add"
)
command
=
app
.
find
(
"add"
)
tester
=
CommandTester
(
command
)
tester
=
CommandTester
(
command
)
...
...
tests/console/commands/test_cache.py
deleted
100644 → 0
View file @
bf12e427
import
uuid
import
pytest
from
cleo.testers
import
CommandTester
@pytest.fixture
def
repository_cache_dir
(
monkeypatch
,
tmpdir
):
import
poetry.locations
from
poetry.utils._compat
import
Path
path
=
Path
(
str
(
tmpdir
))
monkeypatch
.
setattr
(
poetry
.
locations
,
"REPOSITORY_CACHE_DIR"
,
path
)
return
path
@pytest.fixture
def
repository_one
():
return
"01_{}"
.
format
(
uuid
.
uuid4
())
@pytest.fixture
def
repository_two
():
return
"02_{}"
.
format
(
uuid
.
uuid4
())
@pytest.fixture
def
mock_caches
(
repository_cache_dir
,
repository_one
,
repository_two
):
(
repository_cache_dir
/
repository_one
)
.
mkdir
()
(
repository_cache_dir
/
repository_two
)
.
mkdir
()
def
test_cache_list
(
app
,
mock_caches
,
repository_one
,
repository_two
):
command
=
app
.
find
(
"cache list"
)
tester
=
CommandTester
(
command
)
tester
.
execute
()
expected
=
"""
\
{}
{}
"""
.
format
(
repository_one
,
repository_two
)
assert
expected
==
tester
.
io
.
fetch_output
()
def
test_cache_list_empty
(
app
,
repository_cache_dir
):
command
=
app
.
find
(
"cache list"
)
tester
=
CommandTester
(
command
)
tester
.
execute
()
expected
=
"""
\
No caches found
"""
assert
expected
==
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