Skip to content

Commit 4b8d78d

Browse files
committed
update docs
1 parent 6ed94c4 commit 4b8d78d

File tree

2 files changed

+46
-18
lines changed

2 files changed

+46
-18
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
### 2.0.0 (2020-03-13)
12
* (breaking) Drop java 7 support
23
* (breaking) Drop gradle 4 support
34
* Add `python.usePipCache` option to be able to disable cache for dependencies installation
4-
([--no-cache-dir](ttps://pip.pypa.io/en/stable/reference/pip_install/#caching))
5+
([--no-cache-dir](https://pip.pypa.io/en/stable/reference/pip_install/#caching))
56
Also, option added to Pip object constructor and BasePipTask (with default from extension)
67
* Add `Python.getBinaryDir()` returning (in most cases) executed python binary folder
78
(based on `sys.executable` with fallback to `sys.prefix/bin`)
@@ -16,7 +17,7 @@
1617
- Add `Python.pythonArgs` - args applied just after python executable
1718
- Add `PythonTask.pythonArgs`
1819
* Add `Virtualenv.python` accessor to be able to configure additional arguments
19-
* Add installed virtualenv version configuration: `python.virtualenv`. This way, plugin will
20+
* Add installed virtualenv version configuration: `python.virtualenvVersion`. This way, plugin will
2021
always install only known to be working version and avoid side effects of "just released"
2122
versions. By default, 16.7.9 would be installed because 20.0.x has some not fixed regressions
2223
* Use gradle tasks configuration avoidance for lazy tasks initialization (no init when tasks not needed)

README.md

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ buildscript {
5252
jcenter()
5353
}
5454
dependencies {
55-
classpath 'ru.vyarus:gradle-use-python-plugin:1.2.0'
55+
classpath 'ru.vyarus:gradle-use-python-plugin:2.0.0'
5656
}
5757
}
5858
apply plugin: 'ru.vyarus.use-python'
@@ -62,14 +62,18 @@ OR
6262

6363
```groovy
6464
plugins {
65-
id 'ru.vyarus.use-python' version '1.2.0'
65+
id 'ru.vyarus.use-python' version '2.0.0'
6666
}
6767
```
6868

6969
#### Compatibility
7070

71-
Plugin compiled for java 7.
72-
Compatible with gradle 4 and above.
71+
Plugin compiled for java 8, compatible with java 11
72+
73+
Gradle | Version
74+
--------|-------
75+
5-6 | 2.0.0
76+
4.x | [1.1.0](https://github.com/xvik/gradle-mkdocs-plugin/tree/1.1.0)
7377

7478
#### Snapshots
7579

@@ -165,14 +169,20 @@ Make sure the latest pip installed (required to overcome some older pip problems
165169
pip3 install -U pip
166170
```
167171

172+
To install exact pip version:
173+
174+
```bash
175+
pip3 install -U pip==10.0.0
176+
```
177+
168178
Note that on ubuntu pip installed with `python3-pip` package is 9.0.1, but it did not(!) downgrade
169179
module versions (e.g. `pip install click 6.6` when click 6.7 is installed will do nothing).
170180
Maybe there are other differences, so it's highly recommended to upgrade pip with `pip3 install -U pip`.
171181

172182
#### Automatic pip upgrade
173183

174184
As described above, there are different ways of pip installation in linux and, more important,
175-
admin permissions are required to upgrade global pip. So it is impossible to upgrade pip from plugin (in all cases).
185+
admin permissions are required to upgrade global pip. So it is impossible to upgrade pip from the plugin (in all cases).
176186

177187
But, it is possible inside virtualenv or user (--user) scope. Note that plugin creates virtualenv by default (per project independent python environment).
178188

@@ -279,8 +289,8 @@ will be used:
279289
python.pip 'module1:2.0', 'module2:1.0', 'module1:1.0'
280290
```
281291

282-
Will install version 1.0 of module1 because it was the latest declaration. Module overrides
283-
work for all declaration types (see below): the last declared module is used.
292+
Will install version 1.0 of module1 because it was the latest declaration. "Module overrides"
293+
works for all declaration types (see below): the latest declared module version always wins.
284294

285295
Dependencies are installed with `pipInstall` task which is called before any declared `PythonTask`.
286296

@@ -356,7 +366,9 @@ All pip supported vcs could be used: git, svn, hg, bzr
356366
If up-to-date logic, implemented by `pipInstall` task, does not suit your needs, you can always
357367
disable it with `python.alwaysInstallModules = true` (pip always called). But this will be slower.
358368

359-
NOTE: since pip 20, compiled vcs module is cached (before it was build on each execution)
369+
NOTE: since pip 20, compiled vcs module is cached (before it was build on each execution), but
370+
it is possible to disable cache (for all modules) with `python.usePipCache=false` configuration
371+
(applies [--no-cache-dir](https://pip.pypa.io/en/stable/reference/pip_install/#caching) pip flag)
360372

361373
#### Virtualenv
362374

@@ -370,6 +382,10 @@ installation then disable it:
370382
python.installVirtualenv = false
371383
```
372384

385+
Plugin installs exact pip version declared in `python.virtualenvVersion` (by default, 16.7.9).
386+
This way, plugin will always install only known to be working version and avoid side effects of "just released"
387+
versions (note that pip 20 is a major rewrite and may still contain side effects).
388+
373389
In any case, plugin checks if virtualenv is already installed and use it to create local environment
374390
(if not, then fall back to `--user` scope by default). Virtualenv usage is driven by declared scope, so if you don't want to use it set:
375391

@@ -379,7 +395,7 @@ python.scope = USER // or GLOBAL
379395

380396
With USER (or GLOBAL) scope, virtualenv will not be used, even if it's already created in project (plugin will ignore it and use global python).
381397

382-
If you already use virtualenv in your project (have created environment), then simply point plugin to use it:
398+
If you already use virtualenv in your project (have created manually environment), then simply point plugin to use it:
383399

384400
```groovy
385401
python.envPath = 'path/to/your/env'
@@ -427,6 +443,8 @@ python.scope = VIRTUALENV
427443
Note that values may be declared without quotes because it's an enum which values are
428444
declared as project ext properties (`ext.USER==ru.vyarus.gradle.plugin.python.PythonExtension.Scope.USER`).
429445

446+
Complete behaviour matrix [see above](#usage)
447+
430448
#### Check modules updates
431449

432450
To quick check if new versions are available for the registered pip modules
@@ -444,7 +462,7 @@ The following modules could be updated:
444462
Note that it will not show versions for transitive modules, only
445463
for modules specified directly in `python.pip`.
446464

447-
To see all available updates (wihout filtering):
465+
To see all available updates (without filtering):
448466

449467
```groovy
450468
pipUpdates.all = true
@@ -550,7 +568,7 @@ python {
550568

551569
`pythonPath` must be set to directory containing python binary (e.g. 'path/to/python/binray/python.exe')
552570

553-
NOTE: `pythonPath` is ignored when virtualenv used.
571+
NOTE: `pythonPath` is ignored when virtualenv used (virtualenv located at `python.envPath` already exists).
554572

555573
##### Minimal python and pip versions
556574

@@ -598,7 +616,7 @@ pipList.all = true
598616

599617
Global modules are hidden by default (for USER scope) because on linux there are a lot of system modules pre-installed.
600618

601-
By default 'pip install' is not called for modules already installed with correct version.
619+
By default, 'pip install' is not called for modules already installed with correct version.
602620
In most situations this is preferred behaviour, but if you need to be sure about dependencies
603621
then force installation:
604622

@@ -633,10 +651,15 @@ python {
633651
scope = VIRTUALENV_OR_USER
634652
// automatically install virtualenv module (if pip modules declared and scope allows)
635653
installVirtualenv = true
654+
// if virtualenv not installed (in --user scope), plugin will install exactly this version
655+
// (known to be working version) to avoid side effects
656+
virtualenvVersion = '16.7.9'
636657
// used virtualenv path (if virtualenv used, see 'scope')
637658
envPath = '.gradle/python'
638659
// copy virtualenv instead of symlink (when created)
639660
envCopy = false
661+
// may be used to disable pip cache (--no-cache-dir option)
662+
usePipCache = true
640663
}
641664
```
642665

@@ -656,11 +679,14 @@ PythonTask configuration:
656679
| module | Module name to call command on (if command not set module called directly). Useful for derived tasks. |
657680
| command | Python command to execute (string, array, iterable) |
658681
| logLevel | Logging level for python output. By default is `LIFECYCLE` (visible in console). To hide output use `LogLevel.INFO` |
659-
| extraArgs | Extra arguments applied at the end of declared command. Useful for derived tasks to declare default options |
682+
| pythonArgs | Extra python arguments applied just after python binary. Useful for declaring common python options (-I, -S, etc.) |
683+
| extraArgs | Extra arguments applied at the end of declared command (usually module arguments). Useful for derived tasks to declare default options |
660684
| outputPrefix | Prefix, applied for each line of python output. By default is '\t' to identify output for called gradle command |
661685

662-
Also, task provide extra method `extraArgs(String... args)` to declare extra arguments (shortcut to append values to
663-
extraArgs property).
686+
Also, task provide extra methods:
687+
688+
* `pythonArgs(String... args)` to declare extra python arguments (shortcut to append values to pythonArgs property).
689+
* `extraArgs(String... args)` to declare extra arguments (shortcut to append values to extraArgs property).
664690

665691
#### PipInstallTask
666692

@@ -683,6 +709,7 @@ Configuration:
683709
| userScope | Use current user scope (`--user` flag). Enabled by default to avoid permission problems on *nix (global configuration). |
684710
| showInstalledVersions | Perform `pip list` after installation. By default use global configuration value |
685711
| alwaysInstallModules | Call `pip install module` for all declared modules, even if it is already installed with correct version. By default use global configuration value |
712+
| useCache | Can be used to disable pip cache (--no-cache-dir) |
686713

687714
And, as shown above, custom methods: `pip(String... modules)` and `pip(Iterable<String> modules)`
688715

@@ -697,7 +724,7 @@ In your plugin, add plugin as dependency:
697724

698725
```groovy
699726
dependencies {
700-
compile 'ru.vyarus:gradle-use-python-plugin:1.2.0'
727+
implementation 'ru.vyarus:gradle-use-python-plugin:2.0.0'
701728
}
702729
```
703730

0 commit comments

Comments
 (0)