Commit bdcffe5c by Sébastien Eustace

Fix a KeyError when getting package information from sdist

parent a2cf6acd
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
### Fixed ### Fixed
- Fixed reading of some `setup.py` files. - Fixed reading of some `setup.py` files.
- Fixed a `KeyError` when getting information for packages which require reading setup files.
## [0.12.6] - 2018-11-05 ## [0.12.6] - 2018-11-05
......
...@@ -506,7 +506,9 @@ class PyPiRepository(Repository): ...@@ -506,7 +506,9 @@ class PyPiRepository(Repository):
# Still nothing, try reading (without executing it) # Still nothing, try reading (without executing it)
# the setup.py file. # the setup.py file.
try: try:
return self._inspect_sdist_with_setup(sdist_dir) info.update(self._inspect_sdist_with_setup(sdist_dir))
return info
except Exception as e: except Exception as e:
self._log( self._log(
"An error occurred when reading setup.py or setup.cfg: {}".format( "An error occurred when reading setup.py or setup.cfg: {}".format(
......
<!DOCTYPE html>
<html>
<head>
<title>Links for jupyter</title>
</head>
<body>
<h1>Links for jupyter</h1>
<a href="https://files.pythonhosted.org/packages/c9/a9/371d0b8fe37dd231cf4b2cff0a9f0f25e98f3a73c3771742444be27f2944/jupyter-1.0.0.tar.gz#sha256=d9dc4b3318f310e34c82951ea5d6683f67bed7def4b259fafbfe4f1beb1d8e5f">jupyter-1.0.0.tar.gz</a><br/>
</body>
</html>
<!--SERIAL 1673841-->
import pytest import pytest
import shutil
try:
import urllib.parse as urlparse
except ImportError:
import urlparse
from poetry.packages import Dependency
from poetry.repositories.exceptions import PackageNotFound from poetry.repositories.exceptions import PackageNotFound
from poetry.repositories.legacy_repository import LegacyRepository from poetry.repositories.legacy_repository import LegacyRepository
from poetry.repositories.legacy_repository import Page from poetry.repositories.legacy_repository import Page
...@@ -24,6 +31,12 @@ class MockRepository(LegacyRepository): ...@@ -24,6 +31,12 @@ class MockRepository(LegacyRepository):
with fixture.open() as f: with fixture.open() as f:
return Page(self._url + endpoint, f.read(), {}) return Page(self._url + endpoint, f.read(), {})
def _download(self, url, dest):
filename = urlparse.urlparse(url).path.rsplit("/")[-1]
filepath = self.FIXTURES.parent / "pypi.org" / "dists" / filename
shutil.copyfile(str(filepath), dest)
def test_page_relative_links_path_are_correct(): def test_page_relative_links_path_are_correct():
repo = MockRepository() repo = MockRepository()
...@@ -58,3 +71,24 @@ def test_missing_version(mocker): ...@@ -58,3 +71,24 @@ def test_missing_version(mocker):
with pytest.raises(PackageNotFound): with pytest.raises(PackageNotFound):
repo._get_release_info("missing_version", "1.1.0") repo._get_release_info("missing_version", "1.1.0")
def test_get_package_information_fallback_read_setup():
repo = MockRepository()
package = repo.package("jupyter", "1.0.0")
assert package.name == "jupyter"
assert package.version.text == "1.0.0"
assert (
package.description
== "Jupyter metapackage. Install all the Jupyter components in one go."
)
assert package.requires == [
Dependency("notebook", "*"),
Dependency("qtconsole", "*"),
Dependency("jupyter-console", "*"),
Dependency("nbconvert", "*"),
Dependency("ipykernel", "*"),
Dependency("ipywidgets", "*"),
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment