From b04d5a8a4326e0d98529938f072f1a998d628790 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand Date: Fri, 8 Sep 2023 10:01:51 +0200 Subject: [PATCH] Fix python 3.11 support Add patch from open PR https://github.com/pjkundert/cpppo/pull/110 --- recipe/meta.yaml | 4 +- recipe/python-311-support-pr110.patch | 65 +++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 recipe/python-311-support-pr110.patch diff --git a/recipe/meta.yaml b/recipe/meta.yaml index a092f8d..7e3ee2e 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -10,11 +10,13 @@ source: sha256: 8c5a2947d6e9fd732d2d887fa02216beebb4068ab99e2590590f491425992bc6 patches: - remove_getattr_entrypoint.diff + # From https://github.com/pjkundert/cpppo/pull/110 + - python-311-support-pr110.patch build: noarch: python script: {{ PYTHON }} -m pip install . -vv - number: 0 + number: 1 entry_points: - enip_server = cpppo.server.enip.main:main - enip_client = cpppo.server.enip.client:main diff --git a/recipe/python-311-support-pr110.patch b/recipe/python-311-support-pr110.patch new file mode 100644 index 0000000..8a98745 --- /dev/null +++ b/recipe/python-311-support-pr110.patch @@ -0,0 +1,65 @@ +diff --git a/misc.py b/misc.py +index 99a41ad..f063b97 100644 +--- a/misc.py ++++ b/misc.py +@@ -136,41 +136,29 @@ def change_function( function, **kwds ): + + will change the func's co_filename to the specified string. + +- The types.CodeType constructor differs between Python 2 and 3; see +- type help(types.CodeType) at the interpreter prompt for information: ++ The types.CodeType constructor differs between Python versions; see ++ type help(types.CodeType) at the interpreter prompt for information. + +- Python2: +- code(argcount, nlocals, stacksize, flags, codestring, +- | constants, names, varnames, filename, name, firstlineno, +- | lnotab[, freevars[, cellvars]]) ++ """ + +- Python3: +- code(argcount, kwonlyargcount, nlocals, stacksize, flags, codestring, +- | constants, names, varnames, filename, name, firstlineno, +- | lnotab[, freevars[, cellvars]]) ++ version_lookup = { ++ (2, 7): ["co_argcount", "co_nlocals", "co_stacksize", "co_flags", "co_code", "co_consts", "co_names", "co_varnames", "co_filename", "co_name", "co_firstlineno", "co_lnotab", "co_freevars", "co_cellvars"], ++ (3, 7): ["co_argcount", "co_kwonlyargcount", "co_nlocals", "co_stacksize", "co_flags", "co_code", "co_consts", "co_names", "co_varnames", "co_filename", "co_name", "co_firstlineno", "co_lnotab", "co_freevars", "co_cellvars"], ++ (3, 8): ["co_argcount", "co_posonlyargcount", "co_kwonlyargcount", "co_nlocals", "co_stacksize", "co_flags", "co_code", "co_consts", "co_names", "co_varnames", "co_filename", "co_name", "co_firstlineno", "co_lnotab", "co_freevars", "co_cellvars"], ++ (3, 9): ["co_argcount", "co_posonlyargcount", "co_kwonlyargcount", "co_nlocals", "co_stacksize", "co_flags", "co_code", "co_consts", "co_names", "co_varnames", "co_filename", "co_name", "co_firstlineno", "co_lnotab", "co_freevars", "co_cellvars"], ++ (3, 10): ["co_argcount", "co_posonlyargcount", "co_kwonlyargcount", "co_nlocals", "co_stacksize", "co_flags", "co_code", "co_consts", "co_names", "co_varnames", "co_filename", "co_name", "co_firstlineno", "co_linetable", "co_freevars", "co_cellvars"], ++ (3, 11): ["co_argcount", "co_posonlyargcount", "co_kwonlyargcount", "co_nlocals", "co_stacksize", "co_flags", "co_code", "co_consts", "co_names", "co_varnames", "co_filename", "co_name", "co_qualname", "co_firstlineno", "co_linetable", "co_exceptiontable", "co_freevars", "co_cellvars"] ++ } + ++ version, minor = sys.version_info[0], sys.version_info[1] + +- """ +- # Enumerate all the __code__ attributes in the same order; types.CodeTypes +- # doesn't accept keyword args, only position. +- attrs = [ "co_argcount" ] +- if sys.version_info[0] >= 3: +- attrs += [ "co_kwonlyargcount" ] +- if sys.version_info[1] >= 8: +- attrs += [ "co_posonlyargcount" ] +- attrs += [ "co_nlocals", +- "co_stacksize", +- "co_flags", +- "co_code", +- "co_consts", +- "co_names", +- "co_varnames", +- "co_filename", +- "co_name", +- "co_firstlineno", +- "co_lnotab", +- "co_freevars", +- "co_cellvars" ] ++ # Clamp major version to 2 or 3 ++ version = max(min(version, 3), 2) ++ ++ # Clamp minor version to 7-11 ++ minor = max(min(minor, 11), 7) ++ ++ attrs = version_lookup[(version, minor)] + + assert all( k in attrs for k in kwds ), \ + "Invalid function keyword(s) supplied: %s" % ( ", ".join( kwds.keys() ))