Liburing icon indicating copy to clipboard operation
Liburing copied to clipboard

Can't import constants (O_CREAT, STATX_BASIC_STATS, AT_FDCWD, etc.)

Open bland328 opened this issue 6 months ago • 5 comments

When I install (either via pip or by cloning and building from there) using Python 3.12.8 under kernel 6.1, everything seems fine except that I'm unable to import any constants.

from liburing import O_CREAT fails, as do STATX_BASIC_STATS, AT_FDCWD, and so on.

I can import callables just fine.

Any thoughts on what might be going wrong, or more likely, what I might be misunderstanding?

Just in case it helps, liburing.probe() returns True for everything except these:

...
'IORING_OP_READ_MULTISHOT': False
'IORING_OP_WAITID': False
'IORING_OP_FUTEX_WAIT': False
'IORING_OP_FUTEX_WAKE': False
'IORING_OP_FUTEX_WAITV': False
'IORING_OP_FIXED_FD_INSTALL': False
'IORING_OP_FTRUNCATE': False
'IORING_OP_BIND': False
'IORING_OP_LISTEN': False

bland328 avatar Jun 05 '25 21:06 bland328

You normally need the latest Linux to use Liburing properly as there are new features being added. Current Liburing is tested under Linux 6.11+. That being said could you try to uninstall Liburing and install Liburing directly from GitHub? python3 -m pip install --upgrade git+https://github.com/YoSTEALTH/Liburing see if that helps.

All those probe shown as False needs latest Linux kernel.

YoSTEALTH avatar Jun 07 '25 07:06 YoSTEALTH

Hello @YoSTEALTH , I think I'm encountering a similar issue, and I wonder if it doesn't have to do something with the importer instead. In particular, the AT_FDCWD is accessible inside the liburing, just not exported at the top level, and I can get it as follows:

import liburing.common as common
AT_FDCWD = common.__common_define__.AT_FDCWD

and I got the O_CREAT, O_RDWR from os stdlib module itself (though I presume its inside liburing, just not made visible).

Any idea what could be the cause, or how could I help troubleshooting further?

Ftr, my liburing.probe() gives all True except 'IORING_OP_FTRUNCATE': False

tmi avatar Aug 19 '25 08:08 tmi

Thanks @tmi for reporting this issue. I feel bad for not looking into this further when @bland328 reported.

Weird the test that passes before fails now, I also added an import test and yes it fails as well. I wonder if there was some kind of change made to Python security patch!

Run python3 -m pytest test
============================= test session starts ==============================
platform linux -- Python 3.12.11, pytest-8.4.1, pluggy-1.6.0
rootdir: /home/runner/work/Liburing/Liburing
configfile: pyproject.toml
collected 57 items / 3 errors

==================================== ERRORS ====================================
_________________ ERROR collecting test/file/open_how_test.py __________________
ImportError while importing test module '/home/runner/work/Liburing/Liburing/test/file/open_how_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.12.11/x64/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test/file/open_how_test.py:1: in <module>
    from liburing import O_RDWR, RESOLVE_CACHED, open_how
E   ImportError: cannot import name 'O_RDWR' from 'liburing' (/opt/hostedtoolcache/Python/3.12.11/x64/lib/python3.12/site-packages/liburing/__init__.py)
_____________________ ERROR collecting test/import_test.py _____________________
ImportError while importing test module '/home/runner/work/Liburing/Liburing/test/import_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.12.11/x64/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test/import_test.py:2: in <module>
    from liburing import O_CREAT, AT_FDCWD
E   ImportError: cannot import name 'O_CREAT' from 'liburing' (/opt/hostedtoolcache/Python/3.12.11/x64/lib/python3.12/site-packages/liburing/__init__.py)
_____________________ ERROR collecting test/iovec_test.py ______________________
ImportError while importing test module '/home/runner/work/Liburing/Liburing/test/iovec_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.12.11/x64/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test/iovec_test.py:3: in <module>
    from liburing import SC_IOV_MAX, iovec
E   ImportError: cannot import name 'SC_IOV_MAX' from 'liburing' (/opt/hostedtoolcache/Python/3.12.11/x64/lib/python3.12/site-packages/liburing/__init__.py)
=========================== short test summary info ============================
ERROR test/file/open_how_test.py
ERROR test/import_test.py
ERROR test/iovec_test.py
!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!
============================== 3 errors in 0.47s ===============================
Error: Process completed with exit code 2.

I don't really have time (3AM) to look into this issues further today. I am so busy tomorrow as well but if I get a change I will look into it.

YoSTEALTH avatar Aug 19 '25 09:08 YoSTEALTH

same issue

meshya avatar Aug 26 '25 15:08 meshya

Looks like Cython > 3.0.11 doesn't import as it should! I am not sure if its a bug or a feature, I don't have time to dig too deep into it.

You would have to reinstall Liburing (which will use cython==3.0.11).

Edit: O, I actually wrote this whole library in Zig + cPython while ago, I will finish + upload it over the winter, no more Cython.

YoSTEALTH avatar Aug 27 '25 01:08 YoSTEALTH