Skip to content

Added flexpack build info support for poetry#140

Merged
agrasth merged 1 commit intojfrog:mainfrom
agrasth:flexpack
Sep 7, 2025
Merged

Added flexpack build info support for poetry#140
agrasth merged 1 commit intojfrog:mainfrom
agrasth:flexpack

Conversation

@agrasth
Copy link
Copy Markdown
Collaborator

@agrasth agrasth commented Aug 28, 2025

  • All tests passed. If this feature is not already covered by the tests, I added new tests.
  • All static analysis checks passed.
  • Appropriate label is added to auto generate release notes.
  • I used gofmt for formatting the code before submitting the pull request.
  • PR description is clear and concise, and it includes the proposed solution/fix.

// Create Poetry FlexPack instance
poetryFlex, err := flexpack.NewPoetryFlexPack(config)
if err != nil {
log.Warn("Failed to create Poetry FlexPack, falling back to standard method: " + err.Error())
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this warning message? the error can be returned and even the else statement can be removed since we are returning in if block

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok will return error in this case

err := pc.install(buildConfiguration, pythonBuildInfo)

// Get build name and number
buildName, err := buildConfiguration.GetBuildName()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not on priority: we need to check if we really need to read buildName and number from project.yaml which is happening in buildConfiguration.GetBuildName()

// Collect build info using FlexPack
flexBuildInfo, err := poetryFlex.CollectBuildInfo(buildName, buildNumber)
if err != nil {
log.Warn("Failed to collect build info with FlexPack, falling back to standard method: " + err.Error())
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should return error since we failed collecting build info instead of warning

Comment on lines +139 to +144
err = pc.saveFlexPackBuildInfo(flexBuildInfo)
if err != nil {
log.Warn("Failed to save FlexPack build info: " + err.Error())
} else {
log.Info("Successfully saved FlexPack build info with dependencies")
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
err = pc.saveFlexPackBuildInfo(flexBuildInfo)
if err != nil {
log.Warn("Failed to save FlexPack build info: " + err.Error())
} else {
log.Info("Successfully saved FlexPack build info with dependencies")
}
return pc.saveFlexPackBuildInfo(flexBuildInfo)

// Create FlexPack Poetry configuration
config := flexpack.PoetryConfig{
WorkingDirectory: workingDir,
IncludeDevDependencies: false, // Match standard behavior
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default should be false right do we need this?

Suggested change
IncludeDevDependencies: false, // Match standard behavior

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, will update this

Comment on lines +179 to +184
err = bld.SaveBuildInfo(buildInfo)
if err != nil {
return fmt.Errorf("failed to save build info: %w", err)
}

return nil
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
err = bld.SaveBuildInfo(buildInfo)
if err != nil {
return fmt.Errorf("failed to save build info: %w", err)
}
return nil
return bld.SaveBuildInfo(buildInfo)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


// getProjectNameFromPyproject extracts project name from pyproject.toml
func (pc *PoetryCommand) getProjectNameFromPyproject(workingDir string) (string, error) {
pyprojectPath := filepath.Join(workingDir, "pyproject.toml")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a constant for "pyproject.toml".

// collectPublishedArtifacts collects information about artifacts that were published
func (pc *PoetryCommand) collectPublishedArtifacts(buildConfiguration *buildUtils.BuildConfiguration, pythonBuildInfo *build.Build, workingDir string) error {
// Look for built artifacts in dist/ directory
distDir := filepath.Join(workingDir, "dist")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can poetry write published artifacts to a different directory instead of default?

}

// findDistArtifacts finds and creates artifact entries for files in dist directory
func (pc *PoetryCommand) findDistArtifacts(distDir string) ([]entities.Artifact, error) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cant this be read from pyproject.toml?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I can add a method for this


filename := entry.Name()
// Only include wheel and tar.gz files
if !strings.HasSuffix(filename, ".whl") && !strings.HasSuffix(filename, ".tar.gz") {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to improve readability

Suggested change
if !strings.HasSuffix(filename, ".whl") && !strings.HasSuffix(filename, ".tar.gz") {
if !(strings.HasSuffix(filename, ".whl") || !strings.HasSuffix(filename, ".tar.gz")) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can also reuse the function getArtifactType here

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, great point, I will update this to use getArtifactType.

@agrasth agrasth merged commit fb4679f into jfrog:main Sep 7, 2025
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature Automatically generated release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants