From 60c39bb0c896732e90e6d101f1eae81f929cf0f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?=
 <alexey.pawlow@gmail.com>
Date: Thu, 17 Jun 2021 18:51:42 +0530
Subject: [PATCH 019/N] Customize site for MINGW
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Алексей <alexey.pawlow@gmail.com>
Co-authored-by: Christoph Reiter <reiter.christoph@gmail.com>
---
 Lib/site.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/Lib/site.py b/Lib/site.py
index aedf363..a08c6ec 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -90,6 +90,12 @@ USER_SITE = None
 USER_BASE = None
 
 
+# Same as defined in Lib/sysconfig.py
+# redeclared since sysconfig is large for site.
+# GCC[mingw*] use posix build system
+_POSIX_BUILD = os.name == 'posix' or \
+    (os.name == "nt" and 'GCC' in sys.version)
+
 def _trace(message):
     if sys.flags.verbose:
         print(message, file=sys.stderr)
@@ -299,7 +305,7 @@ def _getuserbase():
     def joinuser(*args):
         return os.path.expanduser(os.path.join(*args))
 
-    if os.name == "nt":
+    if os.name == "nt" and not _POSIX_BUILD:
         base = os.environ.get("APPDATA") or "~"
         return joinuser(base, _get_implementation())
 
@@ -320,7 +326,7 @@ def _get_path(userbase):
 
     implementation = _get_implementation()
     implementation_lower = implementation.lower()
-    if os.name == 'nt':
+    if os.name == 'nt' and not _POSIX_BUILD:
         ver_nodot = sys.winver.replace('.', '')
         return f'{userbase}\\{implementation}{ver_nodot}\\site-packages'
 
@@ -399,7 +405,7 @@ def getsitepackages(prefixes=None):
             abi_thread = 't'
         else:
             abi_thread = ''
-        if os.sep == '/':
+        if _POSIX_BUILD:
             libdirs = [sys.platlibdir]
             if sys.platlibdir != "lib":
                 libdirs.append("lib")
