How to use the wheel.install.WheelFile function in wheel

To help you get started, we’ve selected a few wheel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pypa / wheel / tests / test_ranking.py View on Github external
def make_wheel(name, ver, pyver, abi, arch):
    name = WHEELPAT % {'name': name, 'ver': ver, 'pyver': pyver, 'abi': abi, 'arch': arch}
    return WheelFile(name)
github VOLTTRON / volttron / volttrontesting / platform / packaging-tests.py View on Github external
def test_can_extract_package(self):
        wheelhouse = os.path.join(self.tmpdir, 'extract_package')
        expected_install_at = os.path.join(wheelhouse, 'listeneragent-0.1')
        test_wheel_name = 'listeneragent-0.1-py2-none-any.whl'
        wheel_file = os.path.join(self.fixtureDir, test_wheel_name)

        installed_at = extract_package(wheel_file, wheelhouse)

        try:
            self.assertIsNotNone(installed_at)
            self.assertTrue(os.path.isdir(installed_at))
            self.assertEqual(expected_install_at, installed_at)

            # use the wheel file to verify that everything was extracted
            # properly.
            wf = WheelFile(wheel_file)
            self.assertIsNone(wf.verify())

            for o in wf.zipfile.infolist():
                self.assertTrue(
                    os.path.exists(os.path.join(expected_install_at, o.filename)))

            wf.zipfile.close()
        finally:
            shutil.rmtree(installed_at)
            shutil.rmtree(wheelhouse)
    @pytest.mark.xfail(reason="#776 Needs updating")
github pypa / wheel / tests / test_install.py View on Github external
def test_compatibility_tags():
    """Test compatibilty tags are working."""
    wf = WheelFile("package-1.0.0-cp32.cp33-noabi-noarch.whl")
    assert (list(wf.compatibility_tags) ==
            [('cp32', 'noabi', 'noarch'), ('cp33', 'noabi', 'noarch')])
    assert wf.arity == 2

    wf2 = WheelFile("package-1.0.0-1st-cp33-noabi-noarch.whl")
    wf2_info = wf2.parsed_filename.groupdict()
    assert wf2_info['build'] == '1st', wf2_info
github pypa / wheel / tests / test_install.py View on Github external
def test_compatibility_tags():
    """Test compatibilty tags are working."""
    wf = WheelFile("package-1.0.0-cp32.cp33-noabi-noarch.whl")
    assert (list(wf.compatibility_tags) ==
            [('cp32', 'noabi', 'noarch'), ('cp33', 'noabi', 'noarch')])
    assert wf.arity == 2

    wf2 = WheelFile("package-1.0.0-1st-cp33-noabi-noarch.whl")
    wf2_info = wf2.parsed_filename.groupdict()
    assert wf2_info['build'] == '1st', wf2_info
github scikit-build / cmake-python-distributions / scripts / convert_to_generic_platform_wheel.py View on Github external
def _convert_to_generic_platform_wheel(wheel_ctx):
    """Switch to generic python tags and remove ABI tags from a wheel

    Convert implementation specific python tags to their generic equivalent and
    remove all ABI tags from wheel_ctx's filename and ``WHEEL`` file.

    Parameters
    ----------
    wheel_ctx : InWheelCtx
        An open wheel context
    """

    abi_tags = ['none']

    wf = WheelFile(wheel_ctx.in_wheel)
    info_fname = _get_wheelinfo_name(wf)
    info = read_pkg_info(info_fname)

    # Check what tags we have
    if wheel_ctx.out_wheel is not None:
        out_dir = dirname(wheel_ctx.out_wheel)
        wheel_fname = basename(wheel_ctx.out_wheel)
    else:
        out_dir = '.'
        wheel_fname = basename(wheel_ctx.in_wheel)

    # Update wheel filename
    fparts = wf.parsed_filename.groupdict()
    original_platform_tags = fparts['plat'].split('.')

    original_abi_tags = fparts['abi'].split('.')
github VOLTTRON / volttron / volttron / platform / packaging.py View on Github external
:return: The folder where the wheel was extracted.

    """
    real_dir = install_dir

    # Only include the uuid if the caller wants it.
    if include_uuid:
        if specific_uuid == None:
            real_dir = os.path.join(real_dir, str(uuid.uuid4()))
        else:
            real_dir = os.path.join(real_dir, specific_uuid)

    if not os.path.isdir(real_dir):
        os.makedirs(real_dir)

    wf = WheelFile(wheel_file)
    namever = wf.parsed_filename.group('namever')
    destination = os.path.join(real_dir, namever)
    sys.stderr.write("Unpacking to: %s\n" % (destination))
    wf.zipfile.extractall(destination)
    wf.zipfile.close()
    return destination
github VOLTTRON / volttron / volttron / platform / packages.py View on Github external
try:
    import simplejson as jsonapi
except ImportError:
    import json as jsonapi

from wheel.install import WheelFile
from wheel.util import native, open_for_csv


__all__ = ('BasePackageVerifier', 'VolttronPackageWheelFileNoSign',
           'ZipPackageVerifier', 'UnpackedPackage')

_log = logging.getLogger(__name__)

#TODO: Make this this base class and have auth extend it
class VolttronPackageWheelFileNoSign(WheelFile):
    AGENT_DATA_ZIP = 'agent_data.zip'

    def __init__(self,
                 filename,**kwargs):

        super(VolttronPackageWheelFileNoSign, self).__init__(filename, 
                                                             **kwargs)

    def contains(self, path):
        '''Does the wheel contain the specified path?'''

        for x in self.zipfile.filelist:
            if x.filename == path:
                return True
        return False
github pantsbuild / pants / src / python / pants / init / plugin_resolver.py View on Github external
  @classmethod
  def _install_wheel(cls, wheel_path, install_dir):
    safe_mkdir(install_dir, clean=True)
    WheelFile(wheel_path).install(force=True,
                                  overrides={
                                    'purelib': install_dir,
                                    'headers': os.path.join(install_dir, 'headers'),
                                    'scripts': os.path.join(install_dir, 'bin'),
                                    'platlib': install_dir,
                                    'data': install_dir
                                  })
github pantsbuild / pants / src / python / pants / init / plugin_resolver.py View on Github external
def _install_wheel(cls, wheel_path, install_dir):
    safe_mkdir(install_dir, clean=True)
    WheelFile(wheel_path).install(force=True,
                                  overrides={
                                    'purelib': install_dir,
                                    'headers': os.path.join(install_dir, 'headers'),
                                    'scripts': os.path.join(install_dir, 'bin'),
                                    'platlib': install_dir,
                                    'data': install_dir
                                  })