@@ -32,7 +32,102 @@ __wrap__() {
32
32
fi
33
33
}
34
34
35
- pixi-enable-autocomplete () {
35
+ pipx-installed () {
36
+ if command -v " $PIXI_BIN /pipx" & > /dev/null; then
37
+ return 0
38
+ else
39
+ return 1
40
+ fi
41
+ }
42
+
43
+ pipx-global-install () {
44
+ if pixi global install pipx; then
45
+ return 0
46
+ else
47
+ return 1
48
+ fi
49
+ }
50
+
51
+ keyring-installed () {
52
+ if command -v " $PIPX_BIN /keyring" & > /dev/null; then
53
+ return 0
54
+ else
55
+ return 1
56
+ fi
57
+ }
58
+
59
+ pipx-install-keyring () {
60
+ if pipx install keyring; then
61
+ return 0
62
+ else
63
+ return 1
64
+ fi
65
+ }
66
+
67
+ pipx-google-artifact-registry-injected () {
68
+ local backends=" "
69
+ backends=$( keyring --list-backends)
70
+ if echo " $backends " | grep -q " keyrings.gauth.GooglePythonAuth" ; then
71
+ return 0
72
+ else
73
+ return 1
74
+ fi
75
+ }
76
+
77
+ pipx-inject-google-artifact-registry () {
78
+ if pipx inject keyring \
79
+ keyrings.google-artifactregistry-auth \
80
+ --index-url https://pypi.org/simple \
81
+ --force; then
82
+ return 0
83
+ else
84
+ return 1
85
+ fi
86
+ }
87
+
88
+ gcloud-installed () {
89
+ if command -v " $PIXI_BIN /gcloud" & > /dev/null; then
90
+ return 0
91
+ else
92
+ return 1
93
+ fi
94
+ }
95
+
96
+ gcloud-global-install () {
97
+ if pixi global install google-cloud-sdk; then
98
+ return 0
99
+ else
100
+ return 1
101
+ fi
102
+ }
103
+
104
+ gcloud-authenticated () {
105
+ if [ " ${GITHUB_CI:- } " = " true" ]; then
106
+ return 0
107
+ elif gcloud auth application-default print-access-token > /dev/null; then
108
+ return 0
109
+ else
110
+ return 1
111
+ fi
112
+ }
113
+
114
+ gcloud-init () {
115
+ if ! gcloud init; then
116
+ return 1
117
+ else
118
+ return 0
119
+ fi
120
+ }
121
+
122
+ gcloud-auth-adc () {
123
+ if ! gcloud auth application-default login; then
124
+ returny 1
125
+ else
126
+ return 0
127
+ fi
128
+ }
129
+
130
+ pixi-enable-autocomplete () {
36
131
local shell=$1
37
132
local config=$2
38
133
@@ -134,14 +229,68 @@ __wrap__() {
134
229
135
230
# setup google artifact registry access
136
231
echo " checking google artifact registry..."
137
- pushd scripts & > /dev/null
138
- ./check-auth.sh
139
- popd & > /dev/null
140
-
141
- # if [ "${GITHUB_CI:-}" = "true" ]; then
142
- # rm "$PIXI_BIN/pixi"
143
- # return 0
144
- # fi
232
+ # install pipx
233
+ echo " checking pipx..."
234
+ if ! pipx-installed; then
235
+ echo " installing pipx..."
236
+ if ! pipx-global-install; then
237
+ echo " couldn't install pipx"
238
+ exit 1
239
+ fi
240
+ fi
241
+ pipx ensurepath & > /dev/null
242
+ v=$( pipx --version)
243
+ p=$( which pipx)
244
+ printf " ✓ pipx %s installed (%s)\n\n" " $v " " $p "
245
+
246
+ # install keyring
247
+ echo " checking keyring..."
248
+ if ! keyring-installed; then
249
+ echo " installing keyring..."
250
+ if ! pipx-install-keyring; then
251
+ echo " pipx couldn't install keyring"
252
+ exit 1
253
+ fi
254
+ fi
255
+ p=$( which keyring)
256
+ printf " ✓ keyring installed (%s)\n\n" " $p "
257
+
258
+ # inject gcloud auth backend
259
+ echo " checking google-artifact-registry-auth keyring backend..."
260
+ if ! pipx-google-artifact-registry-injected; then
261
+ echo " injecting google-artifact-registry-auth backend..."
262
+ if ! pipx-inject-google-artifact-registry; then
263
+ echo " pipx couldn't inject google artifact registry keyring"
264
+ exit 1
265
+ fi
266
+ fi
267
+ printf " ✓ google artifact registry backend injected\n\n"
268
+
269
+ # install gcloud
270
+ echo " checking gcloud..."
271
+ if ! gcloud-installed; then
272
+ echo " installing gcloud..."
273
+ if ! gcloud-global-install; then
274
+ echo " gcloud install failed"
275
+ exit 1
276
+ fi
277
+ fi
278
+ v=$( gcloud --version)
279
+ p=$( which gcloud)
280
+ printf " ✓ gcloud %s installed (%s)\n\n" " $v " " $p "
281
+
282
+ # check gcloud auth
283
+ echo " checking gcloud auth..."
284
+ if ! gcloud-authenticated; then
285
+ echo " authenticating gcloud..."
286
+ if ! gcloud-auth-adc; then
287
+ echo " gcloud not authenticated"
288
+ exit 1
289
+ fi
290
+ fi
291
+ printf " ✓ gcloud authenticated\n\n"
292
+
293
+ printf " → you are authenticated to google artifact registry \o/\n"
145
294
146
295
# install environment
147
296
echo " installing b3d project dependencies..."
0 commit comments