Last active
April 24, 2023 15:32
-
-
Save pcotret/4f52eabda537c87790f08147d996303c to your computer and use it in GitHub Desktop.
The idea is to get rid of distutils which is deprecated in Python 3.10 and normally removed in Python 3.12. For instance, it's used in Capstone disassembly engine.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_site_packages(): # pragma: no cover | |
try: | |
paths = site.getsitepackages() | |
if site.ENABLE_USER_SITE: | |
paths.append(site.getusersitepackages()) | |
return paths | |
except Exception: | |
try: | |
from distutils.sysconfig import get_python_lib | |
return [get_python_lib()] | |
# just incase, don't fail here, it's not worth it | |
except Exception: | |
return [] | |
def get_site_packages_wo_distutils(): | |
try: | |
paths = site.getsitepackages() | |
if site.ENABLE_USER_SITE: | |
paths.append(site.getusersitepackages()) | |
return paths | |
except Exception: | |
try: | |
from sysconfig import get_path | |
return [get_path("platlib")] | |
# just incase, don't fail here, it's not worth it | |
except Exception: | |
return [] | |
print(get_site_packages()) | |
print(get_site_packages_wo_distutils()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Capstone is impacted here.