Skip to content

Instantly share code, notes, and snippets.

@ishan1608
Last active February 3, 2025 15:34
Show Gist options
  • Save ishan1608/70be4c7e74074cc232435164100914a9 to your computer and use it in GitHub Desktop.
Save ishan1608/70be4c7e74074cc232435164100914a9 to your computer and use it in GitHub Desktop.
Checks whether all the installed packages has support for either the universal wheel or manylinux wheel.
import subprocess
import requests
PYPI_URL = 'https://pypi.org/pypi/{package}/json'
def get_installed_packages():
"""Get installed packages using pip freeze."""
output = subprocess.check_output(['pip', 'freeze'], text=True)
packages = []
for line in output.splitlines():
if '==' in line:
package_name = line.split('==')[0]
packages.append(package_name)
return packages
def get_wheel_info(package_name):
"""Fetch package wheel info from PyPI JSON API."""
url = PYPI_URL.format(package=package_name)
response = requests.get(url, timeout=5)
response.raise_for_status()
data = response.json()
# Get all wheels available
all_wheels = []
for version, files in data['releases'].items():
for file in files:
if file['packagetype'] == 'bdist_wheel':
all_wheels.append(file['filename'])
return all_wheels
def check_universal_wheel():
"""Check if all installed packages have universal wheels."""
packages = get_installed_packages()
for package in packages:
print(f'Checking {package}...')
wheels = get_wheel_info(package)
if not wheels:
print(f' ❌ No wheels found for {package}')
continue
has_universal = any('py3-none-any.whl' in wheel for wheel in wheels)
has_manylinux = any('manylinux2014_x86_64.whl' in wheel for wheel in wheels)
if has_universal:
print(f' ✅ {package} has a universal wheel')
elif has_manylinux:
print(f' ⚠️ {package} has a manylinux wheel')
else:
print(f' ❌ {package} does not have a supported wheel')
if __name__ == '__main__':
check_universal_wheel()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment