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

Function create_dist

tests/test_environment.py:423–467  ·  view source on GitHub ↗
(
    tmpdir,  # type: Tempdir
    wheel_file_name,  # type: str
    project_name="foo",  # type: str
    version="1.0.0",  # type: str
)

Source from the content-addressed store, hash-verified

421
422
423def create_dist(
424 tmpdir, # type: Tempdir
425 wheel_file_name, # type: str
426 project_name="foo", # type: str
427 version="1.0.0", # type: str
428):
429 # type: (...) -> FingerprintedDistribution
430
431 try:
432 tags = CompatibilityTags.from_wheel(wheel_file_name)
433 except ValueError:
434 # Some tests purposefully use bad wheel names; so we just construct in-memory metadata.
435 pass
436 else:
437 wheel_file_name = tmpdir.join(wheel_file_name)
438 pnav = ProjectNameAndVersion.from_filename(wheel_file_name)
439 with safe_open(
440 os.path.join(
441 wheel_file_name,
442 "{project_name}-{version}.dist-info".format(
443 project_name=pnav.project_name, version=pnav.version
444 ),
445 "WHEEL",
446 ),
447 "w",
448 ) as fp:
449 print("Wheel-Version: 1.0", file=fp)
450 print("Generator: pex testing", __version__, file=fp)
451 print(
452 "Root-Is-Purelib:",
453 "false" if any(tag.abi != "none" for tag in tags) else "true",
454 file=fp,
455 )
456 for tag in tags:
457 print("Tag:", tag, file=fp)
458
459 return FingerprintedDistribution(
460 distribution=Distribution(
461 location=wheel_file_name,
462 metadata=create_dist_metadata(
463 project_name=project_name, version=version, location=wheel_file_name
464 ),
465 ),
466 fingerprint=wheel_file_name,
467 )
468
469
470@pytest.fixture

Calls 7

safe_openFunction · 0.90
DistributionClass · 0.90
create_dist_metadataFunction · 0.90
from_wheelMethod · 0.80
from_filenameMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected