Fix PNNX ubuntu -> linux bug (#7050)

This commit is contained in:
Glenn Jocher 2023-12-18 16:22:30 +01:00 committed by GitHub
parent 28593dfb1c
commit e9def85f1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -459,11 +459,14 @@ class Exporter:
f'{prefix} WARNING ⚠️ PNNX not found. Attempting to download binary file from '
'https://github.com/pnnx/pnnx/.\nNote PNNX Binary file must be placed in current working directory '
f'or in {ROOT}. See PNNX repo for full installation instructions.')
_, assets = get_github_assets(repo='pnnx/pnnx', retry=True)
system = 'macos' if MACOS else 'ubuntu' if LINUX else 'windows' # operating system
asset = [x for x in assets if system in x][0] if assets else \
f'https://github.com/pnnx/pnnx/releases/download/20230816/pnnx-20230816-{system}.zip' # fallback
asset = attempt_download_asset(asset, repo='pnnx/pnnx', release='latest')
system = ['macos'] if MACOS else ['windows'] if WINDOWS else ['ubuntu', 'linux'] # operating system
try:
_, assets = get_github_assets(repo='pnnx/pnnx', retry=True)
url = [x for x in assets if any(s in x for s in system)][0]
except Exception as e:
url = f'https://github.com/pnnx/pnnx/releases/download/20231127/pnnx-20231127-{system[0]}.zip'
LOGGER.warning(f'{prefix} WARNING ⚠️ PNNX GitHub assets not found: {e}, using default {url}')
asset = attempt_download_asset(url, repo='pnnx/pnnx', release='latest')
if check_is_path_safe(Path.cwd(), asset): # avoid path traversal security vulnerability
unzip_dir = Path(asset).with_suffix('')
(unzip_dir / name).rename(pnnx) # move binary to ROOT