Commit 4b3caa7e by Sébastien Eustace

Improve support for private repositories.

No longer use pip-tools.
parent 22013468
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
- Improved the `show` command to make it easier to check if packages are properly installed. - Improved the `show` command to make it easier to check if packages are properly installed.
- The `script` command has been deprecated, use `run` instead. - The `script` command has been deprecated, use `run` instead.
- Improved support for private repositories.
- Expanded version constraints now keep the original version's precision. - Expanded version constraints now keep the original version's precision.
### Fixed ### Fixed
......
...@@ -21,6 +21,14 @@ from .vcs_dependency import VCSDependency ...@@ -21,6 +21,14 @@ from .vcs_dependency import VCSDependency
def dependency_from_pep_508(name): def dependency_from_pep_508(name):
# Removing comments
parts = name.split('#', 1)
name = parts[0].strip()
if len(parts) > 1:
rest = parts[1]
if ';' in rest:
name += ';' + rest.split(';', 1)[1]
req = Requirement(name) req = Requirement(name)
if req.marker: if req.marker:
......
...@@ -58,13 +58,8 @@ class GenericConstraint(BaseConstraint): ...@@ -58,13 +58,8 @@ class GenericConstraint(BaseConstraint):
return self._version return self._version
def matches(self, provider): def matches(self, provider):
if not isinstance(provider, (GenericConstraint, EmptyConstraint)): if not isinstance(provider, GenericConstraint):
raise ValueError( return provider.matches(self)
'Generic constraints can only be compared with each other'
)
if isinstance(provider, EmptyConstraint):
return True
is_equal_op = self.OP_EQ is self._operator is_equal_op = self.OP_EQ is self._operator
is_non_equal_op = self.OP_NE is self._operator is_non_equal_op = self.OP_NE is self._operator
......
...@@ -286,7 +286,6 @@ class PyPiRepository(Repository): ...@@ -286,7 +286,6 @@ class PyPiRepository(Repository):
if ( if (
self._fallback self._fallback
and data['requires_dist'] is None and data['requires_dist'] is None
and not data['requires_python']
): ):
self._log( self._log(
'No dependencies found, downloading archives', 'No dependencies found, downloading archives',
...@@ -328,6 +327,8 @@ class PyPiRepository(Repository): ...@@ -328,6 +327,8 @@ class PyPiRepository(Repository):
info = self._get_info_from_urls(urls) info = self._get_info_from_urls(urls)
data['requires_dist'] = info['requires_dist'] data['requires_dist'] = info['requires_dist']
if not data['requires_python']:
data['requires_python'] = info['requires_python'] data['requires_python'] = info['requires_python']
return data return data
...@@ -351,6 +352,7 @@ class PyPiRepository(Repository): ...@@ -351,6 +352,7 @@ class PyPiRepository(Repository):
def _get_info_from_wheel(self, url def _get_info_from_wheel(self, url
): # type: (str) -> Dict[str, Union[str, List, None]] ): # type: (str) -> Dict[str, Union[str, List, None]]
info = { info = {
'summary': '',
'requires_python': None, 'requires_python': None,
'requires_dist': None, 'requires_dist': None,
} }
...@@ -368,6 +370,9 @@ class PyPiRepository(Repository): ...@@ -368,6 +370,9 @@ class PyPiRepository(Repository):
# Assume none # Assume none
return info return info
if meta.summary:
info['summary'] = meta.summary or ''
info['requires_python'] = meta.requires_python info['requires_python'] = meta.requires_python
if meta.requires_dist: if meta.requires_dist:
...@@ -378,6 +383,7 @@ class PyPiRepository(Repository): ...@@ -378,6 +383,7 @@ class PyPiRepository(Repository):
def _get_info_from_sdist(self, url def _get_info_from_sdist(self, url
): # type: (str) -> Dict[str, Union[str, List, None]] ): # type: (str) -> Dict[str, Union[str, List, None]]
info = { info = {
'summary': '',
'requires_python': None, 'requires_python': None,
'requires_dist': None, 'requires_dist': None,
} }
...@@ -390,6 +396,9 @@ class PyPiRepository(Repository): ...@@ -390,6 +396,9 @@ class PyPiRepository(Repository):
try: try:
meta = pkginfo.SDist(str(filepath)) meta = pkginfo.SDist(str(filepath))
if meta.summary:
info['summary'] = meta.summary
if meta.requires_python: if meta.requires_python:
info['requires_python'] = meta.requires_python info['requires_python'] = meta.requires_python
...@@ -427,7 +436,7 @@ class PyPiRepository(Repository): ...@@ -427,7 +436,7 @@ class PyPiRepository(Repository):
unpacked = Path(temp_dir) / 'unpacked' unpacked = Path(temp_dir) / 'unpacked'
sdist_dir = unpacked / Path(filename).name.rstrip('.tar.gz') sdist_dir = unpacked / Path(filename).name.rstrip('.tar.gz')
# Checking for .egg-info # Checking for .egg-info at root
eggs = list(sdist_dir.glob('*.egg-info')) eggs = list(sdist_dir.glob('*.egg-info'))
if eggs: if eggs:
egg_info = eggs[0] egg_info = eggs[0]
...@@ -439,6 +448,18 @@ class PyPiRepository(Repository): ...@@ -439,6 +448,18 @@ class PyPiRepository(Repository):
return info return info
# Searching for .egg-info in sub directories
eggs = list(sdist_dir.glob('**/*.egg-info'))
if eggs:
egg_info = eggs[0]
requires = egg_info / 'requires.txt'
if requires.exists():
with requires.open() as f:
info['requires_dist'] = parse_requires(f.read())
return info
# Still nothing, assume no dependencies # Still nothing, assume no dependencies
# We could probably get them by executing # We could probably get them by executing
# python setup.py egg-info but I don't feel # python setup.py egg-info but I don't feel
......
...@@ -417,5 +417,5 @@ class Version(VersionRange): ...@@ -417,5 +417,5 @@ class Version(VersionRange):
(self.major, (self.major,
self.minor, self.minor,
self.patch, self.patch,
'.'.join(self.prerelease), '.'.join(str(p) for p in self.prerelease),
'.'.join(self.build))) '.'.join(str(p) for p in self.build)))
...@@ -27,13 +27,13 @@ cleo = "^0.6.6" ...@@ -27,13 +27,13 @@ cleo = "^0.6.6"
requests = "^2.18" requests = "^2.18"
toml = "^0.9" toml = "^0.9"
cachy = "^0.2" cachy = "^0.2"
pip-tools = "^2.0"
requests-toolbelt = "^0.8.0" requests-toolbelt = "^0.8.0"
jsonschema = "^2.6" jsonschema = "^2.6"
pyrsistent = "^0.14.2" pyrsistent = "^0.14.2"
pyparsing = "^2.2" pyparsing = "^2.2"
cachecontrol = { version = "^0.12.4", extras = ["filecache"] } cachecontrol = { version = "^0.12.4", extras = ["filecache"] }
pkginfo = "^1.4" pkginfo = "^1.4"
html5lib = "^1.0"
# The typing module is not in the stdlib in Python 2.7 and 3.4 # The typing module is not in the stdlib in Python 2.7 and 3.4
typing = { version = "^3.6", python = "~2.7 || ~3.4" } typing = { version = "^3.6", python = "~2.7 || ~3.4" }
......
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