Juan C.Cilleruelo 12 Posted January 22, 2023 I'm almost sure this is not the ideal forum to ask this, but maybe someone has a quick response. I want to deploy my Delphi application that uses Python4Delphi. Because I wanted my application standalone, during the installation, I deployed to the Python version needed without registering it. This allows me to not ask the user for the need to have a particular version of Python on his computer, but... Hat happens with the rest of the third-party modules, like Pyvista? On my computer, for developing the Delphi Application, I've installed Pyvista with pip, but I don't know how to install it at the same time that the Delphi Application. One option is from the installer, call pip to install it, but my Python is unregistered. I don't know if this is going to be possible. Another option is to deploy the files I have on my developing computer, but I don't know if this will work on the target machine. Are there other options? Do you know a "correct" form of doing this? Many thanks for considering my request. Share this post Link to post
SwiftExpat 65 Posted January 22, 2023 1 hour ago, Juan C.Cilleruelo said: a "correct" form of doing this? I will add a requirement that you want a stable deployment to test against, so that you can certify your software and have a basic support level matrix. I selected python embedded, so I know my python version is 3.9.x. I then PIP installed the modules so the version of each module is known and can be tested to work. I then zip all of that up and deploy it as a sub-directory to my executable. Correct depends on what you believe you can support on the client system. Share this post Link to post
Juan C.Cilleruelo 12 Posted January 22, 2023 6 hours ago, SwiftExpat said: I will add a requirement that you want a stable deployment to test against, so that you can certify your software and have a basic support level matrix. I think both requirements were implicit in the main ask. But thanks. 6 hours ago, SwiftExpat said: I selected python embedded, so I know my python version is 3.9.x. I then PIP installed the modules so the version of each module is known and can be tested to work. I then zip all of that up and deploy it as a sub-directory to my executable. That's the solution I imagined: the response I searched for. I understand that this is the working method of doing the standalone (embedded) deployments of third-party python tools. For me, this is the meaning of "correct." 6 hours ago, SwiftExpat said: Correct depends on what you believe you can support on the client system. I want that, for the client system administrator, to be transparent the installed version of python or the tools added. If he wants, he cant install his own Python without collision with the python my Delphi program uses. Thank you @SwiftExpat Share this post Link to post
SwiftExpat 65 Posted January 22, 2023 C runtime is only item lacking with py embbeded, install it with pip and copy it to your EXE dir. python -m pip install msvc_runtime Here is what mine looks like on the file system: Share this post Link to post
shineworld 73 Posted January 22, 2023 That's what I do: 1) download python embd version. 2) added pip 3) make a backup of this point 4) used pio to install any package 5) used pip to create a requirement.txt of installed packages with version 6) used wheel to download whl of packages from requirements.txt 7) zipped python embd of point 3 8) used innosetup to install my exe + python embed + whl packages 9) during install placed exe in programs,l paced and extracted python in USERAPPDATA and then with script installed offline pip and whl packages. In this mode it's simple to upgrade packages with more fresh without touch python things and end user can install python and packages without a internet connection. Share this post Link to post
shineworld 73 Posted January 23, 2023 These are 3 scripts (windows) that I use to: 1] create requirements.txt file of pip installed packages 2] download whl packages from requirements.txt 3] install the whl packages (offline) A resulting requirements.txt looks like: cffi==1.15.1 cnc-api-client-core==1.3.1 contourpy==1.0.6 cryptography==38.0.4 cycler==0.11.0 delphifmx==0.1.51 delphivcl==0.1.40 fonttools==4.38.0 kiwisolver==1.4.4 lxml==4.9.2 matplotlib==3.6.2 numpy==1.23.4 opcua==0.98.13 opencv-contrib-python==4.6.0.66 packaging==21.3 pbr==5.11.0 Pillow==9.3.0 pip==22.3.1 pybind11==2.10.1 pycparser==2.21 pyparsing==3.0.9 PySide6==6.4.0.1 PySide6-Addons==6.4.0.1 PySide6-Essentials==6.4.0.1 PySimpleGUI==4.60.4 python-dateutil==2.8.2 pytz==2022.7 scipy==1.9.3 screeninfo==0.8.1 setuptools==65.5.1 shiboken6==6.4.0.1 six==1.16.0 skia-python==87.5 tendo==0.3.0 wheel==0.38.3 Inno Setup script install Python embd and packages in this way; [Run] Filename: {userpf}\{#MyAppName}.python\python.64.exe; Parameters: "-y"; WorkingDir: {userpf}\{#MyAppName}.python; StatusMsg: Unpack Python files...; Flags: runhidden Filename: {userpf}\{#MyAppName}.python\python.exe; Parameters: "-m pip install --no-index --find-links offline-packages --force-reinstall --requirement requirements.txt"; WorkingDir: {userpf}\{#MyAppName}.python; StatusMsg: Install Python Offline Packages...; Flags: runhidden #endif python-create-requirements.bat python-offline-download.bat python-offline-install.bat Share this post Link to post
Juan C.Cilleruelo 12 Posted February 2, 2023 On 1/22/2023 at 1:02 PM, SwiftExpat said: ... I then PIP installed the modules so the version of each module is known and can be tested to work. I can't install the modules with pip. Seems it is not working well; C:\Views\CuttingBoards\bin\Win64\Python\Scripts>pip install pyvista Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "C:\Views\CuttingBoards\bin\Win64\Python\Scripts\pip.exe\__main__.py", line 4, in <module> ModuleNotFoundError: No module named 'pip' Share this post Link to post
Juan C.Cilleruelo 12 Posted February 2, 2023 On 1/22/2023 at 8:11 PM, shineworld said: That's what I do: 1) download python embd version. 2) added pip 3) make a backup of this point 4) used pio to install any package 5) used pip to create a requirement.txt of installed packages with version 6) used wheel to download whl of packages from requirements.txt 7) zipped python embd of point 3 😎 used innosetup to install my exe + python embed + whl packages 9) during install placed exe in programs,l paced and extracted python in USERAPPDATA and then with script installed offline pip and whl packages. In this mode it's simple to upgrade packages with more fresh without touch python things and end user can install python and packages without a internet connection. I thank your explanation, but I see that the purpose of this method is to allow the final user to update the packages when he wants. I don't want this. If the final user wishes to have python installed on his machine, he must install it as established and independently from my embedded python. My embedded python shall be updated only when the user installs a new version of my program. This is the spirit of "embedded" in this context. Share this post Link to post
shineworld 73 Posted February 2, 2023 The embedded python is not in the Windows path so he can't reach the %USERDATA%\Programs\Python\<embedded_python_path>\Scripts\pip. You can also remove pip during installation when finisched to install all the offline packages 🙂 Share this post Link to post
SwiftExpat 65 Posted February 2, 2023 I think you are missed the pth file, review the steps in this answer and double check: https://stackoverflow.com/a/48906746 Share this post Link to post
shineworld 73 Posted February 2, 2023 The readme is in Italian language but can be simply tranlsated with google: After pip installation with > python get-pip.py it is necessary to rename python<version>._pth to python<version>._pth-disabled or delete it so you can install packages with pip. readme.txt Share this post Link to post