-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[README.md,setup.py,cdd/shared/pkg_utils.py,cdd/tests/{mocks/cstify.p…
…y,test_setup.py}] Python 3.13 support
- Loading branch information
1 parent
9cb55df
commit 7675deb
Showing
5 changed files
with
34 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
""" | ||
|
||
import sys | ||
from ast import Assign, Constant, Name, parse | ||
from ast import Assign, Name, parse | ||
from functools import partial | ||
from operator import attrgetter | ||
from os import path | ||
|
@@ -15,93 +15,22 @@ | |
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 | ||
|
||
Str = type( | ||
"_Never", | ||
tuple(), | ||
{ | ||
"__init__": lambda s=None, n=None, constant_value=None, string=None, col_offset=None, lineno=None: s | ||
or n | ||
}, | ||
) | ||
from ast import Del as Str | ||
else: | ||
from ast import Str | ||
|
||
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", | ||
) | ||
prefix = ( | ||
prefix or plat_specific and (BASE_EXEC_PREFIX or BASE_PREFIX) | ||
if standard_lib | ||
else (EXEC_PREFIX or PREFIX) | ||
) | ||
if sys.version_info[0] == 2: | ||
from itertools import ifilter as filter | ||
from itertools import imap as map | ||
|
||
class DistutilsPlatformError(Exception): | ||
"""DistutilsPlatformError""" | ||
if sys.version_info[:2] > (3, 7): | ||
from ast import Constant | ||
else: | ||
from ast import expr | ||
|
||
assert os.name in frozenset(("posix", "nt")), DistutilsPlatformError( | ||
"I don't know where Python installs its library " | ||
"on platform '{}'".format(os.name) | ||
) | ||
return ( | ||
( | ||
# plat_specific or standard_lib: | ||
# Platform-specific modules (any module from a non-pure-Python | ||
# module distribution) or standard Python library modules. | ||
# else: | ||
# Pure Python | ||
lambda libpython: ( | ||
libpython | ||
if standard_lib | ||
else ( | ||
os.path.join(prefix, "lib", "python3", "dist-packages") | ||
if is_default_prefix and not is_virtual_environment() | ||
else os.path.join(libpython, "site-packages") | ||
) | ||
) | ||
)( | ||
os.path.join( | ||
prefix, | ||
sys.platlibdir if plat_specific or standard_lib else "lib", | ||
"python" + get_python_version(), | ||
) | ||
) | ||
if os.name == "posix" | ||
else ( | ||
os.path.join(prefix, "Lib") | ||
if standard_lib | ||
else os.path.join(prefix, "Lib", "site-packages") | ||
) | ||
) | ||
# Constant. Will never be used in Python =< 3.8 | ||
Constant = type("Constant", (expr,), {}) | ||
|
||
else: | ||
from ast import Str | ||
from distutils.sysconfig import get_python_lib | ||
|
||
package_name = "cdd" | ||
|
||
|
@@ -113,22 +42,6 @@ class DistutilsPlatformError(Exception): | |
long_description = fh.read() | ||
|
||
|
||
def to_funcs(*paths): | ||
""" | ||
Produce function tuples that produce the local and install dir, respectively. | ||
:param paths: one or more str, referring to relative folder names | ||
:type paths: ```*paths``` | ||
:return: 2 functions | ||
:rtype: ```tuple[Callable[Optional[List[str]], str], Callable[Optional[List[str]], str]]``` | ||
""" | ||
return ( | ||
partial(path.join, path.dirname(__file__), package_name, *paths), | ||
partial(path.join, get_python_lib(prefix=""), package_name, *paths), | ||
) | ||
|
||
|
||
def main(): | ||
"""Main function for setup.py; this actually does the installation""" | ||
with open( | ||
|
@@ -165,18 +78,14 @@ def main(): | |
) | ||
|
||
setup( | ||
name="python-{}".format(package_name), | ||
name=package_name, | ||
author=__author__, | ||
author_email="[email protected]", | ||
version=__version__, | ||
url="https://github.com/offscale/{}".format(package_name), | ||
description=__description__, | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
url="https://github.com/offscale/{}-python".format(package_name), | ||
install_requires=["pyyaml"], | ||
test_suite="{}{}tests".format(package_name, path.extsep), | ||
packages=find_packages(), | ||
package_dir={package_name: package_name}, | ||
classifiers=[ | ||
"Development Status :: 3 - Alpha", | ||
"Environment :: Console", | ||
|
@@ -194,6 +103,7 @@ def main(): | |
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"Programming Language :: Python :: 3.13", | ||
"Programming Language :: Python :: Implementation", | ||
"Programming Language :: Python :: Implementation :: CPython", | ||
"Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator", | ||
|
@@ -203,6 +113,11 @@ def main(): | |
"Topic :: Software Development :: Compilers", | ||
"Topic :: Software Development :: Pre-processors", | ||
], | ||
license="(Apache-2.0 OR MIT)", | ||
license_files=["LICENSE-APACHE", "LICENSE-MIT"], | ||
install_requires=["pyyaml"], | ||
test_suite="{}{}tests".format(package_name, path.extsep), | ||
packages=find_packages(), | ||
python_requires=">=3.6", | ||
) | ||
|
||
|