Skip to content

Commit

Permalink
Customize site for MINGW
Browse files Browse the repository at this point in the history
Co-authored-by: Алексей <[email protected]>
Co-authored-by: Christoph Reiter <[email protected]>
  • Loading branch information
Alexpux and lazka committed Aug 25, 2023
1 parent dfda95f commit a086a11
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Lib/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@
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)
Expand Down Expand Up @@ -273,7 +279,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, "Python")

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

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

Expand Down Expand Up @@ -361,7 +367,7 @@ def getsitepackages(prefixes=None):
continue
seen.add(prefix)

if os.sep == '/':
if _POSIX_BUILD:
libdirs = [sys.platlibdir]
if sys.platlibdir != "lib":
libdirs.append("lib")
Expand Down

0 comments on commit a086a11

Please sign in to comment.