Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bringing in python 3.12 support #37

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
exclude:
- os: macos-latest
python-version: "3.7"
Expand Down
3 changes: 1 addition & 2 deletions _pygim_build/build_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
def post_initialize(context):
md = dict(context.config.metadata)
md['dependencies'] = [urllib.parse.unquote(dep) for dep in md['dependencies']]
logger.debug(f"Metadata: {pformat(md)}")
context.config.metadata = context.config.metadata.__class__(md)
context.config.__dict__["metadata"] = context.config.metadata.__class__(md)
context.config.data['project']['dependencies'] = [
urllib.parse.unquote(dep) for dep in context.config.data['project']['dependencies']]

Expand Down
81 changes: 42 additions & 39 deletions pygim-common/_pygim/_magic/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,54 @@
from .._utils import has_instances, format_dict, TraitFunctions, is_subset
from .._error_msgs import type_error_msg

PY37, PY38, PY39, PY310, PY311 = (3, 7), (3, 8), (3, 9), (3, 10), (3, 11)
# NOTE: CodeObject documentation: https://docs.python.org/3/c-api/code.html#c.PyCodeObject

PY37, PY38, PY39, PY310, PY311, PY312 = (3, 7), (3, 8), (3, 9), (3, 10), (3, 11), (3, 12)
____ = _____ = ()


_PY_CODE_ARGS = dict(
argcount = (PY37, PY38, PY39, PY310, PY311),
posonlyargcount = (____, PY38, PY39, PY310, PY311),
kwonlyargcount = (PY37, PY38, PY39, PY310, PY311),
nlocals = (PY37, PY38, PY39, PY310, PY311),
stacksize = (PY37, PY38, PY39, PY310, PY311),
flags = (PY37, PY38, PY39, PY310, PY311),
codestring = (PY37, PY38, PY39, PY310, PY311),
constants = (PY37, PY38, PY39, PY310, PY311),
names = (PY37, PY38, PY39, PY310, PY311),
varnames = (PY37, PY38, PY39, PY310, PY311),
filename = (PY37, PY38, PY39, PY310, PY311),
name = (PY37, PY38, PY39, PY310, PY311),
qualname = (____, ____, ____, _____, PY311),
firstlineno = (PY37, PY38, PY39, PY310, PY311),
lnotab = (PY37, PY38, PY39, _____, _____),
linetable = (____, ____, ____, PY310, PY311),
exceptiontable = (____, ____, ____, _____, PY311),
freevars = (PY37, PY38, PY39, PY310, PY311),
cellvars = (PY37, PY38, PY39, PY310, PY311),
argcount = (PY37, PY38, PY39, PY310, PY311, PY312),
posonlyargcount = (____, PY38, PY39, PY310, PY311, PY312),
kwonlyargcount = (PY37, PY38, PY39, PY310, PY311, PY312),
nlocals = (PY37, PY38, PY39, PY310, PY311, PY312),
stacksize = (PY37, PY38, PY39, PY310, PY311, PY312),
flags = (PY37, PY38, PY39, PY310, PY311, PY312),
codestring = (PY37, PY38, PY39, PY310, PY311, PY312),
constants = (PY37, PY38, PY39, PY310, PY311, PY312),
names = (PY37, PY38, PY39, PY310, PY311, PY312),
varnames = (PY37, PY38, PY39, PY310, PY311, PY312),
filename = (PY37, PY38, PY39, PY310, PY311, PY312),
name = (PY37, PY38, PY39, PY310, PY311, PY312),
qualname = (____, ____, ____, _____, PY311, PY312),
firstlineno = (PY37, PY38, PY39, PY310, PY311, PY312),
lnotab = (PY37, PY38, PY39, _____, _____, _____),
linetable = (____, ____, ____, PY310, PY311, PY312),
exceptiontable = (____, ____, ____, _____, PY311, PY312),
freevars = (PY37, PY38, PY39, PY310, PY311, PY312),
cellvars = (PY37, PY38, PY39, PY310, PY311, PY312),
)

_CODE_OBJECT_VARS = dict(
co_argcount = (PY37, PY38, PY39, PY310, PY311),
co_cellvars = (PY37, PY38, PY39, PY310, PY311),
co_code = (PY37, PY38, PY39, PY310, PY311),
co_consts = (PY37, PY38, PY39, PY310, PY311),
co_exceptiontable = (____, ____, ____, _____, PY311),
co_filename = (PY37, PY38, PY39, PY310, PY311),
co_firstlineno = (PY37, PY38, PY39, PY310, PY311),
co_flags = (PY37, PY38, PY39, PY310, PY311),
co_freevars = (PY37, PY38, PY39, PY310, PY311),
co_kwonlyargcount = (PY37, PY38, PY39, PY310, PY311),
co_linetable = (____, ____, ____, PY310, PY311),
co_lnotab = (PY37, PY38, PY39, PY310, PY311),
co_name = (PY37, PY38, PY39, PY310, PY311),
co_names = (PY37, PY38, PY39, PY310, PY311),
co_nlocals = (PY37, PY38, PY39, PY310, PY311),
co_posonlyargcount = (____, PY38, PY39, PY310, PY311),
co_qualname = (____, ____, ____, _____, PY311),
co_stacksize = (PY37, PY38, PY39, PY310, PY311),
co_varnames = (PY37, PY38, PY39, PY310, PY311),
co_argcount = (PY37, PY38, PY39, PY310, PY311, PY312),
co_cellvars = (PY37, PY38, PY39, PY310, PY311, PY312),
co_code = (PY37, PY38, PY39, PY310, PY311, PY312),
co_consts = (PY37, PY38, PY39, PY310, PY311, PY312),
co_exceptiontable = (____, ____, ____, _____, PY311, PY312),
co_filename = (PY37, PY38, PY39, PY310, PY311, PY312),
co_firstlineno = (PY37, PY38, PY39, PY310, PY311, PY312),
co_flags = (PY37, PY38, PY39, PY310, PY311, PY312),
co_freevars = (PY37, PY38, PY39, PY310, PY311, PY312),
co_kwonlyargcount = (PY37, PY38, PY39, PY310, PY311, PY312),
co_linetable = (____, ____, ____, PY310, PY311, PY312),
co_lnotab = (PY37, PY38, PY39, PY310, PY311, _____),
co_name = (PY37, PY38, PY39, PY310, PY311, PY312),
co_names = (PY37, PY38, PY39, PY310, PY311, PY312),
co_nlocals = (PY37, PY38, PY39, PY310, PY311, PY312),
co_posonlyargcount = (____, PY38, PY39, PY310, PY311, PY312),
co_qualname = (____, ____, ____, _____, PY311, PY312),
co_stacksize = (PY37, PY38, PY39, PY310, PY311, PY312),
co_varnames = (PY37, PY38, PY39, PY310, PY311, PY312),
)

_ARGS_TO_VARS = dict(
Expand Down
3 changes: 2 additions & 1 deletion pygim-common/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools ~= 58.0", "wheel", "pdm-backend", "pybind11", "toml", "psutil"]
requires = ["setuptools ~= 70.0", "wheel", "pdm-backend", "pybind11", "toml", "psutil"]

[project]
name = "pygim-common"
Expand All @@ -22,6 +22,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Quality Assurance",
"Typing :: Typed",
Expand Down
12 changes: 9 additions & 3 deletions pygim-common/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,27 @@
# This is a bit hacky way to resolve passing arguments to setup.py.
# Invoked by:
# $ python -m build -w --config-setting python_only
CPP_FILES = sorted(Path(ROOT).rglob("*.cpp"))
[f.touch() for f in CPP_FILES]
CPP_FILE_DEPS = list(str(p.relative_to(ROOT)) for p in CPP_FILES)
if not psutil.Process().parent().cmdline()[-1] == "python_only":
ext_modules = [
Pybind11Extension("_pygim.common_fast",
list(str(p) for p in Path(ROOT).rglob("*.cpp")),
CPP_FILE_DEPS,
# Example: passing in the version to the compiled code
define_macros = [('VERSION_INFO', __version__)],
extra_compile_args=["--std=c++17", "-O3"],
#extra_compile_args=["-g", "-march=native", "-O3", "-fopenmp", "-std=c++17"],
),
]

import pprint

pygim = map(lambda v: ('pygim.' + v), find_namespace_packages('pygim'))
pygim_internal = map(lambda v: ('_pygim.' + v), find_namespace_packages('_pygim'))

#print("pygim", list(pygim))
#print("pygim_internal", list(pygim_internal))

cfg = {**pyproject["project"]}
cfg['packages']= list(pygim) + list(pygim_internal) + ['pygim', '_pygim']
Expand All @@ -43,6 +50,5 @@
cfg['cmdclass']={"build_ext": build_ext}
cfg['install_requires']=cfg.pop('dependencies')

#import pprint
#pprint.pprint(cfg)
pprint.pprint(cfg)
setup(**cfg)
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name = "python-gimmicks"
version = "0.2.3"
description = "Full Python Gimmicks project with all of its sub-projects."
readme = "README.rst"
requires-python = ">=3.7, <3.12"
requires-python = ">=3.7, <3.13"
authors = [
{email = "[email protected]"},
{name = "Teppo Perä"}
Expand All @@ -24,6 +24,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Quality Assurance",
"Typing :: Typed",
Expand Down
Loading