Python project packaging records

At present, I am a beginner in the python project and have completed part of the script command work, but for the purpose of creating an internal incubation app and convenient operation tools. To facilitate the "secrecy" of the code. We are going to provide app packages for small partners to use, and here are some experience in using packages.

At present, mac is mainly used for packaging, and it is also mainly used for apps on mac computers. Beginners have not tried the direction of windows packaging.

        

        First of all, in terms of recommendations, pyinstaller has more recommendations. We also use this, and other py2apps can be researched by ourselves.

Pack

1. Installation tool

//安装pyinstaller工具
pip install pyinstaller

pyinstaller command parameter explanation:

2. For the already written py script (here I use a visual page written by tkinter)

 pyinstaller -D -w /Users/caoshixin/Person/CSXPythonFile/GUI/tkinter/compress.py 

Here -D is used instead of -F to generate, mainly to make the application run and start quickly.

  • Use -F to pack a small volume, but the double-click startup is relatively slow, and the response is 1 minute, as if there is no click.
  • -D is packaged to generate a folder, and there will also be an app file at the same time. The file submission is relatively large, but the startup speed is normal.

There is also an article above that says that the python virtual environment uses anaconda to create a pure python virtual environment (this is packaged with py2app when it is said that if you do not use -A, all the local packages of pip will be typed in. The size of the package is abnormally large, but pyinstaller does not seem to have this problem, first use it and then study the details, anyway, there will be no harm).

 Click this environment, open in terminal, and then you can see the terminal screenshot of the above virtual environment, just execute the defeat command in it.

  • The screenshot of the above command explains: I created a folder "New Folder" by myself, and did not execute the packaging command in the project.

3. Then you can see the .app file used by our mac computer in the dist folder

app to dmg

For the convenience of others, we package the app into dmg for forwarding.

  1. Create a new folder on the desktop dmgand put the app file in it.

  2. In order to achieve the drag-and-drop effect, you need to put a double Applicationin this folder .Application

    cd /Users/xxxxx/Desktop/dmg
    ln -s /Applications/ Applications
  3.  Open LaunchPad - Disk Utility

  4.  Click on the directory bar of Disk Utility, select File - New Image - Image from Folder

  5. select directory/Users/xxxxx/Desktop/dmg

  6. Fill in the file name to save the .dmg

  7. The generation is successful, double-click to install and use

 

Supongo que te gusta

Origin blog.csdn.net/BUG_delete/article/details/129823237
Recomendado
Clasificación