Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Using precompiled packages #475

Answered by pyscripter
Nesavi asked this question in Q&A
Discussion options

Am I correct in assuming that precompiled packages can't be used when generating pyd-files? I've tried, and the script importing from my pyd-file fails.

You must be logged in to vote

Firstly, you should not be using LoadDLL in your extension modules but LoadDllInExtensionModule. See https://github.com/pyscripter/python4delphi/blob/master/Modules/DemoModule/uMain.pas as a guide.

Regarding runtime packages, is the directory containing them in the path?
Even if it is there was a change in python when searching for dlls. The Windows path is no longer searched.
See
https://docs.python.org/3/library/os.html#os.add_dll_directory
and https://stackoverflow.com/questions/67805339/is-the-function-os-add-dll-directory-adding-directories-permanently.

You can try:

  • copying all runtime packages in the same directory as the pyd file.
  • or use the os.add_dll_directory function before im...

Replies: 1 comment 4 replies

Comment options

Not sure what you are trying to do. Could you give a detailed minimal example?

You must be logged in to vote
4 replies
Comment options

Yes, I'd be happy to. Do you have a shared drive that I can upload a sample to?

Comment options

You can upload files here. A zipped project would do.

Comment options

Thanks for taking time to answer my question. It's much appreciated :)

The attached zip-file contains to project. The only difference between them, apart from their names, is that the project 'DelphiFromPython_DCP.dproj' has 'Link with runtime packages' set to true:
image

dcp_test.zip

Python 3.12.3 was used:

image

Comment options

Firstly, you should not be using LoadDLL in your extension modules but LoadDllInExtensionModule. See https://github.com/pyscripter/python4delphi/blob/master/Modules/DemoModule/uMain.pas as a guide.

Regarding runtime packages, is the directory containing them in the path?
Even if it is there was a change in python when searching for dlls. The Windows path is no longer searched.
See
https://docs.python.org/3/library/os.html#os.add_dll_directory
and https://stackoverflow.com/questions/67805339/is-the-function-os-add-dll-directory-adding-directories-permanently.

You can try:

  • copying all runtime packages in the same directory as the pyd file.
  • or use the os.add_dll_directory function before importing the pyd extension module.
Answer selected by pyscripter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /