Skip to content

Commit

Permalink
Merge pull request #5 from sarugaku/bugfixes
Browse files Browse the repository at this point in the history
Bugfixes
  • Loading branch information
techalchemy authored Jun 3, 2018
2 parents cb872b3 + 0268155 commit fa2f10a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
4 changes: 4 additions & 0 deletions HISTORY.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.0.8
- Resolve names in setup.py files if available.
- Fix a bug with populating Link objects when there is no URI.
- Properly unquote URIs which have been urlencoded.
0.0.7
- Parse wheel names.
0.0.6
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def run(self):
description="A tool for converting between pip-style and pipfile requirements.",
long_description=long_description,
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Topic :: Software Development :: Build Tools",
Expand All @@ -97,7 +97,7 @@ def run(self):
keywords='pipfile requirements.txt pip requirementslib',
author='Dan Ryan',
author_email='dan@danryan.co',
url='https://github.com/techalchemy/requirementslib',
url='https://github.com/sarugaku/requirementslib',
license='MIT',
package_dir={"": "src"},
packages=find_packages(
Expand Down
2 changes: 1 addition & 1 deletion src/requirementslib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding=utf-8 -*-
__version__ = "0.0.7.dev0"
__version__ = "0.0.8"

from .requirements import Requirement
32 changes: 23 additions & 9 deletions src/requirementslib/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
from pathlib2 import Path

try:
from urllib.parse import urlparse
from urllib.parse import urlparse, unquote
except ImportError:
from urlparse import urlparse
from urlparse import urlparse, unquote

HASH_STRING = " --hash={0}"

Expand Down Expand Up @@ -298,10 +298,23 @@ def get_name(self):
loc = self.path or self.uri
if loc:
self._uri_scheme = "path" if self.path else "uri"
name = None
setup_path = Path(self.path) / 'setup.py'
if self._uri_scheme != "uri" and self.path and setup_path.exists():
from distutils.core import run_setup
try:
dist = run_setup(setup_path.as_posix(), stop_after='init')
except FileNotFoundError:
dist = None
else:
dist_name = dist.get_name()
name = dist_name if dist_name != 'UNKNOWN' else None
hashed_loc = hashlib.sha256(loc.encode("utf-8")).hexdigest()
hash_fragment = hashed_loc[-7:]
self._has_hashed_name = True
return hash_fragment
hashed_name = hashed_loc[-7:]
if not name:
self._has_hashed_name = True
name = hashed_name
return name

@link.default
def get_link(self):
Expand Down Expand Up @@ -359,7 +372,7 @@ def from_line(cls, line):
line = path
else:
_path = Path(line)
link = Link(_path.absolute().as_uri())
link = Link(unquote(_path.absolute().as_uri()))
if _path.is_absolute() or _path.as_posix() == ".":
path = _path.as_posix()
else:
Expand All @@ -382,11 +395,11 @@ def from_pipfile(cls, name, pipfile):
if not uri_key:
abs_path = os.path.abspath(uri)
uri = path_to_url(abs_path) if os.path.exists(abs_path) else None
link = Link(uri) if uri else None
link = Link(unquote(uri)) if uri else None
arg_dict = {
"name": name,
"path": pipfile.get("path"),
"uri": link.url_without_fragment,
"uri": unquote(link.url_without_fragment if link else uri),
"editable": pipfile.get("editable"),
"link": link,
}
Expand Down Expand Up @@ -451,7 +464,8 @@ def get_link(self):

@name.default
def get_name(self):
return self.link.egg_fragment or self.req.name if self.req else ""
return self.link.egg_fragment or self.req.name \
if self.req else super(VCSRequirement, self).get_name()

@property
def vcs_uri(self):
Expand Down

0 comments on commit fa2f10a

Please sign in to comment.