Skip to content

Commit 11b5344

Browse files
committed
update docs
1 parent 8c2d3c5 commit 11b5344

File tree

2 files changed

+103
-12
lines changed

2 files changed

+103
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
### 2.2.0 (2020-04-06)
12
* Add support for `pip` flags: [--trusted-host](https://pip.pypa.io/en/stable/reference/pip/#trusted-host)
23
and [--extra-index-url](https://pip.pypa.io/en/stable/reference/pip_install/#install-extra-index-url) (#10)
3-
May be set in `python` extension or directly for `pip` tasks. Flags applied only
4-
to compatible pip commands.
4+
May be set in `python` extension or directly for `pip` tasks (`extraIndexUrls`, `trustedHosts`).
5+
Flags applied only to compatible pip commands.
56
* Allow dashes in vcs module name (for example, now it is possible to specify `#egg=my-module-11.2`).
67
NOTE: This may lead to problems with versions also containing dashes (1.1-alpha.1), but
78
it may be easily changed manually (to version without dashes: 1.1.alpha.1)
@@ -16,7 +17,7 @@
1617
It is not possible to support every possible pip flag with api so this manual customization
1718
is required to cover wider range of use-cases.
1819
* Fix gradle deprecation warnings on some tasks properties (#9)
19-
* Add environment variables configuration in extension: `python.envVar 'SAMPLE', 'value'`
20+
* Add environment variables configuration in extension: `python.environment 'SAMPLE', 'value'`
2021
* Fix checkPython execution when running from daemon (gradle work dir may differ from project root:
2122
confirmed case with gradle 6 on java 11).
2223
* Use relative path to virtualenv when possible instead of always absolute

README.md

Lines changed: 99 additions & 9 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:2.1.0'
55+
classpath 'ru.vyarus:gradle-use-python-plugin:2.2.0'
5656
}
5757
}
5858
apply plugin: 'ru.vyarus.use-python'
@@ -62,7 +62,7 @@ OR
6262

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

@@ -72,7 +72,7 @@ Plugin compiled for java 8, compatible with java 11
7272

7373
Gradle | Version
7474
--------|-------
75-
5-6 | 2.1.0
75+
5-6 | 2.2.0
7676
4.x | [1.2.0](https://github.com/xvik/gradle-use-python-plugin/tree/1.2.0)
7777

7878
#### Snapshots
@@ -351,6 +351,10 @@ Declares module `boson` version `0.9`, installed from git commit `b52727f7170acb
351351
`pipInstall` will be considered up-to-date if `boson==0.9` is already installed. Note that declared module version
352352
is completely free: you can set any version (0.10, 1.2, etc.), it is not checked and used only for up-to-date validation.
353353

354+
WARNING: module version part assumed to follow the last dash, so if you specify version like
355+
`somethinf-12.0-alpha.1` it would be parsed incorrectly (as package `somethinf-12.0` version `alpha.1`)!
356+
Don't use dashes in a version!
357+
354358
Vcs module installation is: source checkout and module build (using setup.py). You may need to specify subdirectory
355359
as `&subdirectory=pkg_dir` ([see docs](https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support))
356360

@@ -370,6 +374,73 @@ NOTE: since pip 20, compiled vcs module is cached (before it was build on each e
370374
it is possible to disable cache (for all modules) with `python.usePipCache=false` configuration
371375
(applies [--no-cache-dir](https://pip.pypa.io/en/stable/reference/pip_install/#caching) pip flag)
372376

377+
#### Extra pip repositories
378+
379+
To add additional pip repositories (probably self-hosted):
380+
381+
```groovy
382+
python {
383+
extraIndexUrls = ["http://extra-url.com", "http://extra-url.com"]
384+
}
385+
```
386+
387+
or with shortcut method (shortcut may be used multiple times):
388+
389+
```groovy
390+
python {
391+
extraIndexUrls "http://extra-url.com", "http://extra-url2.com"
392+
}
393+
```
394+
395+
Extra urls will be applied as [--extra-index-url](https://pip.pypa.io/en/stable/reference/pip_install/#install-extra-index-url)
396+
flag for pip commands supporting it: install, download, list and wheel. By default, it only affects `pipInstall` and `pipList` tasks.
397+
Applied for all `BasePipTask`, so if you have custom pip tasks, it would be affected too.
398+
399+
In case of ssl problems (stale or self-signed certificated), mark domains as trusted:
400+
401+
```groovy
402+
python {
403+
trustedHosts = ["extra-url.com"]
404+
}
405+
```
406+
407+
or
408+
409+
```groovy
410+
python {
411+
trustedHosts "extra-url.com"
412+
}
413+
```
414+
415+
Applied as [--trusted-host](https://pip.pypa.io/en/stable/reference/pip/#trusted-host)
416+
option only for `pipInstall` (because `pip install` is the only command supporting this option).
417+
418+
NOTE: if, for some reason, you don't want to specify it for all pip tasks, you can configure exact task,
419+
for example: `pipInstall.extraIndexUrls = ["http://extra-url.com", "http://extra-url2.com"]`
420+
421+
#### Extra pip install options
422+
423+
It is impossible to support directly all possible `pip install` [options](https://pip.pypa.io/en/stable/reference/pip_install/#options)
424+
usages directly with api (safe way), so there is a direct configuration for an additional options. For example:
425+
426+
```groovy
427+
pipInstall.options('--upgrade-strategy', 'only-if-needed')
428+
```
429+
430+
Shortcut method above may be called multiple times:
431+
432+
```groovy
433+
pipInstall.options('--a', 'value')
434+
pipInstall.options('--b', 'value')
435+
```
436+
437+
Or you can use property directly:
438+
439+
```groovy
440+
pipInstall.options = ['--a', 'value', '--b', 'value']
441+
```
442+
443+
373444
#### Virtualenv
374445

375446
When you declare any pip modules, plugin will try to use [virtualenv](https://virtualenv.pypa.io/en/stable/)
@@ -564,6 +635,9 @@ Map based declaration (`environment(['foo': 'bar', 'baz': 'bag'])`) does not rem
564635

565636
System variables will be available even after declaring custom variables (of course, custom variables could override global value).
566637

638+
NOTE: environment variable could also be declared in extension to apply for all python commands:
639+
`python.environment 'some', 1` (if environments declared both globally (through extension) and directly on task, they would be merged)
640+
567641
#### Configuration
568642

569643
##### Python location
@@ -614,7 +688,7 @@ python {
614688
##### Pip
615689

616690
By default, all installed python modules are printed to console after pip installations
617-
using `pip list` (of course, if at least one module were declared for installation).
691+
using `pip list` (of course, if at least one module declared for installation).
618692
This should simplify problems resolution (show used transitive dependencies versions).
619693

620694
To switch off:
@@ -656,6 +730,8 @@ python {
656730
pythonPath
657731
// python binary name (python or python3 by default)
658732
pythonBinary
733+
// additional environment variables, visible for all python commands
734+
environment = [:]
659735
660736
// minimal required python version (m.m.m)
661737
minPythonVersion
@@ -666,6 +742,13 @@ python {
666742
showInstalledVersions = true
667743
// always call module install, even if correct version is already installed
668744
alwaysInstallModules = false
745+
// may be used to disable pip cache (--no-cache-dir option)
746+
usePipCache = true
747+
// additional pip repositories (--extra-index-url option)
748+
extraIndexUrls = []
749+
// trusted hosts for pip install (--trusted-host option)
750+
trustedHosts = []
751+
669752
670753
// pip modules installation scope (project local, os user dir, global)
671754
scope = VIRTUALENV_OR_USER
@@ -677,9 +760,7 @@ python {
677760
// used virtualenv path (if virtualenv used, see 'scope')
678761
envPath = '.gradle/python'
679762
// copy virtualenv instead of symlink (when created)
680-
envCopy = false
681-
// may be used to disable pip cache (--no-cache-dir option)
682-
usePipCache = true
763+
envCopy = false
683764
}
684765
```
685766

@@ -729,13 +810,22 @@ Configuration:
729810
|----------|-------------|
730811
| pythonPath | Path to python binary. By default used path declared in global configuration |
731812
| pythonBinary | Python binary name. By default, python3 on linux and python otherwise. |
813+
| pythonArgs | Extra python arguments applied just after python binary. Useful for declaring common python options (-I, -S, etc.) |
814+
| environment | Process specific environment variables |
732815
| modules | Modules to install. In most cases configured indirectly with `pip(..)` task methods. By default, modules from global configuration. |
733816
| userScope | Use current user scope (`--user` flag). Enabled by default to avoid permission problems on *nix (global configuration). |
734817
| showInstalledVersions | Perform `pip list` after installation. By default use global configuration value |
735818
| alwaysInstallModules | Call `pip install module` for all declared modules, even if it is already installed with correct version. By default use global configuration value |
736819
| useCache | Can be used to disable pip cache (--no-cache-dir) |
820+
| extraIndexUrls | Additional pip repositories (--extra-index-url) |
821+
/ trustedHosts / trusted hosts (--trusted-host) /
822+
/ options / additional pip install options /
823+
824+
And, as shown above, custom methods:
737825

738-
And, as shown above, custom methods: `pip(String... modules)` and `pip(Iterable<String> modules)`
826+
* `pip(String... modules)`
827+
* `pip(Iterable<String> modules)`
828+
* `options(String... options)`
739829

740830
### Use as base for specific module plugin
741831

@@ -748,7 +838,7 @@ In your plugin, add plugin as dependency:
748838

749839
```groovy
750840
dependencies {
751-
implementation 'ru.vyarus:gradle-use-python-plugin:2.0.0'
841+
implementation 'ru.vyarus:gradle-use-python-plugin:2.2.0'
752842
}
753843
```
754844

0 commit comments

Comments
 (0)