yglukhov / nimpy

Nim - Python bridge
MIT License
1.46k stars 62 forks source link

Python can't import Nim 1.6.4 Modules on Windows #252

Closed qb-0 closed 2 years ago

qb-0 commented 2 years ago

Not sure if that's equivalent to #249 but I'm not able to import modules compiled with Nim 1.6.4 on WIndows.

C:\Users\qb\Downloads>choosenim-0.8.2_windows_amd64.exe 1.6.0
   Switched to Nim 1.6.0

C:\Users\qb\Downloads\nimpytest>nim c --threads:on --app:lib --out:add.pyd add.nim

C:\Users\qb\Downloads\nimpytest>python -c "import add; print(add.add(1, 5))"
6

C:\Users\qb\Downloads>choosenim-0.8.2_windows_amd64.exe stable
   Switched to Nim 1.6.4

C:\Users\qb\Downloads\nimpytest>nim c --threads:on --app:lib --out:add.pyd add.nim

C:\Users\qb\Downloads\nimpytest>python -c "import add; print(add.add(1, 5))"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: DLL load failed while importing add: Das angegebene Modul wurde nicht gefunden.
yglukhov commented 2 years ago

Please try compiling with --threads:off or --tlsEmulation:on and see if it helps.

qb-0 commented 2 years ago

--threads:off makes it importable again. So should projects be compiled with threads on or off?

yglukhov commented 2 years ago

What about --tlsEmulation:on? It might be a reasonable compromise. As long as you intend to use the module in a single thread, --threads:off should be fine too.

yglukhov commented 2 years ago

In the meantime, marking this as a duplicate of #203