Git Product home page Git Product logo

Comments (11)

ShapingView avatar ShapingView commented on July 21, 2024 1

I tested it, the test script works for me, too! Thanks

from nuitka.

kayhayen avatar kayhayen commented on July 21, 2024

Are you sure your program is running with Python3.12, since there is no imp module.

from nuitka.

kayhayen avatar kayhayen commented on July 21, 2024

Ah, it's probably these things:

      replacements:
        "load_first_config(['config.py'], True)": "textwrap.indent(pkgutil.get_data('cv2', 'config.py').decode('utf8'), '    ') + textwrap.indent(pkgutil.get_data('cv2', 'config-3.py').decode('utf8'), '    ')"
        # Before OpenCV 4.6
        'native_module = importlib.import_module("cv2.cv2")': '"import imp; native_module = imp.load_dynamic(\"cv2\", os.path.join(os.path.dirname(__file__), \"cv2%s\"))" % getSharedLibrarySuffix(False)'
        # After OpenCV 4.6
        'native_module = importlib.import_module("cv2")': '"import imp; native_module = imp.load_dynamic(\"cv2\", os.path.join(os.path.dirname(__file__), \"cv2%s\"))" % getSharedLibrarySuffix(False)'

These could be changed to use _imp I suppose.

from nuitka.

kayhayen avatar kayhayen commented on July 21, 2024

Thanks for your report, this is fixed on the factory branch, which is a development version under rapid development. You can try it out by going here: https://nuitka.net/doc/factory.html

Feedback on whether this is working is very welcome. Please do not share plans to do it; only confirm or deny that it is working.

from nuitka.

kayhayen avatar kayhayen commented on July 21, 2024

Let me know if it works, I only changed the code, expecting everything else to be fine now.

from nuitka.

ShapingView avatar ShapingView commented on July 21, 2024

I tried it, it seems to have fixed the initial error, but now the error changed to this one

build execution
> python -m nuitka --mingw64 --standalone --output-dir=. --main=.\hw.py
Nuitka-Options: Used command line options: --mingw64 --standalone --output-dir=. --main=.\hw.py
Nuitka: Starting Python compilation with Nuitka '2.4rc4' on Python '3.12' commercial grade 'not installed'.
Nuitka: Completed Python level compilation and optimization.
Nuitka: Generating source code for C backend compiler.
Nuitka: Running data composer tool for optimal constant value handling.                 
Nuitka: Running C compilation via Scons.
Nuitka-Scons: Backend C compiler: gcc (gcc 13.2.0).
Nuitka-Scons: Backend linking program with 102 files (no progress information available for this stage).
Nuitka-Scons: Compiled 102 C files using ccache.
Nuitka-Scons: Cached C files (using ccache) with result 'cache hit': 47
Nuitka-Scons: Cached C files (using ccache) with result 'cache miss': 55
Nuitka-Plugins:dll-files: Found 1 file DLLs from cv2 installation.
Nuitka: Keeping build directory 'hw.build'.
Nuitka: Successfully created 'hw.dist\hw.exe'.
pip freeze
python -m pip freeze
Nuitka @ https://github.com/Nuitka/Nuitka/archive/factory.zip#sha256=7a70543e409a3ab180ad6e157451ff2fd647c882c223f8e49b114c9bfd0aeebe
numpy==1.26.4
opencv-python-headless==4.9.0.80
ordered-set==4.1.0
zstandard==0.22.0
> .\hw.dist\hw.exe
Traceback (most recent call last):
  File "C:\Users\SHAPIN~1\Desktop\repos\test\HWBF46~1.DIS\hw.py", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "C:\Users\SHAPIN~1\Desktop\repos\test\HWBF46~1.DIS\cv2\__init__.py", line 209, in <module cv2>
  File "C:\Users\SHAPIN~1\Desktop\repos\test\HWBF46~1.DIS\cv2\__init__.py", line 181, in bootstrap
AttributeError: module '_imp' has no attribute 'load_dynamic'

from nuitka.

kayhayen avatar kayhayen commented on July 21, 2024

Too bad, I think I saw it on older versions, wasn't expecting it to not be there.

from nuitka.

kayhayen avatar kayhayen commented on July 21, 2024

So, in the tests of CPython 3.12, they copied the code of load_dynamic from the former imp module, which would be one way of doing it, and probably what we have to do. I will give it a shot, if anything is needed at all there, maybe for 4.6+ it is now needed at all, and we continued doing it.

from nuitka.

kayhayen avatar kayhayen commented on July 21, 2024

Unfortunately the workaround is still needed though.

from nuitka.

kayhayen avatar kayhayen commented on July 21, 2024

I devised a manual load with ExtensionFileLoader just as done in the 3.12 test suite, for which there seems to be no function in proper Python anymore. Manual module loading is going to spread like wildfire, and people barely get those things correct, but what do I know, slightly annoyed here.

from nuitka.

kayhayen avatar kayhayen commented on July 21, 2024

So right now factory is actually working.

from nuitka.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.