Ejemplo n.º 1
0
    def run(self):
        build_scripts = self.reinitialize_command('build_scripts')
        build_scripts.executable = 'python'

        if not self.skip_build:
            self.run_command('build')

        install = self.reinitialize_command('install',
                                            reinit_subcommands=True)
        install.root = self.bdist_dir
        install.compile = False
        install.skip_build = self.skip_build
        install.warn_dir = False

        # A wheel without setuptools scripts is more cross-platform.
        # Use the (undocumented) `no_ep` option to setuptools'
        # install_scripts command to avoid creating entry point scripts.
        install_scripts = self.reinitialize_command('install_scripts')
        install_scripts.no_ep = True

        # Use a custom scheme for the archive, because we have to decide
        # at installation time which scheme to use.
        for key in ('headers', 'scripts', 'data', 'purelib', 'platlib'):
            setattr(install,
                    'install_' + key,
                    os.path.join(self.data_dir, key))

        basedir_observed = ''

        if os.name == 'nt':
            # win32 barfs if any of these are ''; could be '.'?
            # (distutils.command.install:change_roots bug)
            basedir_observed = os.path.normpath(os.path.join(self.data_dir, '..'))
            self.install_libbase = self.install_lib = basedir_observed

        setattr(install,
                'install_purelib' if self.root_is_pure else 'install_platlib',
                basedir_observed)

        logger.info("installing to %s", self.bdist_dir)

        self.run_command('install')

        archive_basename = self.get_archive_basename()

        pseudoinstall_root = os.path.join(self.dist_dir, archive_basename)
        if not self.relative:
            archive_root = self.bdist_dir
        else:
            archive_root = os.path.join(
                self.bdist_dir,
                self._ensure_relative(install.install_base))

        self.set_undefined_options(
            'install_egg_info', ('target', 'egginfo_dir'))
        self.distinfo_dir = os.path.join(self.bdist_dir,
                                         '%s.dist-info' % self.wheel_dist_name)
        self.egg2dist(self.egginfo_dir,
                      self.distinfo_dir)

        self.write_wheelfile(self.distinfo_dir)

        self.write_record(self.bdist_dir, self.distinfo_dir)

        # Make the archive
        if not os.path.exists(self.dist_dir):
            os.makedirs(self.dist_dir)
        wheel_name = archive_wheelfile(pseudoinstall_root, archive_root)

        # Sign the archive
        if 'WHEEL_TOOL' in os.environ:
            subprocess.call([os.environ['WHEEL_TOOL'], 'sign', wheel_name])

        # Add to 'Distribution.dist_files' so that the "upload" command works
        getattr(self.distribution, 'dist_files', []).append(
            ('bdist_wheel', get_python_version(), wheel_name))

        if not self.keep_temp:
            if self.dry_run:
                logger.info('removing %s', self.bdist_dir)
            else:
                rmtree(self.bdist_dir)
Ejemplo n.º 2
0
def bdist_wininst2wheel(path, dest_dir=os.path.curdir):
    bdw = zipfile.ZipFile(path)

    # Search for egg-info in the archive
    egginfo_name = None
    for filename in bdw.namelist():
        if '.egg-info' in filename:
            egginfo_name = filename
            break

    info = parse_info(os.path.basename(path), egginfo_name)

    root_is_purelib = True
    for zipinfo in bdw.infolist():
        if zipinfo.filename.startswith('PLATLIB'):
            root_is_purelib = False
            break
    if root_is_purelib:
        paths = {'purelib': ''}
    else:
        paths = {'platlib': ''}

    dist_info = "%(name)s-%(ver)s" % info
    datadir = "%s.data/" % dist_info

    # rewrite paths to trick ZipFile into extracting an egg
    # XXX grab wininst .ini - between .exe, padding, and first zip file.
    members = []
    egginfo_name = ''
    for zipinfo in bdw.infolist():
        key, basename = zipinfo.filename.split('/', 1)
        key = key.lower()
        basepath = paths.get(key, None)
        if basepath is None:
            basepath = datadir + key.lower() + '/'
        oldname = zipinfo.filename
        newname = basepath + basename
        zipinfo.filename = newname
        del bdw.NameToInfo[oldname]
        bdw.NameToInfo[newname] = zipinfo
        # Collect member names, but omit '' (from an entry like "PLATLIB/"
        if newname:
            members.append(newname)
        # Remember egg-info name for the egg2dist call below
        if not egginfo_name:
            if newname.endswith('.egg-info'):
                egginfo_name = newname
            elif '.egg-info/' in newname:
                egginfo_name, sep, _ = newname.rpartition('/')
    dir = tempfile.mkdtemp(suffix="_b2w")
    bdw.extractall(dir, members)

    # egg2wheel
    abi = 'none'
    pyver = info['pyver']
    arch = (info['arch'] or 'any').replace('.', '_').replace('-', '_')
    # Wininst installers always have arch even if they are not
    # architecture-specific (because the format itself is).
    # So, assume the content is architecture-neutral if root is purelib.
    if root_is_purelib:
        arch = 'any'
    # If the installer is architecture-specific, it's almost certainly also
    # CPython-specific.
    if arch != 'any':
        pyver = pyver.replace('py', 'cp')
    wheel_name = '-'.join((
                          dist_info,
                          pyver,
                          abi,
                          arch
                          ))
    bw = wheel.bdist_wheel.bdist_wheel(distutils.dist.Distribution())
    bw.root_is_purelib = root_is_purelib
    dist_info_dir = os.path.join(dir, '%s.dist-info' % dist_info)
    bw.egg2dist(os.path.join(dir, egginfo_name), dist_info_dir)
    bw.write_wheelfile(dist_info_dir, generator='wininst2wheel')
    bw.write_record(dir, dist_info_dir)
    
    archive_wheelfile(os.path.join(dest_dir, wheel_name), dir)
    rmtree(dir)
Ejemplo n.º 3
0
    def run(self):
        build_scripts = self.reinitialize_command('build_scripts')
        build_scripts.executable = 'python'

        if not self.skip_build:
            self.run_command('build')

        install = self.reinitialize_command('install', reinit_subcommands=True)
        install.root = self.bdist_dir
        install.compile = False
        install.skip_build = self.skip_build
        install.warn_dir = False

        # A wheel without setuptools scripts is more cross-platform.
        # Use the (undocumented) `no_ep` option to setuptools'
        # install_scripts command to avoid creating entry point scripts.
        install_scripts = self.reinitialize_command('install_scripts')
        install_scripts.no_ep = True

        # Use a custom scheme for the archive, because we have to decide
        # at installation time which scheme to use.
        for key in ('headers', 'scripts', 'data', 'purelib', 'platlib'):
            setattr(install, 'install_' + key,
                    os.path.join(self.data_dir, key))

        basedir_observed = ''

        if os.name == 'nt':
            # win32 barfs if any of these are ''; could be '.'?
            # (distutils.command.install:change_roots bug)
            # PATCHED...
            basedir_observed = os.path.join(self.data_dir, '..', '.')
            self.install_libbase = self.install_lib = basedir_observed

        setattr(install,
                'install_purelib' if self.root_is_pure else 'install_platlib',
                basedir_observed)

        logger.info("installing to %s", self.bdist_dir)

        self.run_command('install')

        archive_basename = self.get_archive_basename()

        pseudoinstall_root = os.path.join(self.dist_dir, archive_basename)
        if not self.relative:
            archive_root = self.bdist_dir
        else:
            archive_root = os.path.join(
                self.bdist_dir, self._ensure_relative(install.install_base))

        self.set_undefined_options('install_egg_info',
                                   ('target', 'egginfo_dir'))
        self.distinfo_dir = os.path.join(self.bdist_dir,
                                         '%s.dist-info' % self.wheel_dist_name)
        self.egg2dist(self.egginfo_dir, self.distinfo_dir)

        self.write_wheelfile(self.distinfo_dir)

        self.write_record(self.bdist_dir, self.distinfo_dir)

        # Make the archive
        if not os.path.exists(self.dist_dir):
            os.makedirs(self.dist_dir)
        wheel_name = archive_wheelfile(pseudoinstall_root, archive_root)

        # Sign the archive
        if 'WHEEL_TOOL' in os.environ:
            subprocess.call([os.environ['WHEEL_TOOL'], 'sign', wheel_name])

        # Add to 'Distribution.dist_files' so that the "upload" command works
        getattr(self.distribution, 'dist_files', []).append(
            ('bdist_wheel', get_python_version(), wheel_name))

        if not self.keep_temp:
            if self.dry_run:
                logger.info('removing %s', self.bdist_dir)
            else:
                rmtree(self.bdist_dir)
Ejemplo n.º 4
0
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Scientific/Engineering
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Operating System :: MacOS

CasADi is a symbolic framework for numeric optimization implementing automatic differentiation in forward and reverse modes on sparse matrix-valued computational graphs. It supports self-contained C-code generation and interfaces state-of-the-art codes such as SUNDIALS, IPOPT etc. It can be used from C++, Python or Matlab/Octave."""
            % (version))

#wheel_dist_name = wheel_dist_name+".post1"
if isinstance(tag, list):
    fullname = wheel_dist_name + "-" + tag[0]
    for t in tag[1:]:
        fullname += "." + t.split("-")[-1]
else:
    fullname = wheel_dist_name + "-" + tag

write_record(bdist_dir, distinfo_dir)
archive_wheelfile(fullname, dir_name)

import sys

sys.stdout.write(fullname + ".whl")
Ejemplo n.º 5
0
def deb_to_wheel(module, src, dest):
    """Translate a debian package to a python wheel."""
    res = {}
    res['results'] = []
    res['msg'] = ''
    res['changed'] = False
    res['rc'] = 1

    # Create scratch directories
    temp_deb_dir = tempfile.mkdtemp()
    temp_wheel_dir = tempfile.mkdtemp()

    # Extract deb package content to scratch directory
    extract_deb(src, temp_deb_dir)

    # Check if there's an egg file or directory
    egg_path = glob.glob(temp_deb_dir +
                         "/usr/lib/python2.7/dist-packages/*.egg-info")
    if len(egg_path) != 0:
        egg_path = egg_path[0]
        pkg_name, pkg_version = egg_to_metadata(module, egg_path,
                                                temp_wheel_dir)
    else:
        # Convert deb control to METADATA file
        control_dir = os.path.join(temp_deb_dir, "DEBIAN/control")
        pkg_name, pkg_version = control_to_metadata(control_dir,
                                                    temp_wheel_dir)

    # How directories in the debian package should be translated to the wheel
    pkg_string = "%s-%s" % (pkg_name, pkg_version)
    data_dir = os.path.join(temp_wheel_dir, pkg_string + ".data")
    dir_map = {
        'usr/lib/python2.7/dist-packages': temp_wheel_dir,
        'usr/bin': os.path.join(data_dir, 'scripts'),
        'usr/include/python2.7/' + pkg_name: os.path.join(data_dir, 'headers'),
        'usr': os.path.join(data_dir, 'data')
    }

    for source, destination in dir_map.iteritems():
        if (os.path.exists(os.path.join(temp_deb_dir, source))):
            ignore = []
            if (source is 'usr'):
                ignore = ['lib', 'bin', 'include']
            copytree(os.path.join(temp_deb_dir, source),
                     destination,
                     ignore=shutil.ignore_patterns(*ignore))

    # Write out record and wheelfile
    dist_info_dir = temp_wheel_dir + "/" + pkg_string + ".dist-info"
    bw = wheel.bdist_wheel.bdist_wheel(distutils.dist.Distribution())
    bw.write_wheelfile(dist_info_dir)
    bw.write_record(temp_wheel_dir, dist_info_dir)

    package_name = "{dist}-{version}-{pyVer}-{abi}-{platform}".format(
        dist=pkg_name,
        version=pkg_version,
        pyVer='py27',
        abi='none',
        platform='any')
    base_name = os.path.join(os.path.dirname(dest), package_name)
    archive_wheelfile(base_name, temp_wheel_dir)

    cleanup(temp_deb_dir, temp_wheel_dir)

    res['rc'] = 0
    res['changed'] = True

    return res
Ejemplo n.º 6
0
    def run(self):
        build_scripts = self.reinitialize_command("build_scripts")
        build_scripts.executable = "python"

        if not self.skip_build:
            self.run_command("build")

        install = self.reinitialize_command("install", reinit_subcommands=True)
        install.root = self.bdist_dir
        install.compile = False
        install.skip_build = self.skip_build
        install.warn_dir = False

        # A wheel without setuptools scripts is more cross-platform.
        # Use the (undocumented) `no_ep` option to setuptools'
        # install_scripts command to avoid creating entry point scripts.
        install_scripts = self.reinitialize_command("install_scripts")
        install_scripts.no_ep = True

        # Use a custom scheme for the archive, because we have to decide
        # at installation time which scheme to use.
        for key in ("headers", "scripts", "data", "purelib", "platlib"):
            setattr(install, "install_" + key,
                    os.path.join(self.data_dir, key))

        basedir_observed = ""

        if os.name == "nt":
            # win32 barfs if any of these are ''; could be '.'?
            # (distutils.command.install:change_roots bug)
            basedir_observed = os.path.normpath(
                os.path.join(self.data_dir, ".."))
            self.install_libbase = self.install_lib = basedir_observed

        setattr(
            install,
            "install_purelib" if self.root_is_pure else "install_platlib",
            basedir_observed,
        )

        logger.info("installing to %s", self.bdist_dir)

        self.run_command("install")

        archive_basename = self.get_archive_basename()

        pseudoinstall_root = os.path.join(self.dist_dir, archive_basename)
        if not self.relative:
            archive_root = self.bdist_dir
        else:
            archive_root = os.path.join(
                self.bdist_dir, self._ensure_relative(install.install_base))

        self.set_undefined_options("install_egg_info",
                                   ("target", "egginfo_dir"))
        self.distinfo_dir = os.path.join(self.bdist_dir,
                                         "%s.dist-info" % self.wheel_dist_name)
        self.egg2dist(self.egginfo_dir, self.distinfo_dir)

        self.write_wheelfile(self.distinfo_dir)

        self.write_record(self.bdist_dir, self.distinfo_dir)

        # Make the archive
        if not os.path.exists(self.dist_dir):
            os.makedirs(self.dist_dir)
        wheel_name = archive_wheelfile(pseudoinstall_root, archive_root)

        # Sign the archive
        if "WHEEL_TOOL" in os.environ:
            subprocess.call([os.environ["WHEEL_TOOL"], "sign", wheel_name])

        # Add to 'Distribution.dist_files' so that the "upload" command works
        getattr(self.distribution, "dist_files", []).append(
            ("bdist_wheel", get_python_version(), wheel_name))

        if not self.keep_temp:
            if self.dry_run:
                logger.info("removing %s", self.bdist_dir)
            else:
                rmtree(self.bdist_dir)
Ejemplo n.º 7
0
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Scientific/Engineering
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Operating System :: MacOS

CasADi is a symbolic framework for numeric optimization implementing automatic differentiation in forward and reverse modes on sparse matrix-valued computational graphs. It supports self-contained C-code generation and interfaces state-of-the-art codes such as SUNDIALS, IPOPT etc. It can be used from C++, Python or Matlab/Octave.""" % (version))


#wheel_dist_name = wheel_dist_name+".post1"
if isinstance(tag,list):
  fullname = wheel_dist_name+"-"+tag[0]
  for t in tag[1:]:
    fullname+="."+t.split("-")[-1]
else:
  fullname = wheel_dist_name+"-"+tag

write_record(bdist_dir, distinfo_dir)
archive_wheelfile(fullname,dir_name)

import sys
sys.stdout.write(fullname+".whl")