Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def rmdir(path: Path):
logging.info(f"removing directory {path}")
try:
if WINDOWS:
os.system(f'rmdir /S /Q "{str(path)}"')
else:
shutil.rmtree(path)
except FileNotFoundError:
pass
def is_valid(self):
return (
self.python_path.is_file()
and (self.bin_path / ("pip" if not WINDOWS else "pip.exe")).is_file()
)
def get_venv_metadata_for_package(self, package: str) -> VenvMetadata:
data = json.loads(
get_script_output(
self.python_path, VENV_METADATA_INSPECTOR, package, str(self.bin_path)
)
)
app_paths = [Path(p) for p in data["app_paths"]]
if WINDOWS:
windows_bin_paths = set()
for app in app_paths:
# windows has additional files staring with the same name that are required
# to run the app
for win_exec in app.parent.glob(f"{app.name}*.exe"):
windows_bin_paths.add(win_exec)
data["app_paths"] = list(windows_bin_paths)
else:
data["app_paths"] = app_paths
data["apps_of_dependencies"] = []
for dep, raw_paths in data["app_paths_of_dependencies"].items():
paths = [Path(raw_path) for raw_path in raw_paths]
data["app_paths_of_dependencies"][dep] = paths
data["apps_of_dependencies"] += [path.name for path in paths]