problems in packaging FreeCAD python modules for klayout on win64 (windows10)

edited December 2023 in KLayout Development

I have built both klayout and FreeCAD in MSYS2/ucrt64. You may find:

FreeCAD directory is supposed to be created in c:\users\username\klayout\salt\layoutDD\python\ after having installed the layoutDD package.
I will insert this operation into the install procedure of layoutDD when FreeCAD import will work but at the moment there is a problem that can be detected using the https://github.com/wsteffe/layoutDD_FreeCAD/test.py:

#! /ucrt64/bin/python
import sys,os
#FCpath="../salt/layoutDD/python/FreeCAD/bin"
username = os.getenv("USERNAME")
FCpath="c:/users/"+username+"/klayout/salt/layoutDD/python/FreeCAD/bin"
if not FCpath in sys.path:
   sys.path.append(FCpath)

import FreeCAD
import Part
import Import
from BOPTools.ShapeMerge import mergeShapes
from BOPTools.GeneralFuseResult import GeneralFuseResult
Import.readDXF("pippo.dxf")

To check the problem please:

  • Install klayout using klayout-0.28.14-win64-ucrt-install.exe (you need windows10 or greater)
  • Install layoutDD package (or just create the folder c:\users\yourusername\klayout\salt\layoutDD\python)
  • Unzip FreeCAD.zip into the folder c:\users\yourusername\klayout\salt\layoutDD\python
  • Install python for the MSYS2 environment ucrt64
  • put test.py in folder "c:\users\yourusername\klayout\pymacros"
  • Open a msys shell and do:

    cd c:/users/yourusername/klayout/pymacros
    touch pippo.dxf
    ./test.py

    Here test.py is using python interpreter from ucrt64 and should run withour error

  • Launch klayout

  • Execute test.py inside the Klayout Macro Editor

Klayout Macro Editor gives me the following error:

Running macro C:/Users/walter/KLayout/pymacros\test1.py
DLL load failed while importing Part: The specified module could not be found.

I am looking for help to understand why FreeCAD modules can be imported in ucrt64/python but not in klayout/python even if both interpreter are built in MSYS2/ucrt64

Comments

  • Update: test.py gives no error if klayout is executed from a msys shell:

    cd C:/Users/username/KLayout/pymacros
    ../../appdata/roaming/klayout/klayout_app.exe -z -r test.py

    How could I make it work also when klayout is executed from windows GUI ?

  • Solved.
    The problem was due to my personal settiing of the windows path. Klayout was loading dlls built in mingw64 environment which are not compatible with ucrt64 code. The problem has disappeared after cleaning my windows path.

  • Thanks @wsteffe!

    I have merged the PR and I will try to include the ucrt64 build in the deployment. I can't promise a quick integration however.

    Best regards,

    Matthias

  • Thanks Matthias,
    I made another small pull request to fix wrong messages "NOT found xxx.dll" produced by deploy-win-ucrt64.sh.

  • @wsteffe Thanks, but I have a branch already (windows-build-ucrt64) which contains some more changes which I think are needed. Maybe you want to take a look at that.

    Matthias

Sign In or Register to comment.