本文整理汇总了Python中setuptools.dist.Distribution方法的典型用法代码示例。如果您正苦于以下问题:Python dist.Distribution方法的具体用法?Python dist.Distribution怎么用?Python dist.Distribution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类setuptools.dist
的用法示例。
在下文中一共展示了dist.Distribution方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_view
# 需要导入模块: from setuptools import dist [as 别名]
# 或者: from setuptools.dist import Distribution [as 别名]
def test_view(self):
stub_mod_call(self, cli)
tmpdir = mkdtemp(self)
os.chdir(tmpdir)
dist = Distribution(dict(
script_name='setup.py',
script_args=['npm', '--view'],
name='foo',
))
dist.parse_command_line()
dist.run_commands()
self.assertFalse(exists(join(tmpdir, 'package.json')))
# also log handlers removed.
self.assertEqual(len(getLogger('calmjs.cli').handlers), 0)
# written to stdout with the correct indentation level.
self.assertIn('\n "jquery": "~1.11.0"', sys.stdout.getvalue())
示例2: test_install_no_init_nodevnoprod
# 需要导入模块: from setuptools import dist [as 别名]
# 或者: from setuptools.dist import Distribution [as 别名]
def test_install_no_init_nodevnoprod(self):
# install implies init
stub_mod_call(self, cli)
stub_base_which(self, which_npm)
tmpdir = mkdtemp(self)
os.chdir(tmpdir)
dist = Distribution(dict(
script_name='setup.py',
script_args=['npm', '--install'],
name='foo',
))
dist.parse_command_line()
dist.run_commands()
with open(os.path.join(tmpdir, 'package.json')) as fd:
result = json.load(fd)
# The cli will still automatically write to that, as install
# implies init.
self.assertEqual(result, {
'dependencies': {'jquery': '~1.11.0'},
'devDependencies': {},
'name': 'foo',
})
self.assertEqual(self.call_args[0], ([which_npm, 'install'],))
示例3: test_install_init_install_production
# 需要导入模块: from setuptools import dist [as 别名]
# 或者: from setuptools.dist import Distribution [as 别名]
def test_install_init_install_production(self):
stub_mod_call(self, cli)
stub_base_which(self, which_npm)
tmpdir = mkdtemp(self)
os.chdir(tmpdir)
dist = Distribution(dict(
script_name='setup.py',
script_args=['npm', '--init', '--install', '--production'],
name='foo',
))
dist.parse_command_line()
dist.run_commands()
with open(os.path.join(tmpdir, 'package.json')) as fd:
result = json.load(fd)
self.assertEqual(result, {
'dependencies': {'jquery': '~1.11.0'},
'devDependencies': {},
'name': 'foo',
})
# Should still invoke install
self.assertEqual(self.call_args[0], (
[which_npm, 'install', '--production=true'],))
示例4: test_install_init_install_develop
# 需要导入模块: from setuptools import dist [as 别名]
# 或者: from setuptools.dist import Distribution [as 别名]
def test_install_init_install_develop(self):
stub_mod_call(self, cli)
stub_base_which(self, which_npm)
tmpdir = mkdtemp(self)
os.chdir(tmpdir)
dist = Distribution(dict(
script_name='setup.py',
script_args=['npm', '--init', '--install', '--development'],
name='foo',
))
dist.parse_command_line()
dist.run_commands()
with open(os.path.join(tmpdir, 'package.json')) as fd:
result = json.load(fd)
self.assertEqual(result, {
'dependencies': {'jquery': '~1.11.0'},
'devDependencies': {},
'name': 'foo',
})
# Should still invoke install
self.assertEqual(self.call_args[0], (
[which_npm, 'install', '--production=false'],))
示例5: test_install_view
# 需要导入模块: from setuptools import dist [as 别名]
# 或者: from setuptools.dist import Distribution [as 别名]
def test_install_view(self):
stub_mod_call(self, cli)
stub_base_which(self, which_npm)
tmpdir = mkdtemp(self)
os.chdir(tmpdir)
dist = Distribution(dict(
script_name='setup.py',
script_args=['npm', '--install', '--view'],
name='foo',
))
dist.parse_command_line()
dist.run_commands()
with open(os.path.join(tmpdir, 'package.json')) as fd:
result = json.load(fd)
self.assertEqual(result, {
'dependencies': {'jquery': '~1.11.0'},
'devDependencies': {},
'name': 'foo',
})
self.assertEqual(self.call_args[0], ([which_npm, 'install'],))
示例6: test_get_dist_package_decoding_error
# 需要导入模块: from setuptools import dist [as 别名]
# 或者: from setuptools.dist import Distribution [as 别名]
def test_get_dist_package_decoding_error(self):
# Quiet stdout from distutils logs
stub_stdouts(self)
# trailing comma
package_json = '{"dependencies": {"left-pad": "~1.1.1"},}'
# bad data could be created by a competiting package.
mock_provider = MockProvider({
self.pkgname: package_json,
})
mock_dist = pkg_resources.Distribution(
metadata=mock_provider, project_name='dummydist', version='0.0.0')
results = calmjs_dist.read_dist_egginfo_json(mock_dist)
# Should still not fail.
self.assertIsNone(results)
示例7: test_build_calmjs_artifacts_standard
# 需要导入模块: from setuptools import dist [as 别名]
# 或者: from setuptools.dist import Distribution [as 别名]
def test_build_calmjs_artifacts_standard(self):
dist = distutils_dist.Distribution()
build_cmd = dist.get_command_obj('build')
original_subcmds = list(build_cmd.sub_commands)
calmjs_dist.build_calmjs_artifacts(dist, 'build_artifact', False)
self.assertEqual(original_subcmds, build_cmd.sub_commands)
# keys are named after the build step.
calmjs_dist.build_calmjs_artifacts(dist, 'build_artifact', True)
self.assertEqual(
('build_artifact', calmjs_dist.has_calmjs_artifact_declarations),
build_cmd.sub_commands[-1],
)
calmjs_dist.build_calmjs_artifacts(dist, 'calmjs_artifact', True)
self.assertEqual(
('calmjs_artifact', calmjs_dist.has_calmjs_artifact_declarations),
build_cmd.sub_commands[-1],
)
示例8: test_view
# 需要导入模块: from setuptools import dist [as 别名]
# 或者: from setuptools.dist import Distribution [as 别名]
def test_view(self):
stub_mod_call(self, cli)
tmpdir = mkdtemp(self)
os.chdir(tmpdir)
dist = Distribution(dict(
script_name='setup.py',
script_args=['yarn', '--view'],
name='foo',
))
dist.parse_command_line()
dist.run_commands()
self.assertFalse(exists(join(tmpdir, 'package.json')))
# also log handlers removed.
self.assertEqual(len(getLogger('calmjs.cli').handlers), 0)
# written to stdout with the correct indentation level.
self.assertIn('\n "jquery": "~1.11.0"', sys.stdout.getvalue())
示例9: test_install_no_init_nodevnoprod
# 需要导入模块: from setuptools import dist [as 别名]
# 或者: from setuptools.dist import Distribution [as 别名]
def test_install_no_init_nodevnoprod(self):
# install implies init
stub_mod_call(self, cli)
stub_base_which(self, which_yarn)
tmpdir = mkdtemp(self)
os.chdir(tmpdir)
dist = Distribution(dict(
script_name='setup.py',
script_args=['yarn', '--install'],
name='foo',
))
dist.parse_command_line()
dist.run_commands()
with open(os.path.join(tmpdir, 'package.json')) as fd:
result = json.load(fd)
# The cli will still automatically write to that, as install
# implies init.
self.assertEqual(result, {
'dependencies': {'jquery': '~1.11.0'},
'devDependencies': {},
'name': 'foo',
})
self.assertEqual(self.call_args[0], ([which_yarn, 'install'],))
示例10: test_install_init_install_production
# 需要导入模块: from setuptools import dist [as 别名]
# 或者: from setuptools.dist import Distribution [as 别名]
def test_install_init_install_production(self):
stub_mod_call(self, cli)
stub_base_which(self, which_yarn)
tmpdir = mkdtemp(self)
os.chdir(tmpdir)
dist = Distribution(dict(
script_name='setup.py',
script_args=['yarn', '--init', '--install', '--production'],
name='foo',
))
dist.parse_command_line()
dist.run_commands()
with open(os.path.join(tmpdir, 'package.json')) as fd:
result = json.load(fd)
self.assertEqual(result, {
'dependencies': {'jquery': '~1.11.0'},
'devDependencies': {},
'name': 'foo',
})
# Should still invoke install
self.assertEqual(self.call_args[0], (
[which_yarn, 'install', '--production=true'],))
示例11: test_install_init_install_develop
# 需要导入模块: from setuptools import dist [as 别名]
# 或者: from setuptools.dist import Distribution [as 别名]
def test_install_init_install_develop(self):
stub_mod_call(self, cli)
stub_base_which(self, which_yarn)
tmpdir = mkdtemp(self)
os.chdir(tmpdir)
dist = Distribution(dict(
script_name='setup.py',
script_args=['yarn', '--init', '--install', '--development'],
name='foo',
))
dist.parse_command_line()
dist.run_commands()
with open(os.path.join(tmpdir, 'package.json')) as fd:
result = json.load(fd)
self.assertEqual(result, {
'dependencies': {'jquery': '~1.11.0'},
'devDependencies': {},
'name': 'foo',
})
# Should still invoke install
self.assertEqual(self.call_args[0], (
[which_yarn, 'install', '--production=false'],))
示例12: test_install_view
# 需要导入模块: from setuptools import dist [as 别名]
# 或者: from setuptools.dist import Distribution [as 别名]
def test_install_view(self):
stub_mod_call(self, cli)
stub_base_which(self, which_yarn)
tmpdir = mkdtemp(self)
os.chdir(tmpdir)
dist = Distribution(dict(
script_name='setup.py',
script_args=['yarn', '--install', '--view'],
name='foo',
))
dist.parse_command_line()
dist.run_commands()
with open(os.path.join(tmpdir, 'package.json')) as fd:
result = json.load(fd)
self.assertEqual(result, {
'dependencies': {'jquery': '~1.11.0'},
'devDependencies': {},
'name': 'foo',
})
self.assertEqual(self.call_args[0], ([which_yarn, 'install'],))
示例13: parse_configuration
# 需要导入模块: from setuptools import dist [as 别名]
# 或者: from setuptools.dist import Distribution [as 别名]
def parse_configuration(
distribution, command_options, ignore_option_errors=False):
"""Performs additional parsing of configuration options
for a distribution.
Returns a list of used option handlers.
:param Distribution distribution:
:param dict command_options:
:param bool ignore_option_errors: Whether to silently ignore
options, values of which could not be resolved (e.g. due to exceptions
in directives such as file:, attr:, etc.).
If False exceptions are propagated as expected.
:rtype: list
"""
meta = ConfigMetadataHandler(
distribution.metadata, command_options, ignore_option_errors)
meta.parse()
options = ConfigOptionsHandler(
distribution, command_options, ignore_option_errors)
options.parse()
return [meta, options]
示例14: notest_develop_with_setup_requires
# 需要导入模块: from setuptools import dist [as 别名]
# 或者: from setuptools.dist import Distribution [as 别名]
def notest_develop_with_setup_requires(self):
wanted = ("Could not find suitable distribution for "
"Requirement.parse('I-DONT-EXIST')")
old_dir = os.getcwd()
os.chdir(self.dir)
try:
try:
dist = Distribution({'setup_requires': ['I_DONT_EXIST']})
except DistutilsError:
e = sys.exc_info()[1]
error = str(e)
if error == wanted:
pass
finally:
os.chdir(old_dir)
示例15: test_package_data_in_sdist
# 需要导入模块: from setuptools import dist [as 别名]
# 或者: from setuptools.dist import Distribution [as 别名]
def test_package_data_in_sdist(self):
"""Regression test for pull request #4: ensures that files listed in
package_data are included in the manifest even if they're not added to
version control.
"""
dist = Distribution(SETUP_ATTRS)
dist.script_name = 'setup.py'
cmd = sdist(dist)
cmd.ensure_finalized()
# squelch output
quiet()
try:
cmd.run()
finally:
unquiet()
manifest = cmd.filelist.files
self.assertTrue(os.path.join('sdist_test', 'a.txt') in manifest)
self.assertTrue(os.path.join('sdist_test', 'b.txt') in manifest)
self.assertTrue(os.path.join('sdist_test', 'c.rst') not in manifest)