Comments (6)
I applied the patch to the conda-forge releases. They should work just fine now.
from clingo.
I can confirm that programs with python scripts do not run using python 3.12 and the packages provided on conda-forge.
#script (python)
#end.
from clingo.
To work with python 3.12, the file libpyclingo/_clingo.c has to be regenerated with cffi 1.16.0. You could apply the following patch to fix the issue:
diff --git a/libpyclingo/_clingo.c b/libpyclingo/_clingo.c
index 36a72d3c..2d6e4cca 100644
--- a/libpyclingo/_clingo.c
+++ b/libpyclingo/_clingo.c
@@ -612,7 +612,8 @@ extern "C" {
* _cffi_call_python_org, which on CPython is actually part of the
_cffi_exports[] array, is the function pointer copied from
- _cffi_backend.
+ _cffi_backend. If _cffi_start_python() fails, then this is set
+ to NULL; otherwise, it should never be NULL.
After initialization is complete, both are equal. However, the
first one remains equal to &_cffi_start_and_call_python until the
@@ -962,7 +963,7 @@ static int _cffi_initialize_python(void)
if (f != NULL && f != Py_None) {
PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME
- "\ncompiled with cffi version: 1.15.0"
+ "\ncompiled with cffi version: 1.16.0"
"\n_cffi_backend module: ", f);
modules = PyImport_GetModuleDict();
mod = PyDict_GetItemString(modules, "_cffi_backend");
@@ -1020,6 +1021,15 @@ static int _cffi_carefully_make_gil(void)
Python < 3.8 because someone might use a mixture of cffi
embedded modules, some of which were compiled before this file
changed.
+
+ In Python >= 3.12, this stopped working because that particular
+ tp_version_tag gets modified during interpreter startup. It's
+ arguably a bad idea before 3.12 too, but again we can't change
+ that because someone might use a mixture of cffi embedded
+ modules, and no-one reported a bug so far. In Python >= 3.12
+ we go instead for PyCapsuleType.tp_as_buffer, which is supposed
+ to always be NULL. We write to it temporarily a pointer to
+ a struct full of NULLs, which is semantically the same.
*/
#ifdef WITH_THREAD
@@ -1044,19 +1054,32 @@ static int _cffi_carefully_make_gil(void)
}
}
# else
+# if PY_VERSION_HEX < 0x030C0000
int volatile *lock = (int volatile *)&PyCapsule_Type.tp_version_tag;
- int old_value, locked_value;
+ int old_value, locked_value = -42;
assert(!(PyCapsule_Type.tp_flags & Py_TPFLAGS_HAVE_VERSION_TAG));
+# else
+ static struct ebp_s { PyBufferProcs buf; int mark; } empty_buffer_procs;
+ empty_buffer_procs.mark = -42;
+ PyBufferProcs *volatile *lock = (PyBufferProcs *volatile *)
+ &PyCapsule_Type.tp_as_buffer;
+ PyBufferProcs *old_value, *locked_value = &empty_buffer_procs.buf;
+# endif
while (1) { /* spin loop */
old_value = *lock;
- locked_value = -42;
if (old_value == 0) {
if (cffi_compare_and_swap(lock, old_value, locked_value))
break;
}
else {
+# if PY_VERSION_HEX < 0x030C0000
assert(old_value == locked_value);
+# else
+ /* The pointer should point to a possibly different
+ empty_buffer_procs from another C extension module */
+ assert(((struct ebp_s *)old_value)->mark == -42);
+# endif
/* should ideally do a spin loop instruction here, but
hard to do it portably and doesn't really matter I
think: PyEval_InitThreads() should be very fast, and
from clingo.
It works as far as I tried, thanks @rkaminsk
from clingo.
I also tried, and it does work, but it depends on old version of Python:
python >=3.9,<3.10.0a0
See https://conda-metadata-app.streamlit.app/?q=conda-forge%2Flinux-64%2Fclingo-5.7.1-py39hc10206b_1.conda. (Check the date).
I followed the instructions, but did not find a newer or better package.
from clingo.
@ejgroene While there are different build versions (e.g., https://conda-metadata-app.streamlit.app/?q=conda-forge%2Flinux-64%2Fclingo-5.7.1-py312h30efb56_1.conda ).
from clingo.
Related Issues (20)
- Solving iteratively (as in `examples/cc/solve_iteratively.cc` gives different results than solving using the CLI. HOT 6
- How to get atom numbers for symbols associated with facts in the Python Observer? HOT 5
- Computing minimal answer sets w.r.t. a subset of atoms HOT 11
- wrong grounding involving recursive conditional literals
- Is it possible to maintain order of literals? HOT 2
- Unexpected grounding blow-up in aggregates HOT 2
- Gringo considers unnecessary instantiations of rule heads. HOT 12
- graph.lp:2:1-5: error: syntax error, unexpected <IDENTIFIER> HOT 3
- how to write the "different than" symbol in a .lp file ? HOT 3
- understanding how to format an lp input graph file for clingo HOT 2
- How to check if #external predicates are defined properly? HOT 6
- Multiple conditions in the head of a condition literal HOT 11
- Absolute submodule paths would be welcome. HOT 6
- Cannot instantiate Comment AST using CommentType enum as argument.
- Benchmarking gringo HOT 1
- Grounder output description HOT 2
- Projected AllSAT with partial solutions in clingo HOT 5
- Does Clingo support floating-point number? HOT 1
- Rewrite: extern(Device, function) ==> function(Device) HOT 9
- avoid canonicalize_file_name HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clingo.