-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for url dependencies (#1260)
- Loading branch information
Showing
20 changed files
with
660 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from poetry.utils._compat import urlparse | ||
|
||
from .dependency import Dependency | ||
|
||
|
||
class URLDependency(Dependency): | ||
def __init__( | ||
self, | ||
name, | ||
url, # type: str | ||
category="main", # type: str | ||
optional=False, # type: bool | ||
): | ||
self._url = url | ||
|
||
parsed = urlparse.urlparse(url) | ||
if not parsed.scheme or not parsed.netloc: | ||
raise ValueError("{} does not seem like a valid url".format(url)) | ||
|
||
super(URLDependency, self).__init__( | ||
name, "*", category=category, optional=optional, allows_prereleases=True | ||
) | ||
|
||
@property | ||
def url(self): | ||
return self._url | ||
|
||
@property | ||
def base_pep_508_name(self): # type: () -> str | ||
requirement = self.pretty_name | ||
|
||
if self.extras: | ||
requirement += "[{}]".format(",".join(self.extras)) | ||
|
||
requirement += " @ {}".format(self._url) | ||
|
||
return requirement | ||
|
||
def is_url(self): # type: () -> bool | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.