On Wed, May 13, 2020 at 5:56 PM Jun Omae <jun6...@gmail.com> wrote:
At least, I think we should use python_d.exe when debug configuration.
...
Python bindings with debug configuration for Python 3.x has something wrong.

[[[
-- Running Swig Python tests --
Traceback (most recent call last):
   File "C:\usr\src\subversion\trunk-py3\Debug\swig\pylib\libsvn\core.py", line 
14, in swig_import_helper
     return importlib.import_module(mname)
   File "C:\usr\apps\python37\lib\importlib\__init__.py", line 127, in 
import_module
     return _bootstrap._gcd_import(name[level:], package, level)
   File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
   File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'libsvn._core'
]]]

According to Build and C API Changes in Python 3.5 [1], extension module should 
end with
`{name}_d.pyd` rather than `{name}.pyd` in debug mode.

After py35-windows-debug-pyd.diff, win-tests.py --debug --swig=python is able 
to run tests.

On Python 3.7.7 with SWIG 3.0.12, the following assertion raises. The assertion 
has been
reported and in SWIG #1321 [2] and fixed in SWIG 4.0.1.

[[[
Testing Debug configuration on local repository.
-- Running Swig Python tests --
.............................Fatal Python error: ..\Objects\dictobject.c:1905 
object at 0000018C25A37C28 has negative ref count -2459565876494606884
]]]


On Python 3.7.7 with SWIG 4.0.1, another assertion raises.

[[[
Testing Debug configuration on local repository.
-- Running Swig Python tests --
Assertion failed: PyTuple_Check(args), file ..\Objects\typeobject.c, line 3670
[Test runner reported failure]
]]]


[1] https://docs.python.org/3/whatsnew/3.5.html#build-and-c-api-changes
[2] https://github.com/swig/swig/issues/1321

--
Jun Omae <jun6...@gmail.com> (大前 潤)
* win-tests.py
  Copy *.pyd files to pylib/libsvn/ file with *_d.pyd suffix and python_d.exe
  rather than python.exe when debug configuration.

Index: win-tests.py
===================================================================
--- win-tests.py        (revision 1877480)
+++ win-tests.py        (working copy)
@@ -1263,7 +1263,10 @@
         or isinstance(i, gen_base.TargetSWIGLib)) and i.lang == 'python':
 
       src = os.path.join(abs_objdir, i.filename)
-      copy_changed_file(src, to_dir=swig_py_libsvn)
+      basename = os.path.basename(src)
+      if basename.endswith('.pyd') and objdir == 'Debug':
+        basename = basename[:-4] + '_d.pyd'
+      copy_changed_file(src, os.path.join(swig_py_libsvn, basename))
 
   py_src = os.path.join(abs_srcdir, 'subversion', 'bindings', 'swig', 'python')
 
@@ -1285,7 +1288,8 @@
   if 'PYTHONPATH' in os.environ:
     pythonpath += os.pathsep + os.environ['PYTHONPATH']
 
-  python_exe = 'python.exe'
+  python_exe = sys.executable if objdir != 'Debug' else \
+               os.path.join(os.path.dirname(sys.executable), 'python_d.exe')
   old_cwd = os.getcwd()
   try:
     os.environ['PYTHONPATH'] = pythonpath

Reply via email to