当前位置: 首页>>代码示例>>Python>>正文


Python setuptools.Distribution类代码示例

本文整理汇总了Python中setuptools.Distribution的典型用法代码示例。如果您正苦于以下问题:Python Distribution类的具体用法?Python Distribution怎么用?Python Distribution使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Distribution类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _include_misc

 def _include_misc(self, name, value):
     if name == 'entry_points':
         old = getattr(self, name)
         for (group, entries) in value.iteritems():
             self.entry_points.setdefault(group, list()).extend(entries)
     else:
         Distribution._include_misc(self, name, value)
开发者ID:segfaulthunter,项目名称:pypentago,代码行数:7,代码来源:setup.py

示例2: fetch_build_egg

	def fetch_build_egg(self, req):
		""" Specialized version of Distribution.fetch_build_egg
		that respects respects allow_hosts and index_url. """
		from setuptools.command.easy_install import easy_install
		dist = Distribution({'script_args': ['easy_install']})
		dist.parse_config_files()
		opts = dist.get_option_dict('easy_install')
		keep = (
			'find_links', 'site_dirs', 'index_url', 'optimize',
			'site_dirs', 'allow_hosts'
		)
		for key in list(opts):
			if key not in keep:
				del opts[key]  # don't use any other settings
		if self.dependency_links:
			links = self.dependency_links[:]
			if 'find_links' in opts:
				links = opts['find_links'][1].split() + links
			opts['find_links'] = ('setup', links)
		if self.allow_hosts:
			opts['allow_hosts'] = ('test', self.allow_hosts)
		if self.index_url:
			opts['index_url'] = ('test', self.index_url)
		install_dir_func = getattr(self, 'get_egg_cache_dir', _os.getcwd)
		install_dir = install_dir_func()
		cmd = easy_install(
			dist, args=["x"], install_dir=install_dir,
			exclude_scripts=True,
			always_copy=False, build_directory=None, editable=False,
			upgrade=False, multi_version=True, no_report=True, user=False
		)
		cmd.ensure_finalized()
		return cmd.easy_install(req)
开发者ID:blue-yonder,项目名称:pyscaffold,代码行数:33,代码来源:ptr.py

示例3: _exclude_misc

 def _exclude_misc(self, name, value):
     if name == 'entry_points':
         old = getattr(self, name)
         for (group, entries) in value.iteritems():
             old_entries = set(self.entry_points.get(group, list()))
             self.entry_points[group] = list(old_entries - set(entries))
     else:
         Distribution._exclude_misc(self, name, value)
开发者ID:segfaulthunter,项目名称:pypentago,代码行数:8,代码来源:setup.py

示例4: get_install_lib

 def get_install_lib(args):
     # This helper uses the distutils/setuptools machinery to determine
     # where a command will install files based on the arguments passed
     # to setup.py
     dist = Distribution({'script_args': args})
     dist.parse_command_line()
     install_cmd = dist.get_command_obj('install')
     install_cmd.ensure_finalized()
     return install_cmd.install_lib
开发者ID:dhomeier,项目名称:stsci.distutils,代码行数:9,代码来源:test_hooks.py

示例5: get_setuptools_script_dir

 def get_setuptools_script_dir():
     " Get the directory setuptools installs scripts to for current python "
     dist = Distribution({'cmdclass': {'install': OnlyGetScriptPath}})
     dist.dry_run = True  # not sure if necessary
     dist.parse_config_files()
     command = dist.get_command_obj('install')
     command.ensure_finalized()
     command.run()
     return dist.install_scripts
开发者ID:jobovy,项目名称:apogee,代码行数:9,代码来源:setup.py

示例6: _convert_metadata

    def _convert_metadata(zf, destination_eggdir, dist_info, egg_info):
        def get_metadata(name):
            with zf.open(posixpath.join(dist_info, name)) as fp:
                value = fp.read().decode('utf-8') if PY3 else fp.read()
                return email.parser.Parser().parsestr(value)

        wheel_metadata = get_metadata('WHEEL')
        # Check wheel format version is supported.
        wheel_version = parse_version(wheel_metadata.get('Wheel-Version'))
        wheel_v1 = (
            parse_version('1.0') <= wheel_version < parse_version('2.0dev0')
        )
        if not wheel_v1:
            raise ValueError(
                'unsupported wheel format version: %s' % wheel_version)
        # Extract to target directory.
        os.mkdir(destination_eggdir)
        zf.extractall(destination_eggdir)
        # Convert metadata.
        dist_info = os.path.join(destination_eggdir, dist_info)
        dist = Distribution.from_location(
            destination_eggdir, dist_info,
            metadata=PathMetadata(destination_eggdir, dist_info),
        )

        # Note: Evaluate and strip markers now,
        # as it's difficult to convert back from the syntax:
        # foobar; "linux" in sys_platform and extra == 'test'
        def raw_req(req):
            req.marker = None
            return str(req)
        install_requires = list(sorted(map(raw_req, dist.requires())))
        extras_require = {
            extra: sorted(
                req
                for req in map(raw_req, dist.requires((extra,)))
                if req not in install_requires
            )
            for extra in dist.extras
        }
        os.rename(dist_info, egg_info)
        os.rename(
            os.path.join(egg_info, 'METADATA'),
            os.path.join(egg_info, 'PKG-INFO'),
        )
        setup_dist = SetuptoolsDistribution(
            attrs=dict(
                install_requires=install_requires,
                extras_require=extras_require,
            ),
        )
        write_requirements(
            setup_dist.get_command_obj('egg_info'),
            None,
            os.path.join(egg_info, 'requires.txt'),
        )
开发者ID:jsirois,项目名称:pex,代码行数:56,代码来源:wheel.py

示例7: __init__

 def __init__(self, attrs=None):
     self.translations = []
     Distribution.__init__(self, attrs)
     self.cmdclass = {
         'install_mo' : install_mo,
         'build_mo' : build_mo,
         # 'build_conf' : build_conf,
         'build_ext': BuildExt,
         'build_scripts': build_scripts_app,
         }
     self.command_obj['build_scripts'] = None
开发者ID:Ichag,项目名称:openerp-client,代码行数:11,代码来源:mydistutils.py

示例8: get_setuptools_script_dir

def get_setuptools_script_dir():
    # Run the above class just to get paths
    dist = Distribution({'cmdclass': {'install': GetPaths}})
    dist.dry_run = True
    dist.parse_config_files()
    command = dist.get_command_obj('install')
    command.ensure_finalized()
    command.run()

    src_dir = glob(os.path.join(dist.install_libbase, 'pomoxis-*', 'exes'))[0]
    for exe in (os.path.join(src_dir, x) for x in os.listdir(src_dir)):
        print("Copying", os.path.basename(exe), '->', dist.install_scripts)
        shutil.copy(exe, dist.install_scripts)
    return dist.install_libbase, dist.install_scripts
开发者ID:vineeth-s,项目名称:pomoxis,代码行数:14,代码来源:setup.py

示例9: __init__

	def __init__(self, attrs=None):
		Distribution.__init__(self, attrs)
		self.cmdclass = {
			'build': build,
			'build_ext': build_ext,
			'sdist': sdist,
			'config': config,
			'docs': sphinx_build,
			'clean': clean,
		}
		try:
			shell_cmd('which dpkg-buildpackage')
			self.cmdclass['debian'] = debian
		except IOError:
			# Not a debian system or dpkg-buildpackage not installed
			pass
开发者ID:rsms,项目名称:smisk,代码行数:16,代码来源:setup.py

示例10: run_command

    def run_command(self, command):
        '''Builds the documentation if needed, then passes control to
        the superclass' run_command(...) method.
        '''

        if command == 'install_data' and docutils:
            print 'creating doc/index.html'
            docutils.core.publish_file(writer_name='html',
                    source=open('doc/index.rst'),
                    source_path='doc',
                    destination=open('doc/index.html', 'w'),
                    destination_path='doc',
                    settings_overrides={'stylesheet_path':
                        'doc/documentation.css'}
            )
        Distribution.run_command(self, command)
开发者ID:abhay123lp,项目名称:online-image-clustering-project,代码行数:16,代码来源:_setup.py

示例11: __init__

    def __init__(self, attrs=None):
        if attrs is None:
            attrs = {}

        attrs = _setup_cmd_classes(attrs)

        self.package = PackageDescription.from_yaml("setup.yaml")

        attrs.update({
            "name": self.package.name,
            "version": str(self.package.version),
            "long_description": self.package.description,
            "description": self.package.summary,
            "packages": self.package.packages,
        })

        OldDistribution.__init__(self, attrs)
开发者ID:cournape,项目名称:toydist,代码行数:17,代码来源:dist.py

示例12: get_command_class

 def get_command_class(self, command):
     # Better raising an error than having some weird behavior for a command
     # we don't support
     if self.script_args is not None \
        and command in self.script_args \
        and command not in _BENTO_MONKEYED_CLASSES:
         raise ValueError("Command %s is not supported by bento.distutils compat layer" % command)
     return Distribution.get_command_class(self, command)
开发者ID:Web5design,项目名称:Bento,代码行数:8,代码来源:dist.py

示例13: finalize_options

    def finalize_options(self):
        self.cmdclass['config'] = config

        self.cmdclass['build'] = build
        self.cmdclass['build_exe'] = build_exe
        self.cmdclass['build_qk'] = build_qk
        self.cmdclass['build_ext'] = build_ext
        self.cmdclass['build_qext'] = build_qext

        self.cmdclass['install'] = install
        self.cmdclass['install_exe'] = install_exe
        self.cmdclass['install_qlib'] = install_qlib
        self.cmdclass['install_qext'] = install_qext

        self.cmdclass['test'] = PyTest

        default_qhome_root = os.getenv('SystemDrive') + '\\' if platform == 'Windows' else os.getenv('HOME')
        self.qhome = os.getenv('QHOME') or os.path.join(default_qhome_root, 'q')

        bits = BITS
        if platform == 'Linux':
            o = 'l'
        elif platform == 'SunOS':
            o = 'v' if uname()[-1] == 'i86pc' else 's'
        elif platform == 'Darwin':
            o = 'm'
            bits = 32
        elif platform == 'Windows':
            o = 'w'
            bits = 32  # FIXME: We test with 32-bit kdb+ on Windows, so forcing 32-bit version.
        else:
            sys.stderr.write("Unknown platform: %s\n" % str(platform))
            sys.exit(1)
        self.qarch = "%s%d" % (o, bits)
        self.install_data = os.path.join(self.qhome, self.qarch)
        self.kxver = self.get_kxver(self.qhome)
        self.qexecutable = os.path.join(self.qhome, self.qarch, 'q')
        _Distribution.finalize_options(self)
        for ext in self.ext_modules + self.qext_modules:
            ext.define_macros.append(('KXVER', self.kxver.split('.')[0]))
            ext.define_macros.append(('QVER', self.kxver.split('.')[0]))
            if sys.hexversion >= 0x3000000:
                ext.define_macros.append(('PY3K', "%s%s" % sys.version_info[:2]))
开发者ID:zjc5415,项目名称:pyq,代码行数:43,代码来源:setup.py

示例14: get_option_dict

 def get_option_dict(self, command_name):
     opts = Distribution.get_option_dict(self, command_name)
     if command_name == 'easy_install':
         if find_links is not None:
             opts['find_links'] = ('setup script', find_links)
         if index_url is not None:
             opts['index_url'] = ('setup script', index_url)
         if allow_hosts is not None:
             opts['allow_hosts'] = ('setup script', allow_hosts)
     return opts
开发者ID:astrofrog,项目名称:sphere,代码行数:10,代码来源:ah_bootstrap.py

示例15: test_dist_fetch_build_egg

def test_dist_fetch_build_egg(tmpdir):
    """
    Check multiple calls to `Distribution.fetch_build_egg` work as expected.
    """
    index = tmpdir.mkdir('index')
    index_url = urljoin('file://', pathname2url(str(index)))

    def sdist_with_index(distname, version):
        dist_dir = index.mkdir(distname)
        dist_sdist = '%s-%s.tar.gz' % (distname, version)
        make_nspkg_sdist(str(dist_dir.join(dist_sdist)), distname, version)
        with dist_dir.join('index.html').open('w') as fp:
            fp.write(DALS(
                '''
                <!DOCTYPE html><html><body>
                <a href="{dist_sdist}" rel="internal">{dist_sdist}</a><br/>
                </body></html>
                '''
            ).format(dist_sdist=dist_sdist))
    sdist_with_index('barbazquux', '3.2.0')
    sdist_with_index('barbazquux-runner', '2.11.1')
    with tmpdir.join('setup.cfg').open('w') as fp:
        fp.write(DALS(
            '''
            [easy_install]
            index_url = {index_url}
            '''
        ).format(index_url=index_url))
    reqs = '''
    barbazquux-runner
    barbazquux
    '''.split()
    with tmpdir.as_cwd():
        dist = Distribution()
        dist.parse_config_files()
        resolved_dists = [
            dist.fetch_build_egg(r)
            for r in reqs
        ]
    assert [dist.key for dist in resolved_dists if dist] == reqs
开发者ID:benoit-pierre,项目名称:setuptools,代码行数:40,代码来源:test_dist.py


注:本文中的setuptools.Distribution类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。