• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python setuptools.Distribution类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: __init__

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

        if not "bento_info" in attrs:
            bento_info = "bento.info"
        else:
            bento_info = attrs["bento.info"]
        self.pkg = PackageDescription.from_file(bento_info)
        self.package_options = PackageOptions.from_file(bento_info)


        attrs = _setup_cmd_classes(attrs)

        d = pkg_to_distutils_meta(self.pkg)
        attrs.update(d)

        Distribution.__init__(self, attrs)

        self.packages = self.pkg.packages
        self.py_modules = self.pkg.py_modules
        if hasattr(self, "entry_points"):
            if self.entry_points is None:
                self.entry_points = {}
            console_scripts = [e.full_representation() for e in self.pkg.executables.values()]
            if "console_scripts" in self.entry_points:
                self.entry_points["console_scripts"].extend(console_scripts)
            else:
                self.entry_points["console_scripts"] = console_scripts

        source_root = os.getcwd()
        build_root = os.path.join(source_root, "build")
        root = create_root_with_source_tree(source_root, build_root)
        self.top_node = root._ctx.srcnode
        self.build_node = root._ctx.bldnode
        self.run_node = root._ctx.srcnode

        self.global_context = global_context_factory(self.package_options)
        modules = set_main(self.top_node, self.build_node, self.pkg)
开发者ID:pberkes,项目名称:Bento,代码行数:39,代码来源:dist.py


示例17: 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

        self.qhome = os.getenv('QHOME') or os.path.join(os.getenv('HOME'), 'q')
        bits = 8 * get_config_var('SIZEOF_VOID_P')
        u = os.uname()
        if u[0] == 'Linux':
            o = 'l'
        elif u[0] == 'SunOS':
            o = 'v' if u[-1] == 'i86pc' else 's'
        elif u[0] == 'Darwin':
            o = 'm'
            bits = 32
        else:
            sys.stderr.write("Unknown platform: %s\n" % str(u))
            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:e42s,项目名称:pyq,代码行数:39,代码来源:setup.py


示例18: ensure_sphinx_astropy_installed

def ensure_sphinx_astropy_installed():
    """
    Make sure that sphinx-astropy is available, installing it temporarily if not.

    This returns the available version of sphinx-astropy as well as any
    paths that should be added to sys.path for sphinx-astropy to be available.
    """
    # We've split out the Sphinx part of astropy-helpers into sphinx-astropy
    # but we want it to be auto-installed seamlessly for anyone using
    # build_docs. We check if it's already installed, and if not, we install
    # it to a local .eggs directory and add the eggs to the path (these
    # have to each be added to the path, we can't add them by simply adding
    # .eggs to the path)
    sys_path_inserts = []
    sphinx_astropy_version = None
    try:
        from sphinx_astropy import __version__ as sphinx_astropy_version  # noqa
    except ImportError:

        from setuptools import Distribution
        dist = Distribution()
        eggs = dist.fetch_build_eggs('sphinx-astropy')

        # Find out the version of sphinx-astropy if possible. For some old
        # setuptools version, eggs will be None even if sphinx-astropy was
        # successfully installed.
        if eggs is not None:
            for egg in eggs:
                if egg.project_name == 'sphinx-astropy':
                    sphinx_astropy_version = egg.parsed_version.public
                    break

        eggs_path = os.path.abspath('.eggs')
        for egg in glob.glob(os.path.join(eggs_path, '*.egg')):
            sys_path_inserts.append(egg)

    return sphinx_astropy_version, sys_path_inserts
开发者ID:Cadair,项目名称:astropy-helpers,代码行数:37,代码来源:build_sphinx.py


示例19: getprefix

    def getprefix(self):
        '''Retrieve setup tool calculated prefix

        :returns: prefix
        :rtype: string
        '''
        dist = Distribution({'cmdclass': {'install': OnlyGetScriptPath}})
        dist.dry_run = True  # not sure if necessary, but to be safe
        dist.parse_config_files()
        try:
            dist.parse_command_line()
        except (distutils.errors.DistutilsArgError, AttributeError):
            pass
        command = dist.get_command_obj('install')
        command.ensure_finalized()
        command.run()
        prefix = dist.install_scripts.replace('/bin', '')
        return prefix
开发者ID:uggla,项目名称:python-redfish,代码行数:18,代码来源:setup.py


示例20: find_config_files

 def find_config_files(self):
     configs = Distribution.find_config_files(self)
     configs.append("setup.py3.cfg" if running_python3 else "setup.py2.cfg")
     return configs
开发者ID:Feng2012,项目名称:PTVS,代码行数:4,代码来源:setup.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python setuptools.Extension类代码示例发布时间:2022-05-27
下一篇:
Python setuptools.Command类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap