Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, source_dir, build_backend, backend_path=None):
self.source_dir = os.path.abspath(source_dir)
self.build_backend = build_backend
self._subprocess_runner = pep517_subprocess_runner
if backend_path:
backend_path = [
pep517.wrappers.norm_and_check(self.source_dir, p) for p in backend_path
]
self.backend_path = backend_path
"install",
"--ignore-installed",
"--prefix",
self.path,
] + list(reqs)
run(
cmd,
block=True,
combine_stderr=True,
return_object=False,
write_to_stdout=False,
nospin=True,
)
class HookCaller(pep517.wrappers.Pep517HookCaller):
def __init__(self, source_dir, build_backend, backend_path=None):
self.source_dir = os.path.abspath(source_dir)
self.build_backend = build_backend
self._subprocess_runner = pep517_subprocess_runner
if backend_path:
backend_path = [
pep517.wrappers.norm_and_check(self.source_dir, p) for p in backend_path
]
self.backend_path = backend_path
def parse_special_directives(setup_entry, package_dir=None):
# type: (S, Optional[STRING_TYPE]) -> S
rv = setup_entry
if not package_dir:
package_dir = os.getcwd()
"install",
"--ignore-installed",
"--prefix",
self.path,
] + list(reqs)
run(
cmd,
block=True,
combine_stderr=True,
return_object=False,
write_to_stdout=False,
nospin=True,
)
class HookCaller(pep517.wrappers.Pep517HookCaller):
def __init__(self, source_dir, build_backend, backend_path=None):
self.source_dir = os.path.abspath(source_dir)
self.build_backend = build_backend
self._subprocess_runner = pep517_subprocess_runner
if backend_path:
backend_path = [
pep517.wrappers.norm_and_check(self.source_dir, p) for p in backend_path
]
self.backend_path = backend_path
def parse_special_directives(setup_entry, package_dir=None):
# type: (S, Optional[STRING_TYPE]) -> S
rv = setup_entry
if not package_dir:
package_dir = os.getcwd()
def __init__(self, source_dir, build_backend, backend_path=None):
self.source_dir = os.path.abspath(source_dir)
self.build_backend = build_backend
self._subprocess_runner = pep517_subprocess_runner
if backend_path:
backend_path = [
pep517.wrappers.norm_and_check(self.source_dir, p) for p in backend_path
]
self.backend_path = backend_path
if extra_environ:
env.update(extra_environ)
run(
cmd,
cwd=cwd,
env=env,
block=True,
combine_stderr=True,
return_object=False,
write_to_stdout=False,
nospin=True,
)
class BuildEnv(pep517.envbuild.BuildEnvironment):
def pip_install(self, reqs):
cmd = [
sys.executable,
"-m",
"pip",
"install",
"--ignore-installed",
"--prefix",
self.path,
] + list(reqs)
run(
cmd,
block=True,
combine_stderr=True,
return_object=False,
write_to_stdout=False,
"""))
# 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:
if extra_environ:
env.update(extra_environ)
run(
cmd,
cwd=cwd,
env=env,
block=True,
combine_stderr=True,
return_object=False,
write_to_stdout=False,
nospin=True,
)
class BuildEnv(pep517.envbuild.BuildEnvironment):
def pip_install(self, reqs):
cmd = [
sys.executable,
"-m",
"pip",
"install",
"--ignore-installed",
"--prefix",
self.path,
] + list(reqs)
run(
cmd,
block=True,
combine_stderr=True,
return_object=False,
write_to_stdout=False,
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:
metadata_path = os.path.join(
path,
[f for f in os.listdir(path) if f.endswith(".dist-info")][0],