[Feature Request] `nuitka` support
See original GitHub issueBeartype0.11 is incompatible with nuitka
env
Ubuntu 20.04
python 3.8
nuitka 1.2.7
beartype 0.11
Code:
import typing
from beartype.door import TypeHint
hint = typing.Union[int, float]
type_hints = TypeHint(hint)
for t in type_hints:
print(t)
build
python3 -m nuitka --onefile main.py
error
./main.bin
Traceback (most recent call last):
File "/tmp/.mount_main.bGqEond/main.py", line 3, in <module>
from beartype.door import TypeHint
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "/tmp/.mount_main.bGqEond/beartype/__init__.py", line 57, in <module beartype>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "/tmp/.mount_main.bGqEond/beartype/_decor/decormain.py", line 24, in <module beartype._decor.decormain>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "/tmp/.mount_main.bGqEond/beartype/_data/datatyping.py", line 26, in <module beartype._data.datatyping>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "/tmp/.mount_main.bGqEond/beartype/_cave/_cavefast.py", line 257, in <module beartype._cave._cavefast>
File "/tmp/.mount_main.bGqEond/beartype/_cave/_cavefast.py", line 250, in _closure_varcell_factory
TypeError: 'NoneType' object is not subscriptable
nuitka related issues:
# ....................{ TYPES ~ call : closure }....................
def _closure_varcell_factory():
'''
Arbitrary function returning a closure-specific cell variable exposed by an
arbitrary closure isolated to this function.
'''
# Arbitrary outer local variable.
cell_variable = 42
def closure():
'''
Arbitrary closure exposing a closure-specific cell variable.
'''
nonlocal cell_variable
return closure.__closure__[0] # pyright: ignore[reportOptionalSubscript]
# Although Python >= 3.7 now exposes an explicit closure cell variable type via
# the standard "types.CellType" object, this is of no benefit to older versions
# of Python. Ergo, the type of an arbitrary method wrapper guaranteed to
# *ALWAYS* exist is obtained instead.
ClosureVarCellType = type(_closure_varcell_factory())
Issue Analytics
- State:
- Created 9 months ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Feature Request: Support Nuitka · Issue #229 · yaml/pyyaml
I want to use Nuitka for a command line tool. This command line tool uses PyYaml. However, there is one problem PyYaml uses...
Read more >Ubuntu Manpage: nuitka - the Python compiler
--version show program's version number and exit -h, --help show this help message and exit --module Create an extension module executable instead of...
Read more >Intro to Nuitka: A better way to compile and distribute Python
The most common way to solve this issue is to package the program together with all its supporting libraries and files and the...
Read more >nuitka Changelog - pyup.io
The Yaml nuitka package configuration feature is getting ever more ... Plugins: Add support for ``pkg_resources.require`` calls to be
Read more >Nuitka 0.4.1 - PyPI
Python compiler with full language support and CPython compatibility. ... It may at times contain little regressions, but also new features.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Resolved by 475dda6… I think. I’ve added a new
test_nuitka()
integration test to ourpytest
test suite exercising thatnuitka
successfully compiles the example script above. That test is so painfully slow, though, that I’ve had to temporarily disable it – defeating the whole point of writing a test! Seriously, though. That test currently takes like twenty minutes on my ailing 2010-era AMD Athlon™ II X2 240. :face_exhaling:Let me know if you hit any additional snags with @beartype under
nuitka
. Until then, thanks again for this fascinating detour into the musty corridors of Python transpilation. You’re great, @shenwpo!@leycec, thank you for your timely reply! Using
ClosureVarCellType = types.CellType
seems to work normally, buttypes.CellType
is added in Python 3.8.I’m trying to use @beartype and the
TypeHint API
to help me with type analysis. Thanks again for your cool work!