Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Gradle to build Python application

I use Python, PyQt, MySQL and Pyinstaller to build stand alone exe applications. I am very satisfied with the flexibility of this environment. Today however, I manually run independent commands to do the following types of tasks:

  1. Build .qrc resource files for all .qrc files in source path
  2. Build .ui qt-designer files for all .ui files in source path
  3. Build python exe using pyinstaller
  4. Delete the generated files because they clutter the source directory and are no longer needed
  5. Run my own custom script to build an installer for the pyinstaller generated exe

I would like to use Gradle as a build system for these tasks. I realize Gradle is mostly used for Java projects, but I see no reason it can't be used for Python projects.

Does anyone have a similar working example of a gradle.build file for the above tasks? Or... provide help in creating one?

Here are a few 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
like image 773
panofish Avatar asked Oct 14 '15 14:10

panofish


People also ask

Can Gradle build Python project?

PyGradle is an enterprise Python build system. PyGradle leverages Gradle to empower Python's existing ecosystem to solve problems like dependency management, polyglot projects, and lots more. LinkedIn has been using PyGradle for several years to successfully manage thousands of Python dependencies.

Is Gradle for Python?

We hope that using Gradle to build your Python code will be as simple as using Setuptools directly, but will provide you with more robust dependency management and a quality method to integrate against your existing metadata systems, in addition to allowing you to explore building products composed of multiple ...

Which programming language can use Gradle?

It is popular for its ability to build automation in languages like Java, Scala, Android, C/C++, and Groovy. The tool supports groovy based Domain Specific Language over XML. Gradle provides building, testing, and deploying software on several platforms.

Is Gradle the best build tool?

Gradle Build Tool is the most popular build tool for open source JVM projects on GitHub. It is downloaded on average more than 25 million times per month and has been counted in the Top 20 Most Popular Open Source Projects for IT by Techcrunch.


1 Answers

Interesting question! It may not help you explicitely with all your tasks but can give you an advice into the right direction.

Just have a look at the gradle Exec task. With that you might be able to run the necessary python build steps within your gradle build, e.g.

task runpy(type:Exec) {
    workingDir './pydir'
    commandLine 'python', 'pyinstaller.py'
} 
like image 152
ferdy Avatar answered Sep 19 '22 02:09

ferdy