Skip to content

Commit

Permalink
Merge pull request #761 from cpanato/update-python-pipeline
Browse files Browse the repository at this point in the history
replace the fetch python url to more friendly URI
  • Loading branch information
rawlingsj authored Oct 17, 2023
2 parents 08f5260 + f6dbfcc commit 8438ed0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
17 changes: 14 additions & 3 deletions pkg/convert/python/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,18 @@ func (c *PythonContext) generatePipeline(ctx context.Context, pack Package, vers
return pipeline, errors.New("could not find any sdist package in available releases")
}

artifact256SHA, err := c.PackageIndex.Client.GetArtifactSHA256(ctx, release.URL)
releaseURL := release.URL
uri := strings.ReplaceAll(releaseURL, version, "${{package.version}}")
readme := fmt.Sprintf("CONFIRM WITH: curl -L %s | sha256sum", releaseURL)
if strings.Contains(release.URL, "https://files.pythonhosted.org") {
packageName := strings.TrimPrefix(pack.Info.Name, fmt.Sprintf("py%s", release.PythonVersion))
releaseURL = fmt.Sprintf("https://files.pythonhosted.org/packages/source/%c/%s/%s-%s.tar.gz", packageName[0], packageName, packageName, version)
readme = fmt.Sprintf("CONFIRM WITH: curl -L %s | sha256sum", releaseURL)

uri = strings.ReplaceAll(releaseURL, version, "${{package.version}}")
}

artifact256SHA, err := c.PackageIndex.Client.GetArtifactSHA256(ctx, releaseURL)
if err != nil {
c.Logger.Printf("[%s] SHA256 Generation FAILED. %v", pack.Info.Name, err)
c.Logger.Printf("[%s] Or try 'curl %s' to check out the API", pack.Info.Name, pack.Info.DownloadURL)
Expand All @@ -413,8 +424,8 @@ func (c *PythonContext) generatePipeline(ctx context.Context, pack Package, vers
fetch := config.Pipeline{
Uses: "fetch",
With: map[string]string{
"uri": strings.ReplaceAll(release.URL, version, "${{package.version}}"),
"README": fmt.Sprintf("CONFIRM WITH: curl -L %s | sha256sum", release.URL),
"uri": uri,
"README": readme,
"expected-sha256": artifact256SHA,
},
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/convert/python/python_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,11 @@ func TestGenerateManifest(t *testing.T) {
assert.NotEmpty(t, release)
assert.Equal(t, "https://files.pythonhosted.org/packages/8f/34/d4bcefeabfb8e4b46157e84ea55c3ecc7399d5f9a3454728e1d0d5f9cb83/botocore-"+pythonctx.PackageVersion+".tar.gz", release.URL)

tempURI := fmt.Sprintf("https://files.pythonhosted.org/packages/source/%c/%s/%s-%s.tar.gz", pythonctx.PackageName[0], pythonctx.PackageName, pythonctx.PackageName, pythonctx.PackageVersion)
assert.Equal(t, got.Pipeline[0].With, map[string]string{
"README": fmt.Sprintf("CONFIRM WITH: curl -L %s | sha256sum", release.URL),
"README": fmt.Sprintf("CONFIRM WITH: curl -L %s | sha256sum", tempURI),
"expected-sha256": "2bee6ed037590ef1e4884d944486232871513915f12a8590c63e3bb6046479bf",
"uri": strings.ReplaceAll(release.URL, pythonctx.PackageVersion, "${{package.version}}"),
"uri": strings.ReplaceAll(tempURI, pythonctx.PackageVersion, "${{package.version}}"),
})

// Check Pipeline - runs
Expand Down

0 comments on commit 8438ed0

Please sign in to comment.