Skip to content

Commit a086a11

Browse files
Alexpuxlazka
andcommitted
Customize site for MINGW
Co-authored-by: Алексей <alexey.pawlow@gmail.com> Co-authored-by: Christoph Reiter <reiter.christoph@gmail.com>
1 parent dfda95f commit a086a11

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Lib/site.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@
8888
USER_BASE = None
8989

9090

91+
# Same as defined in Lib/sysconfig.py
92+
# redeclared since sysconfig is large for site.
93+
# GCC[mingw*] use posix build system
94+
_POSIX_BUILD = os.name == 'posix' or \
95+
(os.name == "nt" and 'GCC' in sys.version)
96+
9197
def _trace(message):
9298
if sys.flags.verbose:
9399
print(message, file=sys.stderr)
@@ -273,7 +279,7 @@ def _getuserbase():
273279
def joinuser(*args):
274280
return os.path.expanduser(os.path.join(*args))
275281

276-
if os.name == "nt":
282+
if os.name == "nt" and not _POSIX_BUILD:
277283
base = os.environ.get("APPDATA") or "~"
278284
return joinuser(base, "Python")
279285

@@ -288,7 +294,7 @@ def joinuser(*args):
288294
def _get_path(userbase):
289295
version = sys.version_info
290296

291-
if os.name == 'nt':
297+
if os.name == 'nt' and not _POSIX_BUILD:
292298
ver_nodot = sys.winver.replace('.', '')
293299
return f'{userbase}\\Python{ver_nodot}\\site-packages'
294300

@@ -361,7 +367,7 @@ def getsitepackages(prefixes=None):
361367
continue
362368
seen.add(prefix)
363369

364-
if os.sep == '/':
370+
if _POSIX_BUILD:
365371
libdirs = [sys.platlibdir]
366372
if sys.platlibdir != "lib":
367373
libdirs.append("lib")

0 commit comments

Comments
 (0)