Using Gradle to Create a Python Application

I use Python, PyQt, MySQL and Pyinstaller to create standalone exe applications. I am very pleased with the flexibility of this environment. However, today I manually run independent commands to perform the following tasks:

  • Create .qrc resource files for all .qrc files in the source path
  • Create .ui qt-designer files for all .ui files in the source path.
  • Building a python exe using pyinstaller
  • Delete the generated files because they clutter up the source directory and are no longer needed.
  • Run your own custom script to create an installer for the created pyinstaller exe

I would like to use Gradle as a build system for these tasks. I understand that Gradle is mainly used for Java projects, but I see no reason why it cannot be used for Python projects.

Does anyone have a similar working example gradle.build file for the above tasks? Or ... help create one?

Here are some detailed examples of the above commands:

C:/Python27/Lib/site-packages/PyQt4/pyuic4.bat $file > ${file_base_name}_ui.py C:/Python27/Lib/site-packages/PyQt4/pyrcc4.exe $file -o ${file_base_name}_rc.py c:/python27/python.exe c:/pyinstaller/pyinstaller.py --onefile --noconsole --out=$file_path/$file 
+6
source share
1 answer

Interest Ask! This may not help you explicitly with all your tasks, but it may give you advice in the right direction.

Just view the gradle Exec task. With this, you could follow the necessary steps of building python in your gradle assembly, for example.

 task runpy(type:Exec) { workingDir './pydir' commandLine 'python', 'pyinstaller.py' } 
0
source

All Articles