@@ -52,7 +52,7 @@ buildscript {
52
52
jcenter()
53
53
}
54
54
dependencies {
55
- classpath 'ru.vyarus:gradle-use-python-plugin:2.1 .0'
55
+ classpath 'ru.vyarus:gradle-use-python-plugin:2.2 .0'
56
56
}
57
57
}
58
58
apply plugin: 'ru.vyarus.use-python'
62
62
63
63
``` groovy
64
64
plugins {
65
- id 'ru.vyarus.use-python' version '2.1 .0'
65
+ id 'ru.vyarus.use-python' version '2.2 .0'
66
66
}
67
67
```
68
68
@@ -72,7 +72,7 @@ Plugin compiled for java 8, compatible with java 11
72
72
73
73
Gradle | Version
74
74
--------|-------
75
- 5-6 | 2.1 .0
75
+ 5-6 | 2.2 .0
76
76
4.x | [ 1.2.0] ( https://github.com/xvik/gradle-use-python-plugin/tree/1.2.0 )
77
77
78
78
#### Snapshots
@@ -351,6 +351,10 @@ Declares module `boson` version `0.9`, installed from git commit `b52727f7170acb
351
351
` pipInstall` will be considered up-to-date if `boson==0.9` is already installed. Note that declared module version
352
352
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.
353
353
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
+
354
358
Vcs module installation is : source checkout and module build (using setup.py). You may need to specify subdirectory
355
359
as `&subdirectory=pkg_dir` ([see docs](https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support))
356
360
@@ -370,6 +374,73 @@ NOTE: since pip 20, compiled vcs module is cached (before it was build on each e
370
374
it is possible to disable cache (for all modules) with `python.usePipCache=false` configuration
371
375
(applies [--no-cache-dir](https://pip.pypa.io/en/stable/reference/pip_install/#caching) pip flag)
372
376
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
+
373
444
# ### Virtualenv
374
445
375
446
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
564
635
565
636
System variables will be available even after declaring custom variables (of course, custom variables could override global value).
566
637
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
+
567
641
#### Configuration
568
642
569
643
##### Python location
@@ -614,7 +688,7 @@ python {
614
688
##### Pip
615
689
616
690
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).
618
692
This should simplify problems resolution (show used transitive dependencies versions).
619
693
620
694
To switch off:
@@ -656,6 +730,8 @@ python {
656
730
pythonPath
657
731
// python binary name (python or python3 by default)
658
732
pythonBinary
733
+ // additional environment variables, visible for all python commands
734
+ environment = [:]
659
735
660
736
// minimal required python version (m.m.m)
661
737
minPythonVersion
@@ -666,6 +742,13 @@ python {
666
742
showInstalledVersions = true
667
743
// always call module install, even if correct version is already installed
668
744
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
+
669
752
670
753
// pip modules installation scope (project local, os user dir, global)
671
754
scope = VIRTUALENV_OR_USER
@@ -677,9 +760,7 @@ python {
677
760
// used virtualenv path (if virtualenv used, see 'scope')
678
761
envPath = '.gradle/python'
679
762
// 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
683
764
}
684
765
```
685
766
@@ -729,13 +810,22 @@ Configuration:
729
810
| ----------| -------------|
730
811
| pythonPath | Path to python binary. By default used path declared in global configuration |
731
812
| 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 |
732
815
| modules | Modules to install. In most cases configured indirectly with ` pip(..) ` task methods. By default, modules from global configuration. |
733
816
| userScope | Use current user scope (` --user ` flag). Enabled by default to avoid permission problems on * nix (global configuration). |
734
817
| showInstalledVersions | Perform ` pip list ` after installation. By default use global configuration value |
735
818
| alwaysInstallModules | Call ` pip install module ` for all declared modules, even if it is already installed with correct version. By default use global configuration value |
736
819
| 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:
737
825
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) `
739
829
740
830
### Use as base for specific module plugin
741
831
@@ -748,7 +838,7 @@ In your plugin, add plugin as dependency:
748
838
749
839
``` groovy
750
840
dependencies {
751
- implementation 'ru.vyarus:gradle-use-python-plugin:2.0 .0'
841
+ implementation 'ru.vyarus:gradle-use-python-plugin:2.2 .0'
752
842
}
753
843
```
754
844
0 commit comments