Skip to content

Commit

Permalink
Revert "Merge master into develop (#2206)" (#2208)
Browse files Browse the repository at this point in the history
This reverts commit bf12e42.
  • Loading branch information
sdispater authored Mar 20, 2020
1 parent bf12e42 commit 9ab2581
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 197 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ repos:
hooks:
- id: flake8

- repo: https://github.com/timothycrosley/isort
rev: 4.3.21
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
hooks:
- id: isort
additional_dependencies: [toml]
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- Fixed an error when parsing some git URLs ([#2018](https://github.com/python-poetry/poetry/pull/2018)).



## [1.0.3] - 2020-01-31

### Fixed
Expand Down
12 changes: 0 additions & 12 deletions docs/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,15 +452,3 @@ The `env` command regroups sub commands to interact with the virtualenvs
associated with a specific project.

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
```
13 changes: 1 addition & 12 deletions poetry/console/commands/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ class AddCommand(EnvCommand, InitCommand):
"Platforms for which the dependency must be installed.",
flag=False,
),
option(
"source",
None,
"Name of the source to use to install the package.",
flag=False,
),
option("allow-prereleases", None, "Accept prereleases."),
option(
"dry-run",
Expand Down Expand Up @@ -92,9 +86,7 @@ def handle(self):
raise ValueError("Package {} is already present".format(name))

requirements = self._determine_requirements(
packages,
allow_prereleases=self.option("allow-prereleases"),
source=self.option("source"),
packages, allow_prereleases=self.option("allow-prereleases")
)

for _constraint in requirements:
Expand Down Expand Up @@ -131,9 +123,6 @@ def handle(self):
if 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:
constraint = constraint["version"]

Expand Down
4 changes: 1 addition & 3 deletions poetry/console/commands/cache/cache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from poetry.console.commands.cache.list import CacheListCommand

from ..command import Command
from .clear import CacheClearCommand

Expand All @@ -9,7 +7,7 @@ class CacheCommand(Command):
name = "cache"
description = "Interact with Poetry's cache"

commands = [CacheClearCommand(), CacheListCommand()]
commands = [CacheClearCommand()]

def handle(self):
return self.call("help", self._config.name)
8 changes: 5 additions & 3 deletions poetry/console/commands/cache/clear.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ class CacheClearCommand(Command):

def handle(self):
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")

parts = cache.split(":")
root = parts[0]

cache_dir = REPOSITORY_CACHE_DIR / root
base_cache = Path(CACHE_DIR) / "cache" / "repositories"
cache_dir = base_cache / root

try:
cache_dir.relative_to(REPOSITORY_CACHE_DIR)
cache_dir.relative_to(base_cache)
except ValueError:
raise ValueError("{} is not a valid repository cache".format(root))

Expand Down
21 changes: 0 additions & 21 deletions poetry/console/commands/cache/list.py

This file was deleted.

11 changes: 4 additions & 7 deletions poetry/console/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def handle(self):
f.write(content)

def _determine_requirements(
self, requires, allow_prereleases=False, source=None
self, requires, allow_prereleases=False
): # type: (List[str], bool) -> List[Dict[str, str]]
if not requires:
requires = []
Expand Down Expand Up @@ -299,9 +299,7 @@ def _determine_requirements(
elif "version" not in requirement:
# determine the best version automatically
name, version = self._find_best_version_for_package(
requirement["name"],
allow_prereleases=allow_prereleases,
source=source,
requirement["name"], allow_prereleases=allow_prereleases
)
requirement["version"] = version
requirement["name"] = name
Expand All @@ -316,7 +314,6 @@ def _determine_requirements(
requirement["name"],
requirement["version"],
allow_prereleases=allow_prereleases,
source=source,
)

requirement["name"] = name
Expand All @@ -326,13 +323,13 @@ def _determine_requirements(
return result

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]
from poetry.version.version_selector import VersionSelector

selector = VersionSelector(self._get_pool())
package = selector.find_best_candidate(
name, required_version, allow_prereleases=allow_prereleases, source=source
name, required_version, allow_prereleases=allow_prereleases
)

if not package:
Expand Down
3 changes: 0 additions & 3 deletions poetry/locations.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from .utils._compat import Path
from .utils.appdirs import user_cache_dir
from .utils.appdirs import user_config_dir


CACHE_DIR = user_cache_dir("pypoetry")
CONFIG_DIR = user_config_dir("pypoetry")

REPOSITORY_CACHE_DIR = Path(CACHE_DIR) / "cache" / "repositories"
4 changes: 2 additions & 2 deletions poetry/repositories/legacy_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

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 dependency_from_pep_508
from poetry.packages.utils.link import Link
Expand Down Expand Up @@ -174,7 +174,7 @@ def __init__(
self._client_cert = client_cert
self._cert = cert
self._inspector = Inspector()
self._cache_dir = REPOSITORY_CACHE_DIR / name
self._cache_dir = Path(CACHE_DIR) / "cache" / "repositories" / name
self._cache = CacheManager(
{
"default": "releases",
Expand Down
4 changes: 2 additions & 2 deletions poetry/repositories/pypi_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from requests import session
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 dependency_from_pep_508
from poetry.packages.utils.link import Link
Expand Down Expand Up @@ -57,7 +57,7 @@ def __init__(self, url="https://pypi.org/", disable_cache=False, fallback=True):
self._disable_cache = disable_cache
self._fallback = fallback

release_cache_dir = REPOSITORY_CACHE_DIR / "pypi"
release_cache_dir = Path(CACHE_DIR) / "cache" / "repositories" / "pypi"
self._cache = CacheManager(
{
"default": "releases",
Expand Down
3 changes: 1 addition & 2 deletions poetry/version/version_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def find_best_candidate(
package_name, # type: str
target_package_version=None, # type: Union[str, None]
allow_prereleases=False, # type: bool
source=None, # type: str
): # type: (...) -> Union[Package, bool]
"""
Given a package name and optional version,
Expand All @@ -27,7 +26,7 @@ def find_best_candidate(
constraint = parse_constraint("*")

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])

Expand Down
68 changes: 0 additions & 68 deletions tests/console/commands/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

from cleo.testers import CommandTester

from poetry.repositories.legacy_repository import LegacyRepository
from poetry.semver import Version
from poetry.utils._compat import Path
from tests.helpers import get_dependency
from tests.helpers import get_package
Expand Down Expand Up @@ -636,72 +634,6 @@ def test_add_constraint_with_platform(app, repo, installer):
}


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):
command = app.find("add")
tester = CommandTester(command)
Expand Down
60 changes: 0 additions & 60 deletions tests/console/commands/test_cache.py

This file was deleted.

0 comments on commit 9ab2581

Please sign in to comment.