-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
174 lines (153 loc) · 5.64 KB
/
build.gradle
File metadata and controls
174 lines (153 loc) · 5.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
plugins {
id 'ru.vyarus.use-python' version '3.0.0'
}
apply plugin: 'base'
ext {
if (project.rootProject.hasProperty('pypi_repo')) {
pypi_repo = project.rootProject.findProperty('pypi_repo')
} else {
pypi_repo = 'testpypi'
}
if (!project.rootProject.hasProperty('vantiqSdkVersion')) {
vantiqSdkVersion = '1.4.9'
}
// See if we are using virtualenvwrapper and if so put the virtualenv in the WORKON_HOME
if (System.getenv('WORKON_HOME')) {
virtualenvPath = System.getenv('WORKON_HOME') + "/vantiqsdk"
}
String depList = ''
project.file('requirements-sdk.in').eachLine { dep ->
dep = dep.trim()
// Skip comments and blank lines
if (dep.startsWith('#') || dep.length() == 0) {
return
}
// Add the dependency to the list
if (depList.length() > 0) {
depList += ",\n"
}
depList += ' "' + dep + '"'
}
vantiqSdkDeps = depList
}
wrapper {
gradleVersion = '8.12.1'
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
}
python {
// python binary name (python or python3 by default)
pythonBinary
// path to python binary (global by default)
pythonPath
// Let pip parse the requirements to txt file
// use-python plugin has issues with more complex requirements.txt specifications
requirements.strict = false
// additional environment variables, visible for all python commands
// Note: We specify the directory paths to search in the pytest.ini file
environment = [:]
// minimal required python version (m.m.m)
minPythonVersion = '3.10'
// minimal required pip version (m.m.m)
minPipVersion = '9'
// show all installed modules versions after pip installation
showInstalledVersions = true
// always call module install, even if correct version is already installed
alwaysInstallModules = false
// may be used to disable pip cache (--no-cache-dir option)
usePipCache = true
// additional pip repositories (--extra-index-url option)
extraIndexUrls = []
// trusted hosts for pip install (--trusted-host option)
trustedHosts = []
// pip modules installation scope (project local, os user dir, global)
scope = VIRTUALENV_OR_USER
// automatically install virtualenv module (if pip modules declared and scope allows)
installVirtualenv = true
// if virtualenv not installed (in --user scope), plugin will install exactly this version
// (known to be working version) to avoid side effects
virtualenvVersion = '20.4.2'
// minimal required virtualenv (v20 is recommended, but by default 16 set to not fail previous
// setups)
minVirtualenvVersion = '20'
// used virtualenv path (if virtualenv used, see 'scope')
if (project.hasProperty('virtualenvPath')) {
envPath = virtualenvPath
}
// copy virtualenv instead of symlink (when created)
envCopy = false
}
tasks.register('generateRequirements', PythonTask) {
inputs.files('requirements-build.in', 'requirements-sdk.in')
outputs.file('requirements.txt')
module = 'piptools'
command = 'compile requirements-build.in requirements-sdk.in --resolver=backtracking --unsafe-package py ' +
'--unsafe-package pywin32 -o requirements.txt'
if (project.hasProperty('upgrade')) {
command += ' --upgrade'
}
}
task pytest(type: PythonTask) {
module = 'pytest'
}
tasks.withType(PythonTask) {
if (rootProject.hasProperty("TestAccessToken")) {
environment 'VANTIQ_ACCESS_TOKEN', rootProject.findProperty("TestAccessToken") ?: "empty"
}
if (rootProject.hasProperty("TestVantiqServer")) {
environment 'VANTIQ_URL', rootProject.findProperty('TestVantiqServer')
}
if (rootProject.hasProperty('TestVantiqUsername')) {
environment 'VANTIQ_USERNAME', rootProject.findProperty('TestVantiqUsername') ?: 'empty'
}
if (rootProject.hasProperty('TestVantiqPassword')) {
environment 'VANTIQ_PASSWORD', rootProject.findProperty('TestVantiqPassword') ?: 'empty'
}
}
tasks.register('generateProjectCfg', Copy) {
doNotTrackState("Copying to root directory")
outputs.upToDateWhen { false }
into "${project.projectDir}"
from 'src/main/templates'
include '**/pyproject.toml.tmpl'
expand(vantiqSdkVersion: vantiqSdkVersion, vantiqSdkDeps: vantiqSdkDeps)
rename ~/(.*)\.tmpl/, '$1'
}
task build_distribution(type: PythonTask) {
module = 'build'
}
build_distribution.dependsOn generateProjectCfg
tasks.register('test')
task copyTestResources() {
doLast {
copy {
from 'src/test/resources/'
include 'logger.ini'
into "."
}
}
}
task pyclean(type: Delete) {
delete "${project.projectDir}/build"
delete "${project.projectDir}/dist"
// Also delete generated stuff
delete "${project.projectDir}/setup.cfg"
}
task publish(type: PythonTask) {
command = "upload --verbose -r ${pypi_repo} dist/*"
module = 'twine'
}
publish.mustRunAfter build_distribution
publish.dependsOn build_distribution
assemble.finalizedBy build_distribution
clean.dependsOn pyclean
build.finalizedBy test
test.finalizedBy pytest
pytest.dependsOn copyTestResources
// Make every other task run after the generateProjectCfg task. This way, they run first and the
// gradle dependency analyzer remains happy.
// matching() and all() are "live" so any tasks declared after this line will also depend on generate*
tasks.matching { !it.name.startsWith('generate')
&& it.name != 'pyclean'
&& it.name != 'clean' }.configureEach { task ->
task.mustRunAfter generateProjectCfg
}