DOCUMENTATION: https://xvik.github.io/gradle-use-python-plugin/
Plugin does not install python and pip itself and use globally installed python (by default). It's easier to prepare python manually because python have good compatibility (from user perspective) and does not need to be updated often.
Also, plugin could run python inside docker container to avoid local python installation.
The only plugin intention is to simplify python usage from gradle. By default, plugin creates python virtualenv inside the project and installs all modules there so each project has its own python (copy) and could not be affected by other projects or system changes.
Features:
- Works with directly installed python or docker container (with python)
- Creates local (project-specific) virtualenv (project-specific python copy)
- Installs required pip modules (venv by default (with fallback to virtualenv), but could be global installation)
- Support requirements.txt file (limited by default)
- Compatible with gradle configuration cache
- Could be used as basement for building plugins for specific python modules (like mkdocs plugin)
- Configuration:
python
- Tasks:
checkPython
- validate python installation (and create virtualenv if required)cleanPython
- clean created python environmentpipInstall
- install declared pip modulespipUpdates
- show the latest available versions for the registered modulespipList
- show all installed modules (the same as pipInstall shows after installation)type:PythonTask
- call python command/script/moduletype:PipInstallTask
- may be used for custom pip modules installation workflow
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'ru.vyarus:gradle-use-python-plugin:4.1.0'
}
}
apply plugin: 'ru.vyarus.use-python'
OR
plugins {
id 'ru.vyarus.use-python' version '4.1.0'
}
Plugin compiled for java 8, compatible with java 11, 17. Supports python 2 (not tested anymore, but should work) and 3 on windows and linux (macos)
Gradle | Version |
---|---|
7-8 | 4.1.0 |
5.3 | 3.0.0 |
5-5.2 | 2.3.0 |
4.x | 1.2.0 |
Snapshots may be used through JitPack
-
Go to JitPack project page
-
Select
Commits
section and clickGet it
on commit you want to use or usemaster-SNAPSHOT
to use the most recent snapshot -
Add to
settings.gradle
(top most!) (exact commit hash might be used as version):pluginManagement { resolutionStrategy { eachPlugin { if (requested.id.id == 'ru.vyarus.use-python') { useModule('ru.vyarus:gradle-use-python-plugin:master-SNAPSHOT') } } } repositories { gradlePluginPortal() maven { url 'https://jitpack.io' } } }
-
Use plugin without declaring version:
plugins { id 'ru.vyarus.use-python' }
Make sure python and pip are installed:
python --version
pip --version
On *nix python
usually reference python2. For python3:
python3 --version
pip3 --version
OR enable docker support to run python inside docker container
Read documentation
- quality-plugin - java and groovy source quality checks
- animalsniffer-plugin - java compatibility checks
- pom-plugin - improves pom generation
- java-lib-plugin - avoid boilerplate for java or groovy library project
- github-info-plugin - pre-configure common plugins with github related info