mirror of
https://github.com/actions/python-versions.git
synced 2025-04-04 22:39:40 +00:00
* fix: use `--upgrade` rather than `--ignore-installed` to upgrade pip This removes left over files when upgrading pip. * remove all installed python on macOS
25 lines
719 B
Python
25 lines
719 B
Python
import glob
|
|
import os.path
|
|
import sysconfig
|
|
from collections import defaultdict
|
|
|
|
|
|
def check_dist_info():
|
|
paths = set([sysconfig.get_path("purelib"), sysconfig.get_path("platlib")])
|
|
versions = defaultdict(list)
|
|
for path in paths:
|
|
pattern = os.path.join(path, "*.dist-info")
|
|
for dist_info in glob.glob(pattern):
|
|
name = os.path.basename(dist_info).split("-", maxsplit=1)[0]
|
|
versions[name].append(dist_info)
|
|
exit_code = 0
|
|
for name in versions:
|
|
if len(versions[name]) > 1:
|
|
print("multiple dist-info found for {}: {}".format(name, versions[name]))
|
|
exit_code = 1
|
|
exit(exit_code)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
check_dist_info()
|