diff options
author | ctolentino8 <ctolentino8@bloomberg.net> | 2018-09-24 10:32:45 +0100 |
---|---|---|
committer | Chandan Singh <chandan.devel@gmail.com> | 2018-11-02 16:41:54 +0000 |
commit | de59ebdbf755ca65c7c9d389204f6ce508f84e7e (patch) | |
tree | 546e291d2d52dee54120eab0a7045452484fd652 /buildstream | |
parent | 7f79b9ce511f1421851821bf2928352ba569b8f0 (diff) | |
download | buildstream-de59ebdbf755ca65c7c9d389204f6ce508f84e7e.tar.gz |
plugins/sources/pip.py: Accomodate characters '-','.','_' for packages
Diffstat (limited to 'buildstream')
-rw-r--r-- | buildstream/plugins/sources/pip.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/buildstream/plugins/sources/pip.py b/buildstream/plugins/sources/pip.py index 6ba3a0407..2ef401620 100644 --- a/buildstream/plugins/sources/pip.py +++ b/buildstream/plugins/sources/pip.py @@ -96,7 +96,7 @@ _PYTHON_VERSIONS = [ # Names of source distribution archives must be of the form # '%{package-name}-%{version}.%{extension}'. _SDIST_RE = re.compile( - r'^([a-zA-Z0-9]+?)-(.+).(?:tar|tar.bz2|tar.gz|tar.xz|tar.Z|zip)$', + r'^([\w.-]+?)-((?:[\d.]+){2,})\.(?:tar|tar.bz2|tar.gz|tar.xz|tar.Z|zip)$', re.IGNORECASE) @@ -225,12 +225,27 @@ class PipSource(Source): def _parse_sdist_names(self, basedir): reqs = [] for f in os.listdir(basedir): - pkg_match = _SDIST_RE.match(f) - if pkg_match: - reqs.append(pkg_match.groups()) + pkg = _match_package_name(f) + if pkg is not None: + reqs.append(pkg) return sorted(reqs) +# Extract the package name and version of a source distribution +# +# Args: +# filename (str): Filename of the source distribution +# +# Returns: +# (tuple): A tuple of (package_name, version) +# +def _match_package_name(filename): + pkg_match = _SDIST_RE.match(filename) + if pkg_match is None: + return None + return pkg_match.groups() + + def setup(): return PipSource |