本文整理汇总了Python中pants.backend.python.tasks.setup_py.SetupPy类的典型用法代码示例。如果您正苦于以下问题:Python SetupPy类的具体用法?Python SetupPy怎么用?Python SetupPy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SetupPy类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_find_packages
def test_find_packages():
def assert_single_chroot(packages, namespace_packages, resources):
with yield_chroot(packages, namespace_packages, resources) as chroot:
p, n_p, r = SetupPy.find_packages(chroot)
assert p == set(packages + namespace_packages)
assert n_p == set(namespace_packages)
assert r == dict((k, set(v)) for (k, v) in resources.items())
# assert both packages and namespace packages work
assert_single_chroot(["foo"], [], {})
assert_single_chroot(["foo"], ["foo"], {})
# assert resources work
assert_single_chroot(["foo"], [], {"foo": ["blork.dat"]})
resources = {"foo": ["f0", os.path.join("bar", "baz", "f1"), os.path.join("bar", "baz", "f2")]}
assert_single_chroot(["foo"], [], resources)
# assert that nearest-submodule is honored
with yield_chroot(["foo", "foo.bar"], [], resources) as chroot:
_, _, r = SetupPy.find_packages(chroot)
assert r == {"foo": {"f0"}, "foo.bar": {os.path.join("baz", "f1"), os.path.join("baz", "f2")}}
# assert that nearest submodule splits on module prefixes
with yield_chroot(["foo", "foo.bar"], [], {"foo.bar1": ["f0"]}) as chroot:
_, _, r = SetupPy.find_packages(chroot)
assert r == {"foo": {"bar1/f0"}}
示例2: test_binary_target_injected_into_reduced_dependencies
def test_binary_target_injected_into_reduced_dependencies(self):
foo_bin_dep = self.create_python_library(relpath='foo/dep', name='dep')
foo_bin = self.create_python_binary(
relpath='foo/bin',
name='bin',
entry_point='foo.bin:foo',
dependencies=[
'foo/dep',
]
)
foo = self.create_python_library(
relpath='foo',
name='foo',
provides=dedent("""
setup_py(
name='foo',
version='0.0.0'
).with_binaries(
foo_binary='foo/bin'
)
""")
)
self.assertEqual(self.dependency_calculator.reduced_dependencies(foo),
OrderedSet([foo_bin, foo_bin_dep]))
entry_points = dict(SetupPy.iter_entry_points(foo))
self.assertEqual(entry_points, {'foo_binary': 'foo.bin:foo'})
with self.run_execute(foo, recursive=False) as created:
self.assertEqual([foo], list(created.keys()))
with self.run_execute(foo, recursive=True) as created:
self.assertEqual([foo], list(created.keys()))
示例3: test_find_packages
def test_find_packages():
def assert_single_chroot(packages, namespace_packages, resources):
with yield_chroot(packages, namespace_packages, resources) as chroot:
p, n_p, r = SetupPy.find_packages(chroot)
assert p == set(packages + namespace_packages)
assert n_p == set(namespace_packages)
assert r == dict((k, set(v)) for (k, v) in resources.items())
# assert both packages and namespace packages work
assert_single_chroot(['foo'], [], {})
assert_single_chroot(['foo'], ['foo'], {})
# assert resources work
assert_single_chroot(['foo'], [], {'foo': ['blork.dat']})
resources = {
'foo': [
'f0',
os.path.join('bar', 'baz', 'f1'),
os.path.join('bar', 'baz', 'f2'),
]
}
assert_single_chroot(['foo'], [], resources)
# assert that nearest-submodule is honored
with yield_chroot(['foo', 'foo.bar'], [], resources) as chroot:
_, _, r = SetupPy.find_packages(chroot)
assert r == {
'foo': {'f0'},
'foo.bar': {os.path.join('baz', 'f1'), os.path.join('baz', 'f2')}
}
# assert that nearest submodule splits on module prefixes
with yield_chroot(
['foo', 'foo.bar'],
[],
{'foo.bar1': ['f0']}) as chroot:
_, _, r = SetupPy.find_packages(chroot)
assert r == {'foo': {'bar1/f0'}}
示例4: test_nearest_subpackage
def test_nearest_subpackage():
# degenerate
assert SetupPy.nearest_subpackage("foo", []) == "foo"
assert SetupPy.nearest_subpackage("foo", ["foo"]) == "foo"
assert SetupPy.nearest_subpackage("foo", ["bar"]) == "foo"
# common prefix
assert "foo" == SetupPy.nearest_subpackage("foo.bar", ["foo"])
assert "foo.bar" == SetupPy.nearest_subpackage("foo.bar", ["foo", "foo.bar"])
assert "foo.bar" == SetupPy.nearest_subpackage("foo.bar.topo", ["foo", "foo.bar"])
assert "foo" == SetupPy.nearest_subpackage("foo.barization", ["foo", "foo.bar"])
示例5: test_nearest_subpackage
def test_nearest_subpackage():
# degenerate
assert SetupPy.nearest_subpackage('foo', []) == 'foo'
assert SetupPy.nearest_subpackage('foo', ['foo']) == 'foo'
assert SetupPy.nearest_subpackage('foo', ['bar']) == 'foo'
# common prefix
assert 'foo' == SetupPy.nearest_subpackage('foo.bar', ['foo'])
assert 'foo.bar' == SetupPy.nearest_subpackage(
'foo.bar', ['foo', 'foo.bar'])
assert 'foo.bar' == SetupPy.nearest_subpackage(
'foo.bar.topo', ['foo', 'foo.bar'])
assert 'foo' == SetupPy.nearest_subpackage(
'foo.barization', ['foo', 'foo.bar'])
示例6: test_binary_target_injected_into_reduced_dependencies_with_provider
def test_binary_target_injected_into_reduced_dependencies_with_provider(self):
bar_bin_dep = self.create_python_library(
relpath='bar/dep',
name='dep',
provides=dedent("""
setup_py(
name='bar_bin_dep',
version='0.0.0'
)
""")
)
bar_bin = self.create_python_binary(
relpath='bar/bin',
name='bin',
entry_point='bar.bin:bar',
dependencies=[
'bar/dep'
],
)
bar = self.create_python_library(
relpath='bar',
name='bar',
provides=dedent("""
setup_py(
name='bar',
version='0.0.0'
).with_binaries(
bar_binary='bar/bin'
)
""")
)
self.assertEqual(self.dependency_calculator.reduced_dependencies(bar),
OrderedSet([bar_bin, bar_bin_dep]))
self.assert_requirements(bar, {'bar_bin_dep==0.0.0'})
entry_points = dict(SetupPy.iter_entry_points(bar))
self.assertEqual(entry_points, {'bar_binary': 'bar.bin:bar'})
with self.run_execute(bar, recursive=False) as created:
self.assertEqual([bar], list(created.keys()))
with self.run_execute(bar, recursive=True) as created:
self.assertEqual({bar_bin_dep, bar}, set(created.keys()))
示例7: assert_requirements
def assert_requirements(self, target, expected):
reduced_dependencies = self.dependency_calculator.reduced_dependencies(target)
self.assertEqual(SetupPy.install_requires(reduced_dependencies), expected)
示例8: assert_single_chroot
def assert_single_chroot(packages, namespace_packages, resources):
with yield_chroot(packages, namespace_packages, resources) as chroot:
p, n_p, r = SetupPy.find_packages(chroot)
assert p == set(packages + namespace_packages)
assert n_p == set(namespace_packages)
assert r == dict((k, set(v)) for (k, v) in resources.items())
示例9: has_ns
def has_ns(stmt):
with temporary_file() as fp:
fp.write(stmt)
fp.flush()
return SetupPy.declares_namespace_package(fp.name)