sagemath / cysignals

cysignals: interrupt and signal handling for Cython. Source repository for https://pypi.org/project/cysignals/
GNU Lesser General Public License v3.0
44 stars 23 forks source link

fix os x test suite #154

Closed kliem closed 2 years ago

kliem commented 2 years ago

The issue first fixed in #71 reappeared:

See e.g. https://github.com/sagemath/cysignals/actions/runs/1494362490

dimpase commented 2 years ago

Does it still suppport py2? I had to do

--- a/rundoctests.py
+++ b/rundoctests.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Run doctests for cysignals
 #

in order to

% ./rundoctests.py  
Doctesting 0 files.
Traceback (most recent call last):
  File "/Users/dima/software/cysignals/./rundoctests.py", line 64, in <module>
    resource.setrlimit(resource.RLIMIT_STACK, (stacksize, stacksize))
ValueError: current limit exceeds maximum limit
% uname -a
Darwin oucl13243.lan 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64 x86_64
kliem commented 2 years ago

It assumes that $PYTHON is set to your python. So you may run make ... PYTHON=python3.

dimpase commented 2 years ago

This seems to be relevant here: https://bugs.python.org/issue34602 https://bugs.python.org/issue40518

dimpase commented 2 years ago

Does $PYTHON override #!/usr/bin/env python? This would be weird...

Anyhow, what's the correct way to run the tests?

kliem commented 2 years ago

The difference to other peoples problems is the following:

# Limit stack size to avoid errors in stack overflow doctest
stacksize = 1 << 20
resource.setrlimit(resource.RLIMIT_STACK, (stacksize, stacksize))

So we want to limit the stack size instead of increasing it. So I guess if for some reason macos tells us 1 << 20 is too large, we just ignore that.

I really don't know what that shebang line is supposed to do. I can't tell that it makes a difference for me.

dimpase commented 2 years ago

Indeed, I suppose one should not call that setrlimit on macOS at all.

Meanwhile, I really need

-#!/usr/bin/env python
+#!/usr/bin/env python3

on setup.py, otherwise make fails as it tries Python2, no matter if I export PYTHON=python3 or not. What works is make PYTHON=python3 - probably it runs a mix of python 2 and 3 then, yuck...

It doesn't work with python2 anyway, though.

dimpase commented 2 years ago

With the following patch, tests run:

--- a/rundoctests.py
+++ b/rundoctests.py
@@ -61,7 +61,8 @@ if os.name != 'nt':
     import resource
     # Limit stack size to avoid errors in stack overflow doctest
     stacksize = 1 << 20
-    resource.setrlimit(resource.RLIMIT_STACK, (stacksize, stacksize))
+    if sys.platform != 'darwin':
+        resource.setrlimit(resource.RLIMIT_STACK, (stacksize, stacksize))

     # Disable core dumps
     resource.setrlimit(resource.RLIMIT_CORE, (0, 0))
dimpase commented 2 years ago

here is what I get if PYTHON=python3 is not passed to make:

% make 
python setup.py build
running build
running build_py
running configure
Traceback (most recent call last):
  File "setup.py", line 217, in <module>
    bdist_egg=no_egg
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build.py", line 127, in run
    self.run_command(cmd_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "setup.py", line 173, in run
    super().run()
TypeError: super() takes at least 1 argument (0 given)
make: *** [build] Error 1

Seems like a bug - noone tested this on py2 for ages it seems.

dimpase commented 2 years ago

OK, the tests on your branch pass, and they have https://github.com/sagemath/cysignals/pull/154#issuecomment-977776188 in, so good to go.

kliem commented 2 years ago

Should we modify the shebang line yet?

It seems for me that make check-all does not work no matter what. I need to run make check-all PYHON=python3.

Btw, support for python < 3.6 has been dropped.

dimpase commented 2 years ago

Should we modify the shebang line yet?

if we're droppying Python 2 officially, then why not. By the way, Makefile has PYTHON = python at the top, no wonder it's broken if good PYTHON is not passed. Not all systems set python to anything nowadays, you need python3 (or python2, but do we care about python2 still?)

dimpase commented 2 years ago

setup.py doesn't say anything about python 2 support, only 3, so that was just an old leftover from python2 days to fix.