MCPcopy
hub / github.com/pex-tool/pex / assert_build_sdist

Function assert_build_sdist

testing/build_system.py:25–69  ·  view source on GitHub ↗
(
    project_dir,  # type: str
    project_name,  # type: str
    version,  # type: str
    tmpdir,  # type: Any
)

Source from the content-addressed store, hash-verified

23
24
25def assert_build_sdist(
26 project_dir, # type: str
27 project_name, # type: str
28 version, # type: str
29 tmpdir, # type: Any
30):
31 # type: (...) -> None
32
33 def assert_expected_dist(dist):
34 # type: (Distribution) -> None
35 assert ProjectName(project_name) == dist.metadata.project_name
36 assert Version(version) == dist.metadata.version
37
38 sdist_dir = os.path.join(str(tmpdir), "sdist_dir")
39
40 # This test utility is used by all versions of Python Pex supports; so we need to use a Pip
41 # setup which is guaranteed to work with the current Python version.
42 pip_version = PipVersion.LATEST_COMPATIBLE
43 resolver_version = ResolverVersion.default(pip_version)
44
45 target = LocalInterpreter.create()
46 resolver = ConfiguredResolver(
47 PipConfiguration(version=pip_version, resolver_version=resolver_version)
48 )
49 location = build_sdist(
50 project_dir,
51 sdist_dir,
52 target,
53 resolver,
54 pip_version=pip_version,
55 )
56 assert not isinstance(location, Error), location
57 assert sdist_dir == os.path.dirname(location)
58
59 sdist = Distribution.load(str(location))
60 assert_expected_dist(sdist)
61
62 # Verify the sdist is valid such that we can build a wheel from it.
63 wheel_dir = os.path.join(str(tmpdir), "wheel_dir")
64 get_pip(version=pip_version, resolver=resolver).spawn_build_wheels(
65 requirements=[sdist.location], wheel_dir=wheel_dir
66 ).wait()
67 wheels = glob.glob(os.path.join(wheel_dir, "*.whl"))
68 assert 1 == len(wheels)
69 assert_expected_dist(Distribution.load(wheels[0]))

Calls 11

ConfiguredResolverClass · 0.90
PipConfigurationClass · 0.90
build_sdistFunction · 0.90
get_pipFunction · 0.90
assert_expected_distFunction · 0.85
spawn_build_wheelsMethod · 0.80
joinMethod · 0.45
defaultMethod · 0.45
createMethod · 0.45
loadMethod · 0.45
waitMethod · 0.45

Tested by 4