FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
dagger/toolchains/python-sdk-dev/util.go at main · syncopatedNote/dagger · GitHub
syncopatedNote
dagger
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
dagger
/
toolchains
/
python-sdk-dev
/
util.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
67 lines (59 loc) · 1.91 KB
Breadcrumbs
dagger
/
toolchains
/
python-sdk-dev
/
util.go
Copy path
File metadata and controls
67 lines (59 loc) · 1.91 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package
main
import
(
"fmt"
"strings"
"dagger/python-sdk-dev/internal/dagger"
)
// Return the changes between two directory, excluding the specified path patterns from the comparison
func
changes
(
before
,
after
*
dagger.
Directory
,
exclude
[]
string
)
*
dagger.
Changeset
{
if
exclude
==
nil
{
return
after
.
Changes
(
before
)
}
return
after
.
// 1. Remove matching files from after
Filter
(dagger.
DirectoryFilterOpts
{
Exclude
:
exclude
}).
// 2. Copy matching files from before
WithDirectory
(
""
,
before
.
Filter
(dagger.
DirectoryFilterOpts
{
Include
:
exclude
})).
Changes
(
before
)
}
// Set up the cache directory for multiple tools.
func
toolsCache
(
args
...
string
) dagger.
WithContainerFunc
{
return
func
(
ctr
*
dagger.
Container
)
*
dagger.
Container
{
for
_
,
tool
:=
range
args
{
ctr
=
ctr
.
WithMountedCache
(
fmt
.
Sprintf
(
"/root/.cache/%s"
,
tool
),
dag
.
CacheVolume
(
fmt
.
Sprintf
(
"modpythondev-%s"
,
tool
))).
WithEnvVariable
(
fmt
.
Sprintf
(
"%s_CACHE_DIR"
,
strings
.
ToUpper
(
tool
)),
fmt
.
Sprintf
(
"/root/.cache/%s"
,
tool
))
}
return
ctr
}
}
// Add directory as a mount on a container, under `/work`
func
mountedWorkdir
(
src
*
dagger.
Directory
) dagger.
WithContainerFunc
{
return
func
(
ctr
*
dagger.
Container
)
*
dagger.
Container
{
return
ctr
.
WithMountedDirectory
(
"/work"
,
src
).
WithWorkdir
(
"/work"
)
}
}
// Add the uv tool to the container.
func
uvTool
(
workspace
*
dagger.
Directory
) dagger.
WithContainerFunc
{
return
func
(
ctr
*
dagger.
Container
)
*
dagger.
Container
{
return
ctr
.
WithDirectory
(
"/usr/local/bin"
,
workspace
.
Directory
(
"sdk/python/runtime/images/uv"
).
DockerBuild
().
Rootfs
(),
dagger.
ContainerWithDirectoryOpts
{
Include
: []
string
{
"uv*"
}}).
WithEnvVariable
(
"UV_LINK_MODE"
,
"copy"
).
WithEnvVariable
(
"UV_PROJECT_ENVIRONMENT"
,
"/opt/venv"
)
}
}
func
uv
(
args
...
string
) []
string
{
return
append
([]
string
{
"uv"
},
args
...
)
}
func
uvRun
(
args
...
string
) []
string
{
return
append
(
uv
(
"run"
),
args
...
)
}
Back
|
FazBrowse Home
|
New Git URL