pyperl3 2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. pyperl3-2.0/CHANGELOG +341 -0
  2. pyperl3-2.0/LICENSE +17 -0
  3. pyperl3-2.0/MANIFEST.in +10 -0
  4. pyperl3-2.0/PKG-INFO +159 -0
  5. pyperl3-2.0/Python-Object/Makefile.PL +42 -0
  6. pyperl3-2.0/Python-Object/lib/Python/Err.pm +200 -0
  7. pyperl3-2.0/Python-Object/lib/Python/Object.pm +511 -0
  8. pyperl3-2.0/Python-Object/lib/Python.pm +299 -0
  9. pyperl3-2.0/README.md +133 -0
  10. pyperl3-2.0/docs/TODO +26 -0
  11. pyperl3-2.0/docs/perlmodule.pod +477 -0
  12. pyperl3-2.0/licenses/Artistic +131 -0
  13. pyperl3-2.0/licenses/Copying +250 -0
  14. pyperl3-2.0/pyproject.toml +38 -0
  15. pyperl3-2.0/setup.cfg +4 -0
  16. pyperl3-2.0/setup.py +163 -0
  17. pyperl3-2.0/src/_pyperl_bootstrap.py +133 -0
  18. pyperl3-2.0/src/dbi.py +58 -0
  19. pyperl3-2.0/src/dbi2.py +384 -0
  20. pyperl3-2.0/src/native/Object.xs +1047 -0
  21. pyperl3-2.0/src/native/PerlPyErr.h +14 -0
  22. pyperl3-2.0/src/native/bridge_state.h +21 -0
  23. pyperl3-2.0/src/native/lang_lock.c +121 -0
  24. pyperl3-2.0/src/native/lang_lock.h +54 -0
  25. pyperl3-2.0/src/native/lang_map.c +187 -0
  26. pyperl3-2.0/src/native/lang_map.h +8 -0
  27. pyperl3-2.0/src/native/opcode.c +43 -0
  28. pyperl3-2.0/src/native/perlmodule.c +958 -0
  29. pyperl3-2.0/src/native/perlmodule.h +54 -0
  30. pyperl3-2.0/src/native/pycompat.h +30 -0
  31. pyperl3-2.0/src/native/pyo.c +620 -0
  32. pyperl3-2.0/src/native/pyo.h +18 -0
  33. pyperl3-2.0/src/native/svrv_array.c +572 -0
  34. pyperl3-2.0/src/native/svrv_collections.h +29 -0
  35. pyperl3-2.0/src/native/svrv_hash.c +286 -0
  36. pyperl3-2.0/src/native/svrv_object.c +662 -0
  37. pyperl3-2.0/src/native/svrv_object.h +27 -0
  38. pyperl3-2.0/src/native/thrd_ctx.c +102 -0
  39. pyperl3-2.0/src/native/thrd_ctx.h +34 -0
  40. pyperl3-2.0/src/native/try_perlapi.c +317 -0
  41. pyperl3-2.0/src/native/try_perlapi.h +22 -0
  42. pyperl3-2.0/src/native/typemap +32 -0
  43. pyperl3-2.0/src/perl.py +65 -0
  44. pyperl3-2.0/src/perlmod.py +203 -0
  45. pyperl3-2.0/src/perlpickle.py +57 -0
  46. pyperl3-2.0/src/perlsh.py +28 -0
  47. pyperl3-2.0/src/pyperl3.egg-info/PKG-INFO +159 -0
  48. pyperl3-2.0/src/pyperl3.egg-info/SOURCES.txt +86 -0
  49. pyperl3-2.0/src/pyperl3.egg-info/dependency_links.txt +1 -0
  50. pyperl3-2.0/src/pyperl3.egg-info/entry_points.txt +2 -0
  51. pyperl3-2.0/src/pyperl3.egg-info/top_level.txt +8 -0
  52. pyperl3-2.0/t/TestClass.pm +51 -0
  53. pyperl3-2.0/t/apply.py +126 -0
  54. pyperl3-2.0/t/basic.py +56 -0
  55. pyperl3-2.0/t/defined.py +32 -0
  56. pyperl3-2.0/t/eval.py +16 -0
  57. pyperl3-2.0/t/hashop.py +62 -0
  58. pyperl3-2.0/t/import.py +32 -0
  59. pyperl3-2.0/t/kw-arg.py +70 -0
  60. pyperl3-2.0/t/listop.py +91 -0
  61. pyperl3-2.0/t/obj-fail.py +46 -0
  62. pyperl3-2.0/t/obj.py +68 -0
  63. pyperl3-2.0/t/py-obj.py +88 -0
  64. pyperl3-2.0/t/safecall.py +69 -0
  65. pyperl3-2.0/t/socket.py +23 -0
  66. pyperl3-2.0/t/thr-basic.py +36 -0
  67. pyperl3-2.0/t/thr-conc.py +43 -0
  68. pyperl3-2.0/t/thr-more.py +14 -0
  69. pyperl3-2.0/t/thr-svrv.py +56 -0
  70. pyperl3-2.0/t/wantarray.py +58 -0
  71. pyperl3-2.0/tests/__init__.py +0 -0
  72. pyperl3-2.0/tests/run.py +10 -0
  73. pyperl3-2.0/tests/test_async.py +153 -0
  74. pyperl3-2.0/tests/test_basic.py +58 -0
  75. pyperl3-2.0/tests/test_bridge.py +265 -0
  76. pyperl3-2.0/tests/test_dbi_adapters.py +110 -0
  77. pyperl3-2.0/tests/test_defined.py +27 -0
  78. pyperl3-2.0/tests/test_eval.py +16 -0
  79. pyperl3-2.0/tests/test_hashop.py +116 -0
  80. pyperl3-2.0/tests/test_imports.py +99 -0
  81. pyperl3-2.0/tests/test_perl_host.py +68 -0
  82. pyperl3-2.0/tests/test_perl_threads.py +102 -0
  83. pyperl3-2.0/tests/test_protocols.py +186 -0
  84. pyperl3-2.0/tests/test_resources.py +65 -0
  85. pyperl3-2.0/tests/test_subinterpreters.py +121 -0
  86. pyperl3-2.0/tests/thread_helpers.py +44 -0
  87. pyperl3-2.0/tools/check_dbi.py +10 -0
  88. pyperl3-2.0/tools/perl-build-flags.pl +3 -0
pyperl3-2.0/CHANGELOG ADDED
@@ -0,0 +1,341 @@
1
+ 2026-11-30 PyPerl 2.0
2
+
3
+ Use pyperl3 as the Python distribution name. Python programs continue to
4
+ import perl, and Perl programs continue to use Python.
5
+
6
+ Support CPython 3.10 through 3.15.2. Python source distributions
7
+ and wheels bundle the Perl modules for the selected libperl.
8
+
9
+ Credit Per Øyvind Karlsen as an author and long-time maintainer
10
+ alongside original author ActiveState. The Python distribution and
11
+ Perl modules now share the same version number.
12
+
13
+
14
+ 2001-03-06 Gisle Aas <gisle@ActiveState.com>
15
+
16
+ Release 1.0.1
17
+
18
+ Perl interpreter now destructed when a thread terminates even on
19
+ Windows.
20
+
21
+ Avoid direct dependency from perl2.so to Object.so. This makes it
22
+ much easier to create relocatable binary builds. Some adjustments
23
+ to the Win32 code because of this.
24
+
25
+ Make perlmod.py module thread aware and its PerlModule class now
26
+ provide an wantarray attribute.
27
+
28
+
29
+
30
+ 2001-03-01 Gisle Aas <gisle@ActiveState.com>
31
+
32
+ Release 1.0
33
+
34
+ Introduced dbi2.py: A Perl DBI adaptor module that conforms
35
+ to Python's own DB API
36
+
37
+ Introduced perlmod.py: Simplified access to existing Perl
38
+ library modules from Python.
39
+
40
+ Added some docstrings.
41
+
42
+
43
+
44
+ 2001-02-23 Gisle Aas <gisle@ActiveState.com>
45
+
46
+ Release 1.0-beta8
47
+
48
+ Escape potential safe compartment for perl.defined()
49
+ and perl.get_ref() calls.
50
+
51
+
52
+
53
+ 2001-02-01 Gisle Aas <gisle@ActiveState.com>
54
+
55
+ Release 1.0-beta7
56
+
57
+ Introduced RTDL_GLOBAL hack for platforms that use dlopen(3). After
58
+ this there should not be any need for patching neither perl nor
59
+ python.
60
+
61
+ Override pysvrv_nonzero so that len() does not have to lie any more.
62
+
63
+ Some prototype changes.
64
+
65
+
66
+
67
+ 2001-01-11 Gisle Aas <gisle@ActiveState.com>
68
+
69
+ Release 1.0-beta6
70
+
71
+ Win32 portability tweaks:
72
+ - make sure svrv_object.c is compiled as C++ (by renaming)
73
+ - disable JMPENV code (required internal API not exported on windows)
74
+ - deal with space in the path to python.exe
75
+
76
+ Documentation updates (mostly regading MULTI_PERL)
77
+
78
+ The dbi.py module does not insist on not working just because
79
+ MULTI_PERL is enabled.
80
+
81
+
82
+
83
+ 2001-01-03 Gisle Aas <gisle@ActiveState.com>
84
+
85
+ Release 1.0-beta5
86
+
87
+ Make it possible to pass 'perl ref' objects to python even
88
+ for MULTI_PERL builds. For this to be safe these objects now
89
+ contain a pointer to perl interpreter that owns them, and the
90
+ objects are only unwrapped when passed to the right interpreter.
91
+
92
+ Python::Import() did not release the python lock as it should.
93
+
94
+ Fix refcount error for perl.get_ref("@")
95
+
96
+ Renamed patches/python-16-dynload-global to python-20-...
97
+
98
+
99
+
100
+ 2000-12-22 Gisle Aas <gisle@ActiveState.com>
101
+
102
+ Release 1.0-beta4
103
+
104
+ Implemented Python::Import()
105
+
106
+ Implemented Python::exec() and Python::eval()
107
+
108
+ Make it possible to boot the symbiosis from perl, i.e. use this
109
+ code base to embed Python in Perl. This support is still very
110
+ rough. It is enabled by touching the file 'BOOT_FROM_PERL'
111
+ before building.
112
+
113
+ Some Win32 tweaks for Python 2.0
114
+
115
+
116
+
117
+ 2000-11-14 Gisle Aas <gisle@ActiveState.com>
118
+
119
+ Release 1.0-beta3
120
+
121
+ Python lists wrapped up in Python::Object now support builtin
122
+ push/pop/shift/unshift/splice and exists.
123
+
124
+ Fixed non MULTI_PERL builds. Did not compile because of missing dTHX
125
+ declarations and a dCTX that expanded to nothing.
126
+
127
+ perlsh.py will now use Term::ReadLine. This allow command line editing.
128
+
129
+
130
+
131
+ 2000-10-02 Gisle Aas <gisle@ActiveState.com>
132
+
133
+ Release 1.0-beta2
134
+
135
+ Win32 builds should work now.
136
+
137
+
138
+
139
+ 2000-09-20 Gisle Aas <gisle@ActiveState.com>
140
+
141
+ Release 1.0-beta1
142
+
143
+ The alpha zope-perl distribution has now been splitted into two
144
+ different distributions: 'pyperl' and 'zoperl'. The 'pyperl'
145
+ distribution contains the general stuff for embedding perl in
146
+ python. There is nothing Zope specific in it. The 'zoperl'
147
+ distribution depends on 'pyperl' and contains 3 Zope products
148
+ (written in Python) that enable perl for Zope.
149
+
150
+ This is the 'pyperl' package. Techinically this release is
151
+ identical to the 'perl for python' part of zope-perl-0.2.a7.
152
+
153
+
154
+
155
+ 2000-09-17 Gisle Aas <gisle@ActiveState.com>
156
+
157
+ Release 0.2.a7
158
+
159
+ Introduced my own thread specific struct; thrd_ctx.[hc]
160
+ It surely needs porting to non-pthread platforms.
161
+
162
+ Implemented perl.safecall() and made the other entry points
163
+ able to escape the last compartment and opmask.
164
+
165
+ Zope PerlMethods are now compiled and executed inside
166
+ a safe compartment. PerlMethod icon reverted to old look.
167
+
168
+ Added some concurrency tests and others to the test suite.
169
+
170
+
171
+
172
+ 2000-09-11 Gisle Aas <gisle@ActiveState.com>
173
+
174
+ Release 0.2.a6
175
+
176
+ The default build flavour of "Perl for Python" is now MULTI_PERL.
177
+ It means that each python thread get its own perl interpreter.
178
+ This avoids the need for a perl lock and allow each the threads to run
179
+ with full concurrency when inside perl. The downside is that perl data
180
+ can not be passed back to python in this mode.
181
+
182
+ Adjusted Zope products to be compatible with MULTI_PERL.
183
+
184
+ Added a README file for ZDBI_DA, mostly to explain the connection
185
+ string format.
186
+
187
+ Build patch (less hardcoding of perl/python paths)
188
+ by Joseph Wayne Norton <norton@arseed.co.jp>
189
+
190
+ Implemented perl.defined() function.
191
+
192
+ Implemented Python::id() function.
193
+
194
+ Made the PerlMethod icon look more dangerous :-)
195
+
196
+
197
+
198
+ 2000-08-31 Gisle Aas <gisle@ActiveState.com>
199
+
200
+ Release 0.1.a5
201
+
202
+ ZDBI_DA can now except multiple statements per query.
203
+ Also implements close() method. Based on patch from
204
+ Joseph Wayne Norton <norton@alum.mit.edu>.
205
+
206
+ The dbi.py file is now installed
207
+
208
+ Invoke SETMAGIC after hash updates. Makes updates to
209
+ tied hashes work.
210
+
211
+ Completed ithread-perl support.
212
+
213
+ PerlMethod tries to be smart about the size of the editing
214
+ textarea.
215
+
216
+
217
+
218
+ 2000-08-21 Gisle Aas <gisle@ActiveState.com>
219
+
220
+ Release 0.1.a4
221
+
222
+ Support builds with perl-5.6 compiled with ithread support.
223
+ But an ithread enabled perl can currently only be invoked from
224
+ the main python thread so it is not usable for Zope yet.
225
+
226
+ Disabled dysfunctional 'define_macros' in setup.py
227
+
228
+ Introduced two ways of calling python methods with keyword
229
+ arguments from perl $o->foo($pos1, *key => $val) and
230
+ $o->foo($pos1, KW(key => $val))
231
+
232
+ Implemented Python::apply($func, \@arg, \%kw)
233
+
234
+ Implemented Python::complex($real, $imag)
235
+
236
+ Fixed refcount error with Python::Err objects (type object where
237
+ decremented twice in the destructor)
238
+
239
+ Reindentation of some C source files.
240
+
241
+ Zope PerlMethod now use "Change Perl Method" permissions.
242
+ This also covers PUT method.
243
+
244
+ Zope PerlMethods can now be edited through ftp (and possibly WebDAV).
245
+ This is cool as it allow them to be edited in emacs directly.
246
+
247
+ Zope PerlMethods now support the document_src method. It means
248
+ that if you have a perl method that you can access as:
249
+
250
+ http://myzope:8080/d/foo
251
+
252
+ then you can get back the source of the method as plain (readable)
253
+ perl function with:
254
+
255
+ http://myzope:8080/d/foo/document_src
256
+
257
+
258
+
259
+ 2000-08-14 Gisle Aas <gisle@ActiveState.com>
260
+
261
+ Release 0.1.a3
262
+
263
+ Moved API methods out of the Python::Object namespace
264
+ and made them plain functions in the Python:: namespace.
265
+ This remove stupid limitation of what real attributes names
266
+ can be used safely with the AUTOLOAD mapping.
267
+
268
+ Python::Object constructors are now plain functions like
269
+ long(), list(), dict() in the Python:: namespace.
270
+
271
+ Overloading of hash/array/call deref for Python::Object.
272
+ It means $list->[0], @$list, $dict->{foo}, %$dict, and
273
+ $callable->($arg1, $arg2) now all work.
274
+
275
+ Python::Err->Raise() is now Python::raise()
276
+
277
+ Python::len() and Python::hash() did not croak when an
278
+ exception was raised.
279
+
280
+ Force keys of lists and tuples to be interpreted as integers
281
+ for PyObject_{Get,Set,Del}Item
282
+
283
+ Python::Object sequence/mapping attributes now unwrap
284
+ in list context.
285
+
286
+ PyXXX_Check() functions can now be passed non-Python::Object
287
+ arguments.
288
+
289
+ Python::Err::Exception() and sister functions now take an
290
+ optional single argument which is tested against the
291
+ corresponding exception type. Still not a subclass test as
292
+ it probably ought to be.
293
+
294
+ Arguments to Zope PerlMethods are now automatically
295
+ extracted from @_.
296
+
297
+ Introduced zope-method.pod
298
+
299
+ Various documentation updates.
300
+
301
+
302
+
303
+
304
+ 2000-08-08 Gisle Aas <gisle@ActiveState.com>
305
+
306
+ Release 0.1.a2
307
+
308
+ Force integer key for {Get,Set,Del}Item on
309
+ sequences.
310
+
311
+ Fix building of perlmodule when python is compiled
312
+ without thread support.
313
+
314
+ Perl data can now be picked with Storable 0.7.
315
+ Pickling of perl data enabled by loading the
316
+ perlpickle module.
317
+
318
+ The setup.py script now requires Distutils-0.9
319
+
320
+ Provide python-dynload-global patch for py152
321
+
322
+ Introduced try_perlapi.pl
323
+
324
+ More ZPublisher provided names in methodTry.dtml.
325
+ Patch by Joseph Wayne Norton <norton@alum.mit.edu>.
326
+
327
+ Improved documentation.
328
+
329
+ Fix comments on last line of a perl method.
330
+ Patch by Monty Taylor <mtaylor@goldridge.net>.
331
+
332
+ Implemented hash.update()
333
+
334
+
335
+
336
+ 2000-07-27 Gisle Aas <gisle@ActiveState.com>
337
+
338
+ Release 0.1.a1
339
+
340
+ First public alpha release.
341
+
pyperl3-2.0/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ (C) 2000-2001 ActiveState.
2
+
3
+ This code is distributed under the same terms as Perl; you can
4
+ redistribute it and/or modify it under the terms of either the GNU
5
+ General Public License or the Artistic License.
6
+
7
+ THIS SOFTWARE IS PROVIDED BY ACTIVESTATE `AS IS'' AND ANY EXPRESSED OR
8
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
9
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
10
+ DISCLAIMED. IN NO EVENT SHALL ACTIVESTATE OR ITS CONTRIBUTORS BE
11
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
12
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
13
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
14
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
15
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
16
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
17
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,10 @@
1
+ include pyproject.toml LICENSE README.md CHANGELOG
2
+ recursive-include licenses *
3
+ recursive-include src/native *.c *.h *.xs typemap
4
+ include Python-Object/Makefile.PL
5
+ recursive-include Python-Object/lib *.pm
6
+ include docs/perlmodule.pod docs/TODO
7
+ recursive-include tests *.py
8
+ recursive-include t *.py *.pm
9
+ include tools/*.py tools/*.pl
10
+ global-exclude *.py[cod]
pyperl3-2.0/PKG-INFO ADDED
@@ -0,0 +1,159 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyperl3
3
+ Version: 2.0
4
+ Summary: Embed Perl in CPython and call Python from Perl
5
+ Author: ActiveState, Per Øyvind Karlsen
6
+ Maintainer: Per Øyvind Karlsen
7
+ License-Expression: Artistic-1.0-Perl OR GPL-1.0-or-later
8
+ Project-URL: Repository, https://github.com/proyvind/pyperl
9
+ Project-URL: Issues, https://github.com/proyvind/pyperl/issues
10
+ Classifier: Programming Language :: Python :: 3 :: Only
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Programming Language :: Python :: 3.15
17
+ Classifier: Programming Language :: Python :: Implementation :: CPython
18
+ Classifier: Programming Language :: Perl
19
+ Classifier: Programming Language :: C
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ License-File: licenses/Artistic
24
+ License-File: licenses/Copying
25
+ Dynamic: license-file
26
+
27
+ # PyPerl (pyperl3)
28
+
29
+ This is a Python extension module that makes it possible to embed Perl
30
+ interpreter(s) in any Python program. It can be used to invoke
31
+ arbitrary Perl code, load any Perl modules and make calls directly
32
+ into Perl functions. The Perl code invoked can call back into Python
33
+ as it see fit.
34
+
35
+ Build and test
36
+ --------------
37
+
38
+ PyPerl supports CPython 3.10 through 3.15.2. Build against the headers
39
+ for the interpreter that will load the extension, with a C11 compiler
40
+ and a Perl 5 installation providing development headers and shared libperl.
41
+ Tested Perl versions include 5.26.3, 5.32.1, 5.40 and 5.44.
42
+ For Debian and Ubuntu, install build-essential, python3-dev, perl and
43
+ libperl-dev. Builds bundle Python::Object for the same Perl ABI used at
44
+ compile time. Rebuild after switching to an incompatible Perl ABI.
45
+
46
+ On native 64-bit Windows, use 64-bit CPython and Strawberry Perl with
47
+ its matching GCC on PATH. For a standard installation, add both
48
+ C:\Strawberry\perl\bin and C:\Strawberry\c\bin. To select another
49
+ installation, set PERL to its perl.exe and put its compiler on PATH.
50
+ When Strawberry Perl starts Python, put the directory containing the
51
+ matching python3XY.dll on PATH as well. For Cygwin, use Cygwin's own
52
+ Python, Perl and GCC together.
53
+
54
+ Install the distribution from PyPI and check the bridge:
55
+
56
+ python -m pip install pyperl3
57
+ python -c 'import perl; print(perl.eval("6 * 7"))'
58
+
59
+ To install from a source checkout:
60
+
61
+ python -m pip install .
62
+
63
+ For local development, build the extension and run both suites:
64
+
65
+ python setup.py build_ext --inplace
66
+ PYTHONPATH=src python tests/run.py
67
+ PYTHONPATH="$PWD/src:$PWD" PYTHONUNBUFFERED=1 prove --exec python t/*.py
68
+
69
+ On slow emulators, PYPERL_TEST_TIMEOUT controls how many seconds the tests
70
+ allow for worker threads and subprocesses. The default is 120.
71
+
72
+ Plain calls, callbacks, Perl references, context selection, Unicode and
73
+ the database adapters are available throughout the range. Python::await
74
+ drives asyncio futures and coroutines. Async iteration and async context
75
+ managers work throughout the supported range. The setting chosen with
76
+ perl.byte_strings() follows the current context across asynchronous tasks.
77
+
78
+ By default all Python threads share a single Perl interpreter. Use
79
+ PYPERL_MULTI_PERL=1 when building to give each thread its own interpreter.
80
+ The legacy MULTI_PERL marker file is also recognized. This mode requires
81
+ Perl built with ithreads. Perl references belong to their originating
82
+ interpreter and operations on them from another interpreter raise
83
+ ValueError. Run the test commands again after switching modes.
84
+
85
+ In a shared build, CPython subinterpreters see the same Perl globals,
86
+ loaded modules and Perl objects. Each Python interpreter owns its reference
87
+ type, exception class and byte-string setting. A Python callback retained
88
+ in Perl executes in the Python interpreter that created it. Once that
89
+ interpreter closes, calling the retained callback raises a Perl error.
90
+ MULTI_PERL builds use the main Python interpreter and give each Python
91
+ thread a private Perl interpreter.
92
+
93
+ On free-threaded CPython 3.13 and later, a shared build runs with the GIL
94
+ disabled. Calls into the process-wide Perl interpreter are serialized while
95
+ other Python threads can execute concurrently. MULTI_PERL builds use
96
+ CPython's compatibility GIL.
97
+
98
+ When Perl creates a thread with `threads->create`, Python objects in its
99
+ arguments and Perl variables are copied with Python's `copy.deepcopy`.
100
+ References to the same mutable object and cycles are preserved within a
101
+ copy. A value returned by `join` is copied back. Objects such as locks
102
+ that reject copying raise an error when used in the receiving thread.
103
+ Immutable values can retain their identity. A plain function or another
104
+ callback that the copy protocol would share makes the containing value
105
+ unavailable in the child. Callable instances with independent copies can
106
+ be used as callbacks. A Perl reference retained by a Python callback belongs to the
107
+ Perl thread that created it. Access after that thread exits raises
108
+ `ValueError`.
109
+
110
+ To start Python from Perl, build against a shared CPython library:
111
+
112
+ PYPERL_BOOT_FROM_PERL=1 python -m pip install .
113
+ pyperl_lib=$(python -c 'from _pyperl_bootstrap import perl_library; print(perl_library)')
114
+ perl -I"$pyperl_lib" -MPython -e 'print Python::eval("6 * 7"), "\n"'
115
+
116
+ To make these modules discoverable on Perl's normal search path, run
117
+ `perl Makefile.PL && make install` in Python-Object. Set PYTHON to the
118
+ interpreter where you installed the wheel. Both installations use that
119
+ wheel's copy of the bridge.
120
+
121
+ The legacy BOOT_FROM_PERL marker enables the same build. Both directions
122
+ share one native module. From embedded Python, importing perl gives access
123
+ to the calling Perl interpreter. In MULTI_PERL mode, additional Python
124
+ threads receive their own Perl interpreters.
125
+
126
+ The Python API is documented in docs/perlmodule.pod. See
127
+ Python-Object/lib/Python/Object.pm and Python-Object/lib/Python.pm for the Perl
128
+ side of the bridge. The dbi and dbi2 adapters additionally require
129
+ Perl's DBI and a driver for the chosen database. With DBI and
130
+ DBD::SQLite installed, python tools/check_dbi.py runs the adapter integration
131
+ tests against an in-memory database. The unittest suite also runs these
132
+ tests when both Perl modules are available.
133
+ With DBD::SQLite, `dbi2` reports `None` for the optional `null_ok` field
134
+ in `cursor.description`. The driver can fail while looking up this field
135
+ for a result column computed by an expression.
136
+
137
+ ## Building distributions
138
+
139
+ The Python modules are under `src/`, and their C and XS sources are under
140
+ `src/native/`. The Perl distribution uses `Python-Object/lib/`. The public
141
+ Python import names and the Perl module names are the same in a wheel
142
+ and a source installation.
143
+
144
+ With a current Python and the Perl development files installed, run:
145
+
146
+ python -m pip install build twine
147
+ python -m build
148
+ python -m twine check --strict dist/*
149
+
150
+ The build produces a source archive and a native wheel built from that archive.
151
+ The source archive is the portable PyPI distribution. A local Linux wheel
152
+ links against the installed libperl. Its platform tag does not identify the
153
+ Perl ABI or the optional build modes. Distribute such wheels only to matching
154
+ runtimes. Build release artifacts from a clean checkout.
155
+
156
+ Installing the wheel also installs `perlsh`, an interactive Perl prompt
157
+ hosted by Python. It is also available through `python -m perlsh`.
158
+
159
+ The distribution includes the original license notice and both license texts.
@@ -0,0 +1,42 @@
1
+ use strict;
2
+ use warnings;
3
+ use utf8;
4
+ use ExtUtils::MakeMaker;
5
+ use File::Path qw(make_path);
6
+ use File::Basename qw(dirname);
7
+
8
+ # Keep the traditional Perl installation entry point. Install forwarders so
9
+ # both hosts always load the native module from the selected Python install.
10
+ my $python = $ENV{PYTHON} || 'python3';
11
+ open my $settings, '-|', $python, '-c',
12
+ 'from _pyperl_bootstrap import perl_library; print(perl_library)'
13
+ or die "Cannot run $python: $!";
14
+ my $bundle = <$settings>;
15
+ close $settings or die "Could not locate PyPerl using $python";
16
+ chomp $bundle;
17
+ $bundle =~ s/([\\'])/\\$1/g;
18
+
19
+ my %modules;
20
+ for my $module ('Python.pm', 'Python/Object.pm', 'Python/Err.pm') {
21
+ my $stub = "forwarders/$module";
22
+ make_path(dirname($stub));
23
+ open my $out, '>', $stub or die "Cannot write $stub: $!";
24
+ print {$out} "use lib '$bundle';\n",
25
+ "my \$file = '$bundle/$module';\n",
26
+ "my \$loaded = do \$file;\n",
27
+ "die \$@ if \$@;\n",
28
+ "die qq{Cannot load \$file: \$!} unless defined \$loaded;\n",
29
+ "\$loaded;\n";
30
+ close $out or die "Cannot close $stub: $!";
31
+ $modules{$stub} = '$(INST_LIB)/' . $module;
32
+ }
33
+ WriteMakefile(
34
+ NAME => 'Python::Object',
35
+ AUTHOR => ['ActiveState', 'Per Øyvind Karlsen'],
36
+ VERSION_FROM => 'lib/Python/Object.pm',
37
+ XS => {}, C => [], OBJECT => '',
38
+ INST_LIB => 'forwarders/blib/lib',
39
+ INST_ARCHLIB => 'forwarders/blib/arch',
40
+ PM => \%modules,
41
+ clean => { FILES => 'forwarders' },
42
+ );