35 Commits

Author SHA1 Message Date
Nicolas Setton
1a230fb6c1 U515-001 gracefully handle the absence of a static python lib
Fix a Python error that occurred when the static lib was not
found.

Change-Id: I02096a913e03714a23bf25935cf056e332452dd5
2021-05-26 10:56:34 +01:00
Nicolas Boulenguez
aeea734354 Use ADAFLAGS CFLAGS CPPFLAGS LDFLAGS if they exist in the environment 2021-04-05 15:56:56 +02:00
Nicolas Boulenguez
1adbba0a53 python.gpr: compute one External_As_List instead of many Split.
This is more efficient and readable.
2021-04-05 15:55:44 +02:00
Nicolas Boulenguez
53d37d3ed4 Removed unused OS_Kind external variable.
The related part of setup.py is still required by the imported
gnatcoll.gpr.
2021-04-05 15:55:13 +02:00
Nicolas Boulenguez
bd6661cae4 In library projects, only set version in the relocatable case 2021-04-05 15:54:31 +02:00
Nicolas Boulenguez
92da3a0af8 Explicitly mark projects with the library qualifier 2021-04-05 15:46:19 +02:00
Dmitriy Anisimkov
335f34c0d2 Fix compilation issue in debug mode
no-tn-check

Add Unreferenced mark to unreferenced but necessary variable.

Change-Id: Ia27e62b67544a9ee78f0f7a2276771476a6e62b5
2021-03-23 16:51:44 +01:00
Adrien Boulanger
7a272ebf03 U305-023: Defensive code for the GIL
Trying to ensure/release the GIL when there is no interpreter will
raise an exception.

Change-Id: I4f85bfbfdd799b906848d2038b52825c4c709e54
2021-03-19 12:34:13 +01:00
Adrien Boulanger
fc63e2906b U201-012: Ensure frame state when calling python function.
Most of the commands can only be called if we have the GIL:
retrieve it.
Add a controlled type to automatically retrieve/free the GIL.
Lock every call using Py_INCREF/Py_DECREF.

Change-Id: I8989fcb3eacf6aedbb90056469536144a2795a3f
2021-02-25 11:17:13 +01:00
Adrien Boulanger
45aaa42efc TC15-079: Remove forbidden flags METH_OLDARGS
METH_OLDARGS (0x0, i.e. no flag) was obsolete in python2
and is forbidden with python3.

(no-precommit-check)
Change-Id: I576042492d74ca69bd59ed6ea6264cb7562c650f
2021-02-12 11:18:02 +01:00
Adrien Boulanger
1b4bf35ad9 TC21-029: Fix PyAdaMethodDescrObject function call
The cfunc is stored inside the descriptor when doing:

f = Foo()
f.bar() => cfunc is retrieved via tp_descr_get
Foo.bar(f) => cfunc is retrieved via tp_call

Without defining tp_call it will try to call a
wrapping function without the proper flags.

Change-Id: I164492895cee66dd4d9946b505c6866c2fea768a
2021-02-12 11:14:20 +01:00
Nicolas Setton
911e57fe44 TB10-016 do not link with the python .la in shared mode
Refinement on the previous change: do not pass the Python
static library to the linker if we are in the mode where
we are using the Python shared library.

Change-Id: I05a19d0f69a492106d04e612f299ea32ceeae1ea
2020-11-19 09:41:04 +00:00
Nicolas Setton
6e9769eb5a TB10-016 Make gnatcoll_python.gpr relocatable
Add a project variable to indicate the path to the libpython*.la,
and use this variable to find this when building.

Copy the .la file to the installation destination,
and use the variable to make sure the project generated by gprinstall
finds it.

Change-Id: Ic145f14339091ecb3bf6f10af14916de9fa176d4
2020-11-18 15:55:55 +00:00
Fabien Chouteau
c8425159d5 gnatcoll_*.gpr: rename external GNATCOLL_BUILD into GNATCOLL_BUILD_MODE
To avoid conflict with installed gnatcoll.gpr where GNATCOLL_BUILD means
library type.

Part of S709-037.

Change-Id: I5a0164505bee8e4a93409615e7a9d3b9a85c02f3
2020-09-10 18:41:55 +02:00
Fabien Chouteau
5262835c42 gnatcoll_*.gpr: introduce the GNATCOLL_BUILD external
Like for gnatcoll_core, these externals allow gnatcoll_*.gpr to be used
from a project that defines the BUILD external in an incompatible way.

Part of S709-037.

Change-Id: I409695393fb40d301e280a3f5ac7018e9d7bc81b
2020-08-25 16:07:04 +02:00
Adrien Boulanger
39e71d520d T416-023: Fix test
The test is creating a hidden property which can't be accessed
by at the python level => thus the last check is always wrong:
remove it.

Change-Id: I5dc8eff713e2e55cfcf97c5758a0fc6c463f69a2
2020-08-05 17:36:13 +02:00
Adrien Boulanger
7b0376a444 T416-023: Add python3-bindings tests
Change-Id: Id656b2905eaa4536e37ec00314479a9e248129e3
2020-07-08 17:06:58 +02:00
Adrien Boulanger
912c1b5e6a T612-027: Update library name for python3 bindings
The API between python2 and python3 has significantly changed
and having a different name will prevent dynamic linking issues.

Change-Id: I7ad5f5d470a658abfc67e65206a09919e0a68fe5
2020-07-08 16:53:44 +02:00
Nicolas Roche
78fae807b1 Update testsuite
* Adjust test layout
* Add a test for T701-014
* Add documentation on existing tests

Change-Id: Iafaf003ceec6af038c76bc6899b169865e3294be
2020-07-03 06:31:52 -07:00
Nicolas Roche
58ea71a57a Add testsuite framework for gnatcoll python 3.x binding
Part of T702-023

Change-Id: I73b3541df5bb5c441310c0ebb85a158cc9fe5eac
2020-07-02 04:08:27 -07:00
Nicolas Roche
6140ee8e69 Remove simulation of PyCObjects in Python 3.x
Capsules should be used instead. Tentative of PyCObject simulation
cannot work as destructors associated with PyCObject and PyCapsule
do not have the same semantic (one receive the encapsulated C
pointer and the other the capsule).

This fix also memory issues in GNATCOLL.Scripts.Python

Part of T601-026

Change-Id: Id1793d255998a55b10d507deff1ce707d79a8932
2020-06-16 09:55:43 +00:00
Nicolas Roche
928b7b25b3 Fix issue with declaration of static method with GNATCOLL.Scripts.
Python 3.x modified the way CFunction with METH_STATIC flag are
called. Self attribute passed to PyCFunction_New is not passed
anymore to the C code. Removing the METH_STATIC flag ensure that
self is preserved. This ensure GNATCOLL.Scripts can bind C data
to the declared C function.

Part of S821-014
Part of T519-009

Change-Id: Ib51501df8302e2f0451924e954f3fb8b37ea89f1
2020-05-28 12:17:19 +02:00
Nicolas Roche
9c61fb6fe9 Move declaration of PyGILState_* functions to GNATCOLL.Python.State
Part of S821-014

Change-Id: I3f43a40c59942f50ae29d286be858a7739922c74
2020-05-28 11:04:12 +02:00
Nicolas Roche
8796288dae Fix style issues
Part of S821-014

Change-Id: If7ffaa320df0922afe50067c116de1d265d34f55
2020-05-27 07:00:24 +00:00
Nicolas Roche
af397296fd Move declaration of python thread related bindings under GNATCOLL.Python
* Move PyEval_SaveThread to GNATCOLL.Python.Eval
* Move PyEval_RestoreThread to GNATCOLL.Python.Eval
* Move PyThreadState to GNATCOLL.Python
* Remove binding to PyEval_InitThreads (not needed since 3.7)
* Remove Has_Thread_Support (we assume python 3 always have thread
support)

Part of S821-014

Change-Id: I037b19be518a36600663df20d34f233c91bc4139
2020-05-27 07:00:24 +00:00