How do I import modules from a SO file generated by nuitka?
See original GitHub issueI am interested in “Use Case 3”. I am very new to nuitka’s concepts, bare with me.
I am trying to use nuitka to “obfuscate” some django sub packages (“apps”)
My question is, can I reuse the shared object file generated by nuitka in python?
I have the following (basic example):
/api
/api/urls.py
python3 -m nuitka --module api --include-package=api
python3
>>> import api (works)
>>> from api import urls
ImportError: cannot import name 'urls'
I am also aware of the note in the documentation that says:
The recursion into the package directory needs to be provided manually, otherwise the package is empty.
However this is at odds with the --help command:
--include-package=PACKAGE
Include a whole package. Give as a Python namespace,
e.g. ``some_package.sub_package`` and Nuitka will then
find it and include it and all the modules found below
that disk location in the binary or extension module
it creates, and make it available for import by the
code.
Using --follow-import-to=api
appears to make no difference
Perhaps I am going about this all wrong, or can be gently reguided.
Thank you for your work.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
How do you use nuitka shared object files? - Stack Overflow
If you used --module you should probably just do: import some_package. Another approach to use ctypes: import ctypes my_package ...
Read more >Intro to Nuitka: A better way to compile and distribute Python
Compile a Python program with Nuitka By default, Nuitka only compiles the module you specify. If your module has imports—whether from elsewhere ...
Read more >Ubuntu Manpage: nuitka - the Python compiler
This allows you to transfer the created binary to other machines without it using ... Do not create a ".pyi" file for extension...
Read more >nuitka — Debian unstable
Select what value "__file__" is going to be. With "runtime" (default for standalone binary mode and module mode), the created binaries and modules,...
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
@Vigrond This might be a basic Python misunderstanding, but Python does not automatically import submodules.
You have to actually trigger the import for this to work. Only an
import module.sub_module
or with Python3 I think,from module import sub_module
will work.If I am getting something wrong, please try and make the minimal reproducer that illustrates what is working with standard Python and not with compiled code.
Lack of feedback.