PySlurm / pyslurm

Python Interface to Slurm
https://pyslurm.github.io
GNU General Public License v2.0
474 stars 116 forks source link

Cython Compile failure on RHEL8 with PySlurm 21.08.4. #236

Closed bviviano closed 2 years ago

bviviano commented 2 years ago

Details

Issue

I am attempting to build PySlurm from release tar.gz 21.08.4 against Slurm 21.08.8, for use with with Slurm-web 2.4.0, but am getting a cython error on build of pyslurm 21.08.4. I've created a python virtual environment and installed cython into it:

$ /bin/python3 -m venv /local/slurm-web
$ /local/slurm-web/bin/pip3 install --upgrade pip
$ /local/slurm-web/bin/pip3 install Cython

When I go to "build" PySlurm from that virtual environment, it errors out:

$ /local/slurm-web/bin/python3 setup.py build --slurm-lib=/usr/local/lib64 --slurm-inc=/usr/local/include
INFO: 
INFO: Building PySlurm (21.08.4.0)
INFO: ------------------------------
INFO: 
INFO: Cython version 0.29.30 installed
INFO: 
INFO: Clean - checking for objects to clean
INFO: Clean - completed
INFO: Build - Found Slurm header in /usr/local/include/slurm
INFO: Build - Detected Slurm version - 0x150808 21.08.08
INFO: Build - Found Slurm shared library in /usr/local/lib64
INFO: Build - Generating pyslurm/bluegene.pxi file
/local/slurm-web/lib64/python3.6/site-packages/setuptools/dist.py:398: UserWarning: Normalizing '21.08.4.0' to '21.8.4.0'
  normalized_version,
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/pyslurm
copying pyslurm/__init__.py -> build/lib.linux-x86_64-3.6/pyslurm
copying pyslurm/__version__.py -> build/lib.linux-x86_64-3.6/pyslurm
running build_ext
cythoning pyslurm/pyslurm.pyx to pyslurm/pyslurm.c
warning: pyslurm/slurm.pxd:3801:8: 'SLURMDB_USER_FLAG_NONE' redeclared 
warning: pyslurm/slurm.pxd:3802:8: 'SLURMDB_USER_FLAG_DELETED' redeclared 
warning: pyslurm/slurm.pxd:3834:8: 'SLURMDB_WCKEY_FLAG_NONE' redeclared 
warning: pyslurm/slurm.pxd:3835:8: 'SLURMDB_WCKEY_FLAG_DELETED' redeclared 

Error compiling Cython file:
------------------------------------------------------------
...
#
# Trigger Get/Set/Update Class
#

cdef class trigger:
    ^
------------------------------------------------------------

pyslurm/pyslurm.pyx:3819:5: Compiler crash in AnalyseDeclarationsTransform

ModuleNode.body = StatListNode(pyslurm.pyx:4:0)
StatListNode.stats[133] = StatListNode(pyslurm.pyx:3819:5)
StatListNode.stats[0] = CClassDefNode(pyslurm.pyx:3819:5,
    as_name = 'trigger',
    class_name = 'trigger',
    module_name = '',
    visibility = 'private')

Compiler crash traceback from this point on:
  File "Cython/Compiler/Visitor.py", line 180, in Cython.Compiler.Visitor.TreeVisitor._visit
  File "/local/slurm-web/lib64/python3.6/site-packages/Cython/Compiler/ParseTreeTransforms.py", line 1636, in visit_CClassDefNode
    self._inject_pickle_methods(node)
  File "/local/slurm-web/lib64/python3.6/site-packages/Cython/Compiler/ParseTreeTransforms.py", line 1719, in _inject_pickle_methods
    for mkchecksum in checksum_algos
  File "/local/slurm-web/lib64/python3.6/site-packages/Cython/Compiler/ParseTreeTransforms.py", line 1719, in <listcomp>
    for mkchecksum in checksum_algos
ValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS
building 'pyslurm.pyslurm' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/pyslurm
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/local/include -I. -I/local/slurm-web/include -I/usr/include/python3.6m -c pyslurm/pyslurm.c -o build/temp.linux-x86_64-3.6/pyslurm/pyslurm.o
pyslurm/pyslurm.c:1:2: error: #error Do not use this file, it is the result of a failed Cython compilation.
 #error Do not use this file, it is the result of a failed Cython compilation.
  ^~~~~
error: command 'gcc' failed with exit status 1

Any suggestions on what I might be missing would be appreciated.

bviviano commented 2 years ago

If I downgrade to cython 0.19.2 and PySlurm 20.11.8-1 and build against Slurm 20.11.9 I can compile without issue

$ /local/slurm-web/bin/python3 setup.py build --slurm=/usr/local/encap/slurm-20.11.9
INFO: 
INFO: Building PySlurm (20.11.8.0)
INFO: ------------------------------
INFO: 
INFO: Cython version 0.19.2 installed
INFO: 
INFO: Clean - checking for objects to clean
INFO: Clean - removing build/
INFO: Clean - removing pyslurm/bluegene.pxi
INFO: Clean - completed
INFO: Build - Found Slurm header in /usr/local/encap/slurm-20.11.9/include
INFO: Build - Detected Slurm version - 0x140b09 (20.11.09)
INFO: Build - Found Slurm shared library in /usr/local/encap/slurm-20.11.9/lib64
INFO: Build - Generating pyslurm/bluegene.pxi file
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/pyslurm
copying pyslurm/__init__.py -> build/lib.linux-x86_64-3.6/pyslurm
copying pyslurm/__version__.py -> build/lib.linux-x86_64-3.6/pyslurm
running build_ext
cythoning pyslurm/pyslurm.pyx to pyslurm/pyslurm.c
building 'pyslurm.pyslurm' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/pyslurm
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/local/encap/slurm-20.11.9/include -I. -I/local/slurm-web/include -I/usr/include/python3.6m -c pyslurm/pyslurm.c -o build/temp.linux-x86_64-3.6/pyslurm/pyslurm.o
gcc -pthread -shared -Wl,-z,relro -Wl,-z,now -g -Wl,-z,relro -Wl,-z,now -g build/temp.linux-x86_64-3.6/pyslurm/pyslurm.o -L/usr/local/encap/slurm-20.11.9/lib64 -L/usr/local/encap/slurm-20.11.9/lib64/slurm -L/usr/lib64 -Wl,--enable-new-dtags,-R/usr/local/encap/slurm-20.11.9/lib64 -Wl,--enable-new-dtags,-R/usr/local/encap/slurm-20.11.9/lib64/slurm -lslurmfull -lpython3.6m -o build/lib.linux-x86_64-3.6/pyslurm/pyslurm.cpython-36m-x86_64-linux-gnu.so

If I try and use Cython 0.19.2 with PySlurm 21.08.4, I get a different set of errors then I get with Cython 0.29.30:

$ /local/slurm-web/bin/python3 setup.py build --slurm=/usr/local/encap/slurm-21.08.8
INFO: 
INFO: Building PySlurm (21.08.4.0)
INFO: ------------------------------
INFO: 
INFO: Cython version 0.19.2 installed
INFO: 
INFO: Clean - checking for objects to clean
INFO: Clean - removing build/
INFO: Clean - removing pyslurm/bluegene.pxi
INFO: Clean - removing pyslurm/pyslurm.c
INFO: Clean - completed
INFO: Build - Found Slurm header in /usr/local/encap/slurm-21.08.8/include/slurm
INFO: Build - Detected Slurm version - 0x150808 21.08.08
INFO: Build - Found Slurm shared library in /usr/local/encap/slurm-21.08.8/lib64
INFO: Build - Generating pyslurm/bluegene.pxi file
/local/slurm-web/lib64/python3.6/site-packages/setuptools/dist.py:398: UserWarning: Normalizing '21.08.4.0' to '21.8.4.0'
  normalized_version,
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/pyslurm
copying pyslurm/__init__.py -> build/lib.linux-x86_64-3.6/pyslurm
copying pyslurm/__version__.py -> build/lib.linux-x86_64-3.6/pyslurm
running build_ext
cythoning pyslurm/pyslurm.pyx to pyslurm/pyslurm.c

Error compiling Cython file:
------------------------------------------------------------
...
cdef extern from "xmalloc.h" nogil:
    cdef void *xmalloc(size_t size)

import builtins as __builtin__

from pyslurm cimport slurm
^
------------------------------------------------------------

pyslurm/pyslurm.pyx:60:0: 'slurm.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
...
cdef extern from "xmalloc.h" nogil:
    cdef void *xmalloc(size_t size)

import builtins as __builtin__

from pyslurm cimport slurm
                    ^
------------------------------------------------------------

pyslurm/pyslurm.pyx:60:21: Name 'slurm' not declared in module 'pyslurm'

Error compiling Cython file:
------------------------------------------------------------
...

#
# Defined job states
#

cdef inline IS_JOB_PENDING(slurm.slurm_job_info_t _X):
                          ^
------------------------------------------------------------

pyslurm/pyslurm.pyx:125:27: 'slurm' is not declared

Error compiling Cython file:
------------------------------------------------------------
...
------------------------------------------------------------

pyslurm/pyslurm.pyx:5740:39: Casting temporary Python object to non-numeric non-Python type

Error compiling Cython file:
------------------------------------------------------------
...
                Assoc_dict["user"] = slurm.stringOrNone(slurmdb_report_assoc.user, '')
                Assoc_dict["tres_list"] = []
                tres_itr = slurm.slurm_list_iterator_create(slurmdb_report_assoc.tres_list)

                for k in range(slurm.slurm_list_count(slurmdb_report_assoc.tres_list)):
                    tres = <slurm.slurmdb_tres_rec_t *>slurm.slurm_list_next(tres_itr)
                           ^
------------------------------------------------------------

pyslurm/pyslurm.pyx:5750:28: 'slurm' is not a cimported module

Error compiling Cython file:
------------------------------------------------------------
...
                Assoc_dict["user"] = slurm.stringOrNone(slurmdb_report_assoc.user, '')
                Assoc_dict["tres_list"] = []
                tres_itr = slurm.slurm_list_iterator_create(slurmdb_report_assoc.tres_list)

                for k in range(slurm.slurm_list_count(slurmdb_report_assoc.tres_list)):
                    tres = <slurm.slurmdb_tres_rec_t *>slurm.slurm_list_next(tres_itr)
                          ^
------------------------------------------------------------

pyslurm/pyslurm.pyx:5750:27: Casting temporary Python object to non-numeric non-Python type
building 'pyslurm.pyslurm' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/pyslurm
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/local/encap/slurm-21.08.8/include -I. -I/local/slurm-web/include -I/usr/include/python3.6m -c pyslurm/pyslurm.c -o build/temp.linux-x86_64-3.6/pyslurm/pyslurm.o
pyslurm/pyslurm.c:1:2: error: #error Do not use this file, it is the result of a failed Cython compilation.
 #error Do not use this file, it is the result of a failed Cython compilation.
  ^~~~~
error: command 'gcc' failed with exit status 1
bviviano commented 2 years ago

Updating for anyone else who might have a similar issue.

Looks like my specific issue was Cython version related. "Latest stable" seems to not be 100% accurate in the install guide. After testing various cython releases between 0.19.x and 0.29.x. I found that after I downgraded to 0.25.2, PySlurm 21.08.4 compiled against Slurm 21.08.8 without issue.

So the following stack works inside a venv:

$ /bin/python3 -m venv /local/slurm-web
$ /local/slurm-web/bin/pip3 install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/a4/6d/6463d49a933f547439d6b5b98b46af8742cc03ae83543e4d7688c2420f8b/pip-21.3.1-py3-none-any.whl (1.7MB)
    100% |████████████████████████████████| 1.7MB 813kB/s 
Installing collected packages: pip
  Found existing installation: pip 9.0.3
    Uninstalling pip-9.0.3:
      Successfully uninstalled pip-9.0.3
Successfully installed pip-21.3.1
You are using pip version 21.3.1, however version 22.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ /local/slurm-web/bin/pip3 install wheel
Collecting wheel
  Downloading wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel
Successfully installed wheel-0.37.1
$ /local/slurm-web/bin/pip3 install cython==0.25.2
Collecting cython==0.25.2
  Downloading Cython-0.25.2-cp36-cp36m-manylinux1_x86_64.whl (7.3 MB)
     |████████████████████████████████| 7.3 MB 4.7 MB/s            
Installing collected packages: cython
Successfully installed cython-0.25.2
$ /local/slurm-web/bin/python setup.py build --slurm=/usr/local
INFO: 
INFO: Building PySlurm (21.08.4.0)
INFO: ------------------------------
INFO: 
INFO: Cython version 0.25.2 installed
INFO: 
INFO: Clean - checking for objects to clean
INFO: Clean - removing build/
INFO: Clean - removing pyslurm/bluegene.pxi
INFO: Clean - removing pyslurm/pyslurm.c
INFO: Clean - completed
INFO: Build - Found Slurm header in /usr/local/include/slurm
INFO: Build - Detected Slurm version - 0x150808 21.08.08
INFO: Build - Found Slurm shared library in /usr/local/lib64
INFO: Build - Generating pyslurm/bluegene.pxi file
/local/slurm-web/lib64/python3.6/site-packages/setuptools/dist.py:398: UserWarning: Normalizing '21.08.4.0' to '21.8.4.0'
  normalized_version,
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/pyslurm
copying pyslurm/__init__.py -> build/lib.linux-x86_64-3.6/pyslurm
copying pyslurm/__version__.py -> build/lib.linux-x86_64-3.6/pyslurm
running build_ext
cythoning pyslurm/pyslurm.pyx to pyslurm/pyslurm.c
building 'pyslurm.pyslurm' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/pyslurm
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/local/include -I. -I/local/slurm-web/include -I/usr/include/python3.6m -c pyslurm/pyslurm.c -o build/temp.linux-x86_64-3.6/pyslurm/pyslurm.o
pyslurm/pyslurm.c: In function ‘__Pyx_PyInt_LshiftObjC’:
pyslurm/pyslurm.c:96589:34: warning: comparison of integer expressions of different signedness: ‘long int’ and ‘long unsigned int’ [-Wsign-compare]
                 if (unlikely(!(b < sizeof(long)*8 && a == x >> b)) && a) {
                                  ^
pyslurm/pyslurm.c:630:43: note: in definition of macro ‘unlikely’
   #define unlikely(x) __builtin_expect(!!(x), 0)
                                           ^
pyslurm/pyslurm.c: In function ‘PyInit_pyslurm’:
pyslurm/pyslurm.c:82236:16: note: variable tracking size limit exceeded with -fvar-tracking-assignments, retrying without
 PyMODINIT_FUNC PyInit_pyslurm(void)
                ^~~~~~~~~~~~~~
gcc -pthread -shared -Wl,-z,relro -Wl,-z,now -g -Wl,-z,relro -Wl,-z,now -g build/temp.linux-x86_64-3.6/pyslurm/pyslurm.o -L/usr/local/lib64 -L/usr/local/lib64/slurm -L/usr/lib64 -Wl,--enable-new-dtags,-R/usr/local/lib64 -Wl,--enable-new-dtags,-R/usr/local/lib64/slurm -lslurmfull -lpython3.6m -o build/lib.linux-x86_64-3.6/pyslurm/pyslurm.cpython-36m-x86_64-linux-gnu.so
$ /local/slurm-web/bin/python setup.py install
/local/slurm-web/lib64/python3.6/site-packages/setuptools/dist.py:398: UserWarning: Normalizing '21.08.4.0' to '21.8.4.0'
  normalized_version,
running install
running bdist_egg
running egg_info
writing pyslurm.egg-info/PKG-INFO
writing dependency_links to pyslurm.egg-info/dependency_links.txt
writing requirements to pyslurm.egg-info/requires.txt
writing top-level names to pyslurm.egg-info/top_level.txt
reading manifest file 'pyslurm.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'pyslurm/slurm_defines.pxi'
warning: no files found matching 'README.rst'
warning: no files found matching 'THANKS.rst'
writing manifest file 'pyslurm.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
running build_ext
skipping 'pyslurm/pyslurm.c' Cython extension (up-to-date)
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/pyslurm
copying build/lib.linux-x86_64-3.6/pyslurm/__init__.py -> build/bdist.linux-x86_64/egg/pyslurm
copying build/lib.linux-x86_64-3.6/pyslurm/__version__.py -> build/bdist.linux-x86_64/egg/pyslurm
copying build/lib.linux-x86_64-3.6/pyslurm/pyslurm.cpython-36m-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/egg/pyslurm
byte-compiling build/bdist.linux-x86_64/egg/pyslurm/__init__.py to __init__.cpython-36.pyc
byte-compiling build/bdist.linux-x86_64/egg/pyslurm/__version__.py to __version__.cpython-36.pyc
creating stub loader for pyslurm/pyslurm.cpython-36m-x86_64-linux-gnu.so
byte-compiling build/bdist.linux-x86_64/egg/pyslurm/pyslurm.py to pyslurm.cpython-36.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying pyslurm.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pyslurm.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pyslurm.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pyslurm.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pyslurm.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
pyslurm.__pycache__.pyslurm.cpython-36: module references __file__
creating 'dist/pyslurm-21.8.4.0-py3.6-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing pyslurm-21.8.4.0-py3.6-linux-x86_64.egg
creating /local/slurm-web/lib/python3.6/site-packages/pyslurm-21.8.4.0-py3.6-linux-x86_64.egg
Extracting pyslurm-21.8.4.0-py3.6-linux-x86_64.egg to /local/slurm-web/lib/python3.6/site-packages
Adding pyslurm 21.8.4.0 to easy-install.pth file

Installed /local/slurm-web/lib/python3.6/site-packages/pyslurm-21.8.4.0-py3.6-linux-x86_64.egg
Processing dependencies for pyslurm==21.8.4.0
Searching for Cython==0.25.2
Best match: Cython 0.25.2
Adding Cython 0.25.2 to easy-install.pth file
Installing cygdb script to /local/slurm-web/bin
Installing cython script to /local/slurm-web/bin
Installing cythonize script to /local/slurm-web/bin

Using /local/slurm-web/lib/python3.6/site-packages
Finished processing dependencies for pyslurm==21.8.4.0

Any cython later then 0.25.X doesn't seem to work with Slurm/PySlurm 21.08.x

$ /local/slurm-web/bin/python setup.py build --slurm=/usr/local
INFO: 
INFO: Building PySlurm (21.08.4.0)
INFO: ------------------------------
INFO: 
INFO: Cython version 0.26.1 installed
INFO: 
INFO: Clean - checking for objects to clean
INFO: Clean - removing build/
INFO: Clean - removing pyslurm/bluegene.pxi
INFO: Clean - removing pyslurm/pyslurm.c
INFO: Clean - completed
INFO: Build - Found Slurm header in /usr/local/include/slurm
INFO: Build - Detected Slurm version - 0x150808 21.08.08
INFO: Build - Found Slurm shared library in /usr/local/lib64
INFO: Build - Generating pyslurm/bluegene.pxi file
/local/slurm-web/lib64/python3.6/site-packages/setuptools/dist.py:398: UserWarning: Normalizing '21.08.4.0' to '21.8.4.0'
  normalized_version,
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/pyslurm
copying pyslurm/__init__.py -> build/lib.linux-x86_64-3.6/pyslurm
copying pyslurm/__version__.py -> build/lib.linux-x86_64-3.6/pyslurm
running build_ext
cythoning pyslurm/pyslurm.pyx to pyslurm/pyslurm.c

Error compiling Cython file:
------------------------------------------------------------
...
#
# Trigger Get/Set/Update Class
#

cdef class trigger:
    ^
------------------------------------------------------------

pyslurm/pyslurm.pyx:3819:5: Compiler crash in AnalyseDeclarationsTransform

ModuleNode.body = StatListNode(pyslurm.pyx:4:0)
StatListNode.stats[133] = StatListNode(pyslurm.pyx:3819:5)
StatListNode.stats[0] = CClassDefNode(pyslurm.pyx:3819:5,
    as_name = 'trigger',
    class_name = 'trigger',
    module_name = '',
    visibility = 'private')

Compiler crash traceback from this point on:
  File "Cython/Compiler/Visitor.py", line 180, in Cython.Compiler.Visitor.TreeVisitor._visit
  File "/local/slurm-web/lib64/python3.6/site-packages/Cython/Compiler/ParseTreeTransforms.py", line 1598, in visit_CClassDefNode
    self._inject_pickle_methods(node)
  File "/local/slurm-web/lib64/python3.6/site-packages/Cython/Compiler/ParseTreeTransforms.py", line 1666, in _inject_pickle_methods
    checksum = '0x%s' % hashlib.md5(' '.join(all_members_names).encode('utf-8')).hexdigest()[:7]
ValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS
building 'pyslurm.pyslurm' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/pyslurm
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/local/include -I. -I/local/slurm-web/include -I/usr/include/python3.6m -c pyslurm/pyslurm.c -o build/temp.linux-x86_64-3.6/pyslurm/pyslurm.o
pyslurm/pyslurm.c:1:2: error: #error Do not use this file, it is the result of a failed Cython compilation.
 #error Do not use this file, it is the result of a failed Cython compilation.
  ^~~~~
error: command 'gcc' failed with exit status 1
mvpel commented 2 years ago

To clarify for those who may find this issue, the root cause is the kernel having FIPS enforcement turned on. When this is enabled via a "fips=1" kernel command line option, which you can confirm with the "fipscheck" command, any crypto or hash algorithm that is not FIPS-approved, such as DES or MD5, is blocked within the kernel.

In Cython's ParseTreeTransforms.py 0.29.x it looks for an AttributeError exception when the hashlib.md5 function is added to the array, but since it's not invoked at that point, it's not blocked by the kernel and there's no exception - the exception occurs later when the algorithm list is used to generate checksums. The same issue, with a slight variation in construction of the list, appears in the master branch. The fix may be to try calling hashlib.md5(b'abc') and looking for a ValueError exception.

da-woods commented 2 years ago

Can I suggest turning off the auto-pickle feature by adding the line:

# cython: auto_pickle = False

to the top of your source files (or setting it everywhere in setup.py if you use that). It's the auto-pickle feature that's using the hashes, so that should be a better solution than downgrading to the version before it was introduced

tazend commented 2 years ago

Thanks for the explanations on the problem.

I'd say instead of disabling that feature where a check is perhaps mishandled within cython itself, we just remove Cython as a build dependency (by default, as is also recommended), do the code-generation on our side and ship the c-files with the source (as discussed in #190).

That way everyone would get exactly what was tested on the maintainer side, and the only dependency left for the user would be to have a c-compiler ready. And by doing that, failures like these shouldn't really be possible anymore (unless perhaps the user really wants to force cythonizing the files again ).

What do you think about that?

da-woods commented 2 years ago

do the code-generation on our side and ship the c-files with the source

There's pros and cons to that. From a Cython point-of-view it used to be the recommended way of shipping things (you know for sure all your uses are using a known, good version of the c files). The main disadvantage is that you'll probably need to regenerate the C files to support new versions of Python (I imagine you'll be OK from now until the first 3.12 alphas start appearing).

But it's a valid way of distributing cython code, and it's worked well for other projects.

tazend commented 2 years ago

Yeah, I wasn't really taking into consideration what happens when new python releases come into play. Actually, since currently the frequency of new pyslurm-releases is pretty low, it might be better for now to keep Cython as build-dependency and leave codegen on, to prevent the code from becoming too old and not adapting to new environments. In the future we could still easily switch things around if releases become more frequent.

Also had another look at the auto_pickle feature, and as described here it is disabled by default for cdef classes which include pointers, so it makes it probably useless anyway for the most part in pyslurm, might aswell disable it explicitly then.