Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""))
# Copy the pyproject.toml:
shutil.copyfile(
os.path.join(path, 'pyproject.toml'),
os.path.join(output_path, 'pyproject.toml')
)
# Get build backend and requirements from pyproject.toml:
with open(os.path.join(path, 'pyproject.toml')) as f:
build_sys = pytoml.load(f)['build-system']
backend = build_sys["build-backend"]
build_requires.extend(build_sys["requires"])
# Get a virtualenv with build requirements and get all metadata:
env = BuildEnvironment()
metadata = None
with env:
hooks = Pep517HookCaller(path, backend)
env.pip_install([transform_dep_for_pip(req) for req in build_requires])
reqs = hooks.get_requires_for_build_wheel({})
env.pip_install([transform_dep_for_pip(req) for req in reqs])
try:
metadata = hooks.prepare_metadata_for_build_wheel(path)
except Exception: # sadly, pep517 has no good error here
pass
if metadata is not None:
metadata_path = os.path.join(
path, metadata, "METADATA"
)
else:
# This is a wheel, so metadata should be in *.dist-info folder: