Skip to content

Commit 97e08e3

Browse files
authored
Fix broken pyproj version lookup (#654)
1 parent c1a73cf commit 97e08e3

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

cmd/run_python.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,30 @@ func (p *Preparer) BuildPythonProgram(ctx context.Context) (sdkbuild.Program, er
1919

2020
// Get version from pyproject.toml if not present
2121
version := p.config.Version
22+
versionFromPyProj := ""
2223
if version == "" {
2324
b, err := os.ReadFile(filepath.Join(p.rootDir, "pyproject.toml"))
2425
if err != nil {
2526
return nil, fmt.Errorf("failed reading pyproject.toml: %w", err)
2627
}
2728
for _, line := range strings.Split(string(b), "\n") {
2829
line = strings.TrimSpace(line)
29-
if strings.HasPrefix(line, "temporalio = ") {
30+
if strings.Contains(line, "temporalio") {
3031
version = line[strings.Index(line, `"`)+1 : strings.LastIndex(line, `"`)]
3132
break
3233
}
3334
}
3435
if version == "" {
3536
return nil, fmt.Errorf("version not found in pyproject.toml")
3637
}
38+
versionFromPyProj = version
3739
}
3840

3941
prog, err := sdkbuild.BuildPythonProgram(ctx, sdkbuild.BuildPythonProgramOptions{
40-
BaseDir: p.rootDir,
41-
DirName: p.config.DirName,
42-
Version: version,
42+
BaseDir: p.rootDir,
43+
DirName: p.config.DirName,
44+
Version: version,
45+
VersionFromPyProj: versionFromPyProj,
4346
})
4447
if err != nil {
4548
return nil, fmt.Errorf("failed preparing: %w", err)

sdkbuild/python.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ type BuildPythonProgramOptions struct {
1919
// a single wheel in the dist directory. Otherwise it is a specific version
2020
// (with leading "v" is trimmed if present).
2121
Version string
22+
// If specified, takes precedence over Version. Is a PEP 508 requirement string, like
23+
// `temporalio>=1.13.0,<2`.
24+
VersionFromPyProj string
2225
// If present, this directory is expected to exist beneath base dir. Otherwise
2326
// a temporary dir is created.
2427
DirName string
@@ -89,7 +92,9 @@ requires-python = "~=3.9"
8992
return nil, fmt.Errorf("failed writing pyproject.toml: %w", err)
9093
}
9194

92-
if strings.ContainsAny(options.Version, `/\`) {
95+
if options.VersionFromPyProj != "" {
96+
executeCommand("uv", "add", options.VersionFromPyProj)
97+
} else if strings.ContainsAny(options.Version, `/\`) {
9398
// It's a path; install from wheel
9499
wheel, err := getWheel(ctx, options.Version)
95100
if err != nil {

0 commit comments

Comments
 (0)