Skip to content

Commit

Permalink
[cdd/setup.py] Add support for Python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelMarks committed Oct 9, 2023
1 parent 38859bf commit 093e84d
Showing 1 changed file with 72 additions and 1 deletion.
73 changes: 72 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,86 @@
extracts the `__author__` and `__version__`
"""

import sys
from ast import Assign, Constant, Str, parse
from distutils.sysconfig import get_python_lib
from functools import partial
from operator import attrgetter
from os import path
from os.path import extsep

from setuptools import find_packages, setup

if sys.version_info[:2] >= (3, 12):
import os
from sysconfig import _BASE_EXEC_PREFIX as BASE_EXEC_PREFIX
from sysconfig import _BASE_PREFIX as BASE_PREFIX
from sysconfig import _EXEC_PREFIX as EXEC_PREFIX
from sysconfig import _PREFIX as PREFIX
from sysconfig import get_python_version

def is_virtual_environment():
"""
Whether one is in a virtual environment
"""
return sys.base_prefix != sys.prefix or hasattr(sys, "real_prefix")

def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
"""Return the directory containing the Python library (standard or
site additions).
If 'plat_specific' is true, return the directory containing
platform-specific modules, i.e. any module from a non-pure-Python
module distribution; otherwise, return the platform-shared library
directory. If 'standard_lib' is true, return the directory
containing standard Python library modules; otherwise, return the
directory for site-specific modules.
If 'prefix' is supplied, use it instead of sys.base_prefix or
sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
"""
is_default_prefix = not prefix or os.path.normpath(prefix) in (
"/usr",
"/usr/local",
)
if prefix is None:
if standard_lib:
prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
else:
prefix = plat_specific and EXEC_PREFIX or PREFIX

if os.name == "posix":
if plat_specific or standard_lib:
# Platform-specific modules (any module from a non-pure-Python
# module distribution) or standard Python library modules.
libdir = sys.platlibdir
else:
# Pure Python
libdir = "lib"
libpython = os.path.join(prefix, libdir, "python" + get_python_version())
if standard_lib:
return libpython
elif is_default_prefix and not is_virtual_environment():
return os.path.join(prefix, "lib", "python3", "dist-packages")
else:
return os.path.join(libpython, "site-packages")
elif os.name == "nt":
if standard_lib:
return os.path.join(prefix, "Lib")
else:
return os.path.join(prefix, "Lib", "site-packages")
else:

class DistutilsPlatformError(Exception):
"""DistutilsPlatformError"""

raise DistutilsPlatformError(
"I don't know where Python installs its library "
"on platform '%s'" % os.name
)

else:
from distutils.sysconfig import get_python_lib

package_name = "cdd"

with open(
Expand Down

0 comments on commit 093e84d

Please sign in to comment.