Python pkg_resources.safe_version() Examples

The following are 30 code examples of pkg_resources.safe_version(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pkg_resources , or try the search function .
Example #1
Source File: utils.py    From wheelhouse-uploader with MIT License 6 votes vote down vote up
def _parse_exe_filename(basename, project_name=None, return_tags=True):
    remainder, pythontag = basename.rsplit('-', 1)
    if not pythontag.startswith('py'):
        # There was no python tag with this file, therefore it must be
        # python version independent
        pythontag = 'py' + '.'.join(str(x) for x in sys.version_info[:2])
        remainder = basename
    name_and_version, platform = remainder.rsplit('.', 1)
    distname, version = name_and_version.rsplit('-', 1)
    distname = _wheel_escape(distname)
    if project_name is not None and distname != _wheel_escape(project_name):
        raise ValueError('File %s.exe does not match project name %s'
                         % (basename, project_name))
    pyversion = pythontag[2:]
    if return_tags:
        tags = {
            'python': pythontag.replace('.', ''),
            'platform': _wheel_escape(platform),
        }
        return (distname, safe_version(version), pyversion, 'bdist_wininst',
                tags)
    return (distname, safe_version(version), pyversion, 'bdist_wininst') 
Example #2
Source File: cmd.py    From wheelhouse-uploader with MIT License 6 votes vote down vote up
def run(self):
        metadata = self.distribution.metadata
        project_name = metadata.get_name()
        version = safe_version(metadata.get_version())
        print("Collecting artifacts for %s==%s in 'dist' folder:" %
              (project_name, version))
        dist_files = []
        for filename in os.listdir('dist'):
            try:
                _, file_version, pyversion, command = parse_filename(
                    filename, project_name=project_name)
                if file_version != version:
                    continue
            except ValueError:
                continue
            filepath = os.path.join('dist', filename)
            dist_files.append((command, pyversion, filepath))

        if not dist_files:
            raise DistutilsOptionError(
                "No file collected from the 'dist' folder")

        for command, pyversion, filepath in dist_files:
            self.upload_file(command, pyversion, filepath) 
Example #3
Source File: dist.py    From datafari with Apache License 2.0 5 votes vote down vote up
def patch_missing_pkg_info(self, attrs):
        # Fake up a replacement for the data that would normally come from
        # PKG-INFO, but which might not yet be built if this is a fresh
        # checkout.
        #
        if not attrs or 'name' not in attrs or 'version' not in attrs:
            return
        key = pkg_resources.safe_name(str(attrs['name'])).lower()
        dist = pkg_resources.working_set.by_key.get(key)
        if dist is not None and not dist.has_metadata('PKG-INFO'):
            dist._version = pkg_resources.safe_version(str(attrs['version']))
            self._patched_dist = dist 
Example #4
Source File: dist.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def patch_missing_pkg_info(self, attrs):
        # Fake up a replacement for the data that would normally come from
        # PKG-INFO, but which might not yet be built if this is a fresh
        # checkout.
        #
        if not attrs or 'name' not in attrs or 'version' not in attrs:
            return
        key = pkg_resources.safe_name(str(attrs['name'])).lower()
        dist = pkg_resources.working_set.by_key.get(key)
        if dist is not None and not dist.has_metadata('PKG-INFO'):
            dist._version = pkg_resources.safe_version(str(attrs['version']))
            self._patched_dist = dist 
Example #5
Source File: dist.py    From syntheticmass with Apache License 2.0 5 votes vote down vote up
def patch_missing_pkg_info(self, attrs):
        # Fake up a replacement for the data that would normally come from
        # PKG-INFO, but which might not yet be built if this is a fresh
        # checkout.
        #
        if not attrs or 'name' not in attrs or 'version' not in attrs:
            return
        key = pkg_resources.safe_name(str(attrs['name'])).lower()
        dist = pkg_resources.working_set.by_key.get(key)
        if dist is not None and not dist.has_metadata('PKG-INFO'):
            dist._version = pkg_resources.safe_version(str(attrs['version']))
            self._patched_dist = dist 
Example #6
Source File: dist.py    From aws-kube-codesuite with Apache License 2.0 5 votes vote down vote up
def patch_missing_pkg_info(self, attrs):
        # Fake up a replacement for the data that would normally come from
        # PKG-INFO, but which might not yet be built if this is a fresh
        # checkout.
        #
        if not attrs or 'name' not in attrs or 'version' not in attrs:
            return
        key = pkg_resources.safe_name(str(attrs['name'])).lower()
        dist = pkg_resources.working_set.by_key.get(key)
        if dist is not None and not dist.has_metadata('PKG-INFO'):
            dist._version = pkg_resources.safe_version(str(attrs['version']))
            self._patched_dist = dist 
Example #7
Source File: dist.py    From android_universal with MIT License 5 votes vote down vote up
def patch_missing_pkg_info(self, attrs):
        # Fake up a replacement for the data that would normally come from
        # PKG-INFO, but which might not yet be built if this is a fresh
        # checkout.
        #
        if not attrs or 'name' not in attrs or 'version' not in attrs:
            return
        key = pkg_resources.safe_name(str(attrs['name'])).lower()
        dist = pkg_resources.working_set.by_key.get(key)
        if dist is not None and not dist.has_metadata('PKG-INFO'):
            dist._version = pkg_resources.safe_version(str(attrs['version']))
            self._patched_dist = dist 
Example #8
Source File: bdist_wheel.py    From android_universal with MIT License 5 votes vote down vote up
def safer_version(version):
    return safe_version(version).replace('-', '_') 
Example #9
Source File: dist.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 5 votes vote down vote up
def patch_missing_pkg_info(self, attrs):
        # Fake up a replacement for the data that would normally come from
        # PKG-INFO, but which might not yet be built if this is a fresh
        # checkout.
        #
        if not attrs or 'name' not in attrs or 'version' not in attrs:
            return
        key = pkg_resources.safe_name(str(attrs['name'])).lower()
        dist = pkg_resources.working_set.by_key.get(key)
        if dist is not None and not dist.has_metadata('PKG-INFO'):
            dist._version = pkg_resources.safe_version(str(attrs['version']))
            self._patched_dist = dist 
Example #10
Source File: dist.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def patch_missing_pkg_info(self, attrs):
        # Fake up a replacement for the data that would normally come from
        # PKG-INFO, but which might not yet be built if this is a fresh
        # checkout.
        #
        if not attrs or 'name' not in attrs or 'version' not in attrs:
            return
        key = pkg_resources.safe_name(str(attrs['name'])).lower()
        dist = pkg_resources.working_set.by_key.get(key)
        if dist is not None and not dist.has_metadata('PKG-INFO'):
            dist._version = pkg_resources.safe_version(str(attrs['version']))
            self._patched_dist = dist 
Example #11
Source File: dist.py    From Flask with Apache License 2.0 5 votes vote down vote up
def patch_missing_pkg_info(self, attrs):
        # Fake up a replacement for the data that would normally come from
        # PKG-INFO, but which might not yet be built if this is a fresh
        # checkout.
        #
        if not attrs or 'name' not in attrs or 'version' not in attrs:
            return
        key = pkg_resources.safe_name(str(attrs['name'])).lower()
        dist = pkg_resources.working_set.by_key.get(key)
        if dist is not None and not dist.has_metadata('PKG-INFO'):
            dist._version = pkg_resources.safe_version(str(attrs['version']))
            self._patched_dist = dist 
Example #12
Source File: dist.py    From Flask with Apache License 2.0 5 votes vote down vote up
def patch_missing_pkg_info(self, attrs):
        # Fake up a replacement for the data that would normally come from
        # PKG-INFO, but which might not yet be built if this is a fresh
        # checkout.
        #
        if not attrs or 'name' not in attrs or 'version' not in attrs:
            return
        key = pkg_resources.safe_name(str(attrs['name'])).lower()
        dist = pkg_resources.working_set.by_key.get(key)
        if dist is not None and not dist.has_metadata('PKG-INFO'):
            dist._version = pkg_resources.safe_version(str(attrs['version']))
            self._patched_dist = dist 
Example #13
Source File: bdist_wheel.py    From keras-lambda with MIT License 5 votes vote down vote up
def safer_version(version):
    return safe_version(version).replace('-', '_') 
Example #14
Source File: dist.py    From Hands-On-Deep-Learning-for-Games with MIT License 5 votes vote down vote up
def patch_missing_pkg_info(self, attrs):
        # Fake up a replacement for the data that would normally come from
        # PKG-INFO, but which might not yet be built if this is a fresh
        # checkout.
        #
        if not attrs or 'name' not in attrs or 'version' not in attrs:
            return
        key = pkg_resources.safe_name(str(attrs['name'])).lower()
        dist = pkg_resources.working_set.by_key.get(key)
        if dist is not None and not dist.has_metadata('PKG-INFO'):
            dist._version = pkg_resources.safe_version(str(attrs['version']))
            self._patched_dist = dist 
Example #15
Source File: bdist_wheel.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def safer_version(version):
    return safe_version(version).replace('-', '_') 
Example #16
Source File: dist.py    From setuptools with MIT License 5 votes vote down vote up
def patch_missing_pkg_info(self, attrs):
        # Fake up a replacement for the data that would normally come from
        # PKG-INFO, but which might not yet be built if this is a fresh
        # checkout.
        #
        if not attrs or 'name' not in attrs or 'version' not in attrs:
            return
        key = pkg_resources.safe_name(str(attrs['name'])).lower()
        dist = pkg_resources.working_set.by_key.get(key)
        if dist is not None and not dist.has_metadata('PKG-INFO'):
            dist._version = pkg_resources.safe_version(str(attrs['version']))
            self._patched_dist = dist 
Example #17
Source File: check_requirements.py    From requirements-tools with MIT License 5 votes vote down vote up
def parse_requirement(req):
    dumb_parse = pkg_resources.Requirement.parse(req)
    if dumb_parse.extras:
        extras = '[{}]'.format(','.join(dumb_parse.extras))
    else:
        extras = ''
    return pkg_resources.Requirement.parse(
        dumb_parse.project_name + extras + ','.join(
            operator + pkg_resources.safe_version(version)
            for operator, version in dumb_parse.specs
        ),
    ) 
Example #18
Source File: dist.py    From PhonePi_SampleServer with MIT License 5 votes vote down vote up
def patch_missing_pkg_info(self, attrs):
        # Fake up a replacement for the data that would normally come from
        # PKG-INFO, but which might not yet be built if this is a fresh
        # checkout.
        #
        if not attrs or 'name' not in attrs or 'version' not in attrs:
            return
        key = pkg_resources.safe_name(str(attrs['name'])).lower()
        dist = pkg_resources.working_set.by_key.get(key)
        if dist is not None and not dist.has_metadata('PKG-INFO'):
            dist._version = pkg_resources.safe_version(str(attrs['version']))
            self._patched_dist = dist 
Example #19
Source File: bdist_wheel.py    From Ansible with MIT License 5 votes vote down vote up
def safer_version(version):
    return safe_version(version).replace('-', '_') 
Example #20
Source File: dist.py    From Ansible with MIT License 5 votes vote down vote up
def patch_missing_pkg_info(self, attrs):
        # Fake up a replacement for the data that would normally come from
        # PKG-INFO, but which might not yet be built if this is a fresh
        # checkout.
        #
        if not attrs or 'name' not in attrs or 'version' not in attrs:
            return
        key = pkg_resources.safe_name(str(attrs['name'])).lower()
        dist = pkg_resources.working_set.by_key.get(key)
        if dist is not None and not dist.has_metadata('PKG-INFO'):
            dist._version = pkg_resources.safe_version(str(attrs['version']))
            self._patched_dist = dist 
Example #21
Source File: bdist_wheel.py    From ImageFusion with MIT License 5 votes vote down vote up
def safer_version(version):
    return safe_version(version).replace('-', '_') 
Example #22
Source File: dist.py    From ImageFusion with MIT License 5 votes vote down vote up
def patch_missing_pkg_info(self, attrs):
        # Fake up a replacement for the data that would normally come from
        # PKG-INFO, but which might not yet be built if this is a fresh
        # checkout.
        #
        if not attrs or 'name' not in attrs or 'version' not in attrs:
            return
        key = pkg_resources.safe_name(str(attrs['name'])).lower()
        dist = pkg_resources.working_set.by_key.get(key)
        if dist is not None and not dist.has_metadata('PKG-INFO'):
            dist._version = pkg_resources.safe_version(str(attrs['version']))
            self._patched_dist = dist 
Example #23
Source File: bdist_wheel.py    From rules_pip with MIT License 5 votes vote down vote up
def safer_version(version):
    return safe_version(version).replace('-', '_') 
Example #24
Source File: dist.py    From rules_pip with MIT License 5 votes vote down vote up
def patch_missing_pkg_info(self, attrs):
        # Fake up a replacement for the data that would normally come from
        # PKG-INFO, but which might not yet be built if this is a fresh
        # checkout.
        #
        if not attrs or 'name' not in attrs or 'version' not in attrs:
            return
        key = pkg_resources.safe_name(str(attrs['name'])).lower()
        dist = pkg_resources.working_set.by_key.get(key)
        if dist is not None and not dist.has_metadata('PKG-INFO'):
            dist._version = pkg_resources.safe_version(str(attrs['version']))
            self._patched_dist = dist 
Example #25
Source File: bdist_wheel.py    From planespotter with MIT License 5 votes vote down vote up
def safer_version(version):
    return safe_version(version).replace('-', '_') 
Example #26
Source File: dist.py    From planespotter with MIT License 5 votes vote down vote up
def patch_missing_pkg_info(self, attrs):
        # Fake up a replacement for the data that would normally come from
        # PKG-INFO, but which might not yet be built if this is a fresh
        # checkout.
        #
        if not attrs or 'name' not in attrs or 'version' not in attrs:
            return
        key = pkg_resources.safe_name(str(attrs['name'])).lower()
        dist = pkg_resources.working_set.by_key.get(key)
        if dist is not None and not dist.has_metadata('PKG-INFO'):
            dist._version = pkg_resources.safe_version(str(attrs['version']))
            self._patched_dist = dist 
Example #27
Source File: bdist_wheel.py    From Flask-P2P with MIT License 5 votes vote down vote up
def safer_version(version):
    return safe_version(version).replace('-', '_') 
Example #28
Source File: dist.py    From Flask-P2P with MIT License 5 votes vote down vote up
def patch_missing_pkg_info(self, attrs):
        # Fake up a replacement for the data that would normally come from
        # PKG-INFO, but which might not yet be built if this is a fresh
        # checkout.
        #
        if not attrs or 'name' not in attrs or 'version' not in attrs:
            return
        key = pkg_resources.safe_name(str(attrs['name'])).lower()
        dist = pkg_resources.working_set.by_key.get(key)
        if dist is not None and not dist.has_metadata('PKG-INFO'):
            dist._version = pkg_resources.safe_version(str(attrs['version']))
            self._patched_dist = dist 
Example #29
Source File: bdist_wheel.py    From Financial-Portfolio-Flask with MIT License 5 votes vote down vote up
def safer_version(version):
    return safe_version(version).replace('-', '_') 
Example #30
Source File: dist.py    From Financial-Portfolio-Flask with MIT License 5 votes vote down vote up
def patch_missing_pkg_info(self, attrs):
        # Fake up a replacement for the data that would normally come from
        # PKG-INFO, but which might not yet be built if this is a fresh
        # checkout.
        #
        if not attrs or 'name' not in attrs or 'version' not in attrs:
            return
        key = pkg_resources.safe_name(str(attrs['name'])).lower()
        dist = pkg_resources.working_set.by_key.get(key)
        if dist is not None and not dist.has_metadata('PKG-INFO'):
            dist._version = pkg_resources.safe_version(str(attrs['version']))
            self._patched_dist = dist