本文整理汇总了Python中distutils.core.Distribution方法的典型用法代码示例。如果您正苦于以下问题:Python core.Distribution方法的具体用法?Python core.Distribution怎么用?Python core.Distribution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类distutils.core
的用法示例。
在下文中一共展示了core.Distribution方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_solaris_enable_shared
# 需要导入模块: from distutils import core [as 别名]
# 或者: from distutils.core import Distribution [as 别名]
def test_solaris_enable_shared(self):
dist = Distribution({'name': 'xx'})
cmd = build_ext(dist)
old = sys.platform
sys.platform = 'sunos' # fooling finalize_options
from distutils.sysconfig import _config_vars
old_var = _config_vars.get('Py_ENABLE_SHARED')
_config_vars['Py_ENABLE_SHARED'] = 1
try:
cmd.ensure_finalized()
finally:
sys.platform = old
if old_var is None:
del _config_vars['Py_ENABLE_SHARED']
else:
_config_vars['Py_ENABLE_SHARED'] = old_var
# make sure we get some library dirs under solaris
self.assertGreater(len(cmd.library_dirs), 0)
示例2: test_user_site
# 需要导入模块: from distutils import core [as 别名]
# 或者: from distutils.core import Distribution [as 别名]
def test_user_site(self):
import site
dist = Distribution({'name': 'xx'})
cmd = build_ext(dist)
# making sure the user option is there
options = [name for name, short, label in
cmd.user_options]
self.assertIn('user', options)
# setting a value
cmd.user = 1
# setting user based lib and include
lib = os.path.join(site.USER_BASE, 'lib')
incl = os.path.join(site.USER_BASE, 'include')
os.mkdir(lib)
os.mkdir(incl)
cmd.ensure_finalized()
# see if include_dirs and library_dirs were set
self.assertIn(lib, cmd.library_dirs)
self.assertIn(lib, cmd.rpath)
self.assertIn(incl, cmd.include_dirs)
示例3: test_customize_compiler_before_get_config_vars
# 需要导入模块: from distutils import core [as 别名]
# 或者: from distutils.core import Distribution [as 别名]
def test_customize_compiler_before_get_config_vars(self):
# Issue #21923: test that a Distribution compiler
# instance can be called without an explicit call to
# get_config_vars().
with open(TESTFN, 'w') as f:
f.writelines(textwrap.dedent('''\
from distutils.core import Distribution
config = Distribution().get_command_obj('config')
# try_compile may pass or it may fail if no compiler
# is found but it should not raise an exception.
rc = config.try_compile('int x;')
'''))
p = subprocess.Popen([str(sys.executable), TESTFN],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True)
outs, errs = p.communicate()
self.assertEqual(0, p.returncode, "Subprocess failed: " + outs)
示例4: test_default_settings
# 需要导入模块: from distutils import core [as 别名]
# 或者: from distutils.core import Distribution [as 别名]
def test_default_settings(self):
dist = Distribution()
dist.command_obj["build"] = support.DummyCommand(
build_scripts="/foo/bar")
dist.command_obj["install"] = support.DummyCommand(
install_scripts="/splat/funk",
force=1,
skip_build=1,
)
cmd = install_scripts(dist)
self.assertFalse(cmd.force)
self.assertFalse(cmd.skip_build)
self.assertIsNone(cmd.build_dir)
self.assertIsNone(cmd.install_dir)
cmd.finalize_options()
self.assertTrue(cmd.force)
self.assertTrue(cmd.skip_build)
self.assertEqual(cmd.build_dir, "/foo/bar")
self.assertEqual(cmd.install_dir, "/splat/funk")
示例5: setUp
# 需要导入模块: from distutils import core [as 别名]
# 或者: from distutils.core import Distribution [as 别名]
def setUp(self):
"""Patches the environment."""
super(PyPIRCCommandTestCase, self).setUp()
self.tmp_dir = self.mkdtemp()
os.environ['HOME'] = self.tmp_dir
self.rc = os.path.join(self.tmp_dir, '.pypirc')
self.dist = Distribution()
class command(PyPIRCCommand):
def __init__(self, dist):
PyPIRCCommand.__init__(self, dist)
def initialize_options(self):
pass
finalize_options = initialize_options
self._cmd = command
self.old_threshold = set_threshold(WARN)
示例6: create_dist
# 需要导入模块: from distutils import core [as 别名]
# 或者: from distutils.core import Distribution [as 别名]
def create_dist(self, pkg_name='foo', **kw):
"""Will generate a test environment.
This function creates:
- a Distribution instance using keywords
- a temporary directory with a package structure
It returns the package directory and the distribution
instance.
"""
tmp_dir = self.mkdtemp()
pkg_dir = os.path.join(tmp_dir, pkg_name)
os.mkdir(pkg_dir)
dist = Distribution(attrs=kw)
return pkg_dir, dist
示例7: test_finalize_options
# 需要导入模块: from distutils import core [as 别名]
# 或者: from distutils.core import Distribution [as 别名]
def test_finalize_options(self):
dist = Distribution({'name': 'xx'})
cmd = install(dist)
# must supply either prefix/exec-prefix/home or
# install-base/install-platbase -- not both
cmd.prefix = 'prefix'
cmd.install_base = 'base'
self.assertRaises(DistutilsOptionError, cmd.finalize_options)
# must supply either home or prefix/exec-prefix -- not both
cmd.install_base = None
cmd.home = 'home'
self.assertRaises(DistutilsOptionError, cmd.finalize_options)
# can't combine user with prefix/exec_prefix/home or
# install_(plat)base
cmd.prefix = None
cmd.user = 'user'
self.assertRaises(DistutilsOptionError, cmd.finalize_options)
示例8: test_saved_password
# 需要导入模块: from distutils import core [as 别名]
# 或者: from distutils.core import Distribution [as 别名]
def test_saved_password(self):
# file with no password
self.write_file(self.rc, PYPIRC_NOPASSWORD)
# make sure it passes
dist = Distribution()
cmd = upload(dist)
cmd.finalize_options()
self.assertEqual(cmd.password, None)
# make sure we get it as well, if another command
# initialized it at the dist level
dist.password = 'xxx'
cmd = upload(dist)
cmd.finalize_options()
self.assertEqual(cmd.password, 'xxx')
示例9: test_solaris_enable_shared
# 需要导入模块: from distutils import core [as 别名]
# 或者: from distutils.core import Distribution [as 别名]
def test_solaris_enable_shared(self):
dist = Distribution({'name': 'xx'})
cmd = build_ext(dist)
old = sys.platform
sys.platform = 'sunos' # fooling finalize_options
from distutils.sysconfig import _config_vars
old_var = _config_vars.get('Py_ENABLE_SHARED')
_config_vars['Py_ENABLE_SHARED'] = 1
try:
cmd.ensure_finalized()
finally:
sys.platform = old
if old_var is None:
del _config_vars['Py_ENABLE_SHARED']
else:
_config_vars['Py_ENABLE_SHARED'] = old_var
# make sure we get some library dirs under solaris
self.assertTrue(len(cmd.library_dirs) > 0)
示例10: test_default_settings
# 需要导入模块: from distutils import core [as 别名]
# 或者: from distutils.core import Distribution [as 别名]
def test_default_settings(self):
dist = Distribution()
dist.command_obj["build"] = support.DummyCommand(
build_scripts="/foo/bar")
dist.command_obj["install"] = support.DummyCommand(
install_scripts="/splat/funk",
force=1,
skip_build=1,
)
cmd = install_scripts(dist)
self.assertTrue(not cmd.force)
self.assertTrue(not cmd.skip_build)
self.assertTrue(cmd.build_dir is None)
self.assertTrue(cmd.install_dir is None)
cmd.finalize_options()
self.assertTrue(cmd.force)
self.assertTrue(cmd.skip_build)
self.assertEqual(cmd.build_dir, "/foo/bar")
self.assertEqual(cmd.install_dir, "/splat/funk")
示例11: _get_pypirc_command
# 需要导入模块: from distutils import core [as 别名]
# 或者: from distutils.core import Distribution [as 别名]
def _get_pypirc_command(self):
"""
Get the distutils command for interacting with PyPI configurations.
:return: the command.
"""
from distutils.core import Distribution
from distutils.config import PyPIRCCommand
d = Distribution()
return PyPIRCCommand(d)
示例12: test_build_ext
# 需要导入模块: from distutils import core [as 别名]
# 或者: from distutils.core import Distribution [as 别名]
def test_build_ext(self):
global ALREADY_TESTED
support.copy_xxmodule_c(self.tmp_dir)
self.xx_created = True
xx_c = os.path.join(self.tmp_dir, 'xxmodule.c')
xx_ext = Extension('xx', [xx_c])
dist = Distribution({'name': 'xx', 'ext_modules': [xx_ext]})
dist.package_dir = self.tmp_dir
cmd = build_ext(dist)
support.fixup_build_ext(cmd)
cmd.build_lib = self.tmp_dir
cmd.build_temp = self.tmp_dir
old_stdout = sys.stdout
if not test_support.verbose:
# silence compiler output
sys.stdout = StringIO()
try:
cmd.ensure_finalized()
cmd.run()
finally:
sys.stdout = old_stdout
if ALREADY_TESTED:
self.skipTest('Already tested in %s' % ALREADY_TESTED)
else:
ALREADY_TESTED = type(self).__name__
import xx
for attr in ('error', 'foo', 'new', 'roj'):
self.assertTrue(hasattr(xx, attr))
self.assertEqual(xx.foo(2, 5), 7)
self.assertEqual(xx.foo(13,15), 28)
self.assertEqual(xx.new().demo(), None)
if test_support.HAVE_DOCSTRINGS:
doc = 'This is a template module just for instruction.'
self.assertEqual(xx.__doc__, doc)
self.assertIsInstance(xx.Null(), xx.Null)
self.assertIsInstance(xx.Str(), xx.Str)
示例13: test_get_source_files
# 需要导入模块: from distutils import core [as 别名]
# 或者: from distutils.core import Distribution [as 别名]
def test_get_source_files(self):
modules = [Extension('foo', ['xxx'])]
dist = Distribution({'name': 'xx', 'ext_modules': modules})
cmd = build_ext(dist)
cmd.ensure_finalized()
self.assertEqual(cmd.get_source_files(), ['xxx'])
示例14: test_ext_fullpath
# 需要导入模块: from distutils import core [as 别名]
# 或者: from distutils.core import Distribution [as 别名]
def test_ext_fullpath(self):
ext = sysconfig.get_config_vars()['SO']
dist = Distribution()
cmd = build_ext(dist)
cmd.inplace = 1
cmd.distribution.package_dir = {'': 'src'}
cmd.distribution.packages = ['lxml', 'lxml.html']
curdir = os.getcwd()
wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + ext)
path = cmd.get_ext_fullpath('lxml.etree')
self.assertEqual(wanted, path)
# building lxml.etree not inplace
cmd.inplace = 0
cmd.build_lib = os.path.join(curdir, 'tmpdir')
wanted = os.path.join(curdir, 'tmpdir', 'lxml', 'etree' + ext)
path = cmd.get_ext_fullpath('lxml.etree')
self.assertEqual(wanted, path)
# building twisted.runner.portmap not inplace
build_py = cmd.get_finalized_command('build_py')
build_py.package_dir = {}
cmd.distribution.packages = ['twisted', 'twisted.runner.portmap']
path = cmd.get_ext_fullpath('twisted.runner.portmap')
wanted = os.path.join(curdir, 'tmpdir', 'twisted', 'runner',
'portmap' + ext)
self.assertEqual(wanted, path)
# building twisted.runner.portmap inplace
cmd.inplace = 1
path = cmd.get_ext_fullpath('twisted.runner.portmap')
wanted = os.path.join(curdir, 'twisted', 'runner', 'portmap' + ext)
self.assertEqual(wanted, path)
示例15: test_build_ext_inplace
# 需要导入模块: from distutils import core [as 别名]
# 或者: from distutils.core import Distribution [as 别名]
def test_build_ext_inplace(self):
etree_c = os.path.join(self.tmp_dir, 'lxml.etree.c')
etree_ext = Extension('lxml.etree', [etree_c])
dist = Distribution({'name': 'lxml', 'ext_modules': [etree_ext]})
cmd = build_ext(dist)
cmd.ensure_finalized()
cmd.inplace = 1
cmd.distribution.package_dir = {'': 'src'}
cmd.distribution.packages = ['lxml', 'lxml.html']
curdir = os.getcwd()
ext = sysconfig.get_config_var("SO")
wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + ext)
path = cmd.get_ext_fullpath('lxml.etree')
self.assertEqual(wanted, path)