ansys / pydpf-core

Data Processing Framework - Python Core
http://dpf.docs.pyansys.com/
MIT License
68 stars 25 forks source link

Crash with pyinstaller environment #1216

Closed BClappe closed 1 year ago

BClappe commented 1 year ago

Before submitting the issue

Description of the bug

When using examples from ansys-dpf-core in a pyinstaller environment, the program crashes. This is due to a function not being given a parameter when it should (ansys.dpf.core : init.py line 13). See documentation here.

A possible fix is to give it __name__ as a parameter but I'm unsure if this is what was intended at first.

The bug has been detected on windows but it is very possible that it appears on linux and macos as well. The bug shouldn't particularly be bound to any python version.

Steps To Reproduce

Install pyinstaller and ansys-dpf-core. Run the following main.py in a pyinstaller environment:

from ansys.dpf import core as dpf
from ansys.dpf.core import examples

model = dpf.Model(examples.download_crankshaft()) # Should fail here
print("Created model:\n", model)

You can also use the following archive which is configured for you with all you need to reproduce the bug: python_installer.zip

Which Operating System causes the issue?

Windows

Which DPF/Ansys version are you using?

Ansys 2023 R2

Which Python version causes the issue?

3.11

Installed packages

altgraph==0.17.4 ansys-dpf-core==0.9.0 ansys-dpf-gate==0.4.1 ansys-dpf-gatebin==0.4.1 ansys-grpc-dpf==0.8.1 cachetools==5.3.1 certifi==2023.7.22 charset-normalizer==3.3.0 colorama==0.4.6 google-api-core==2.12.0 google-api-python-client==2.103.0 google-auth==2.23.3 google-auth-httplib2==0.1.1 googleapis-common-protos==1.61.0 grpcio==1.59.0 httplib2==0.22.0 idna==3.4 importlib-metadata==6.8.0 numpy==1.26.1 packaging==23.2 pefile==2023.2.7 protobuf==4.24.4 psutil==5.9.6 pyasn1==0.5.0 pyasn1-modules==0.3.0 pyinstaller==5.12.0 pyinstaller-hooks-contrib==2023.5 pyparsing==3.1.1 pywin32-ctypes==0.2.2 requests==2.31.0 rsa==4.9 tqdm==4.66.1 uritemplate==4.1.1 urllib3==2.0.6 zipp==3.17.0

PProfizi commented 1 year ago

@BClappe just a note: I tested the code mentioned and the function does work properly and return the module path, despite not being given a parameter, when run on Windows using a Python 3.9 based venv with ansys-dpf-core installed in editable mode.