Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(poetry): Improve the definition file paths #7624

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
project:
id: "Poetry::poetry-from-poetry:<REPLACE_REVISION>"
definition_file_path: "plugins/package-managers/python/src/funTest/assets/projects/synthetic/poetry/requirements-from-poetry.txt"
definition_file_path: "plugins/package-managers/python/src/funTest/assets/projects/synthetic/poetry/poetry.lock"
declared_licenses: []
declared_licenses_processed: {}
vcs:
Expand Down
8 changes: 8 additions & 0 deletions plugins/package-managers/python/src/main/kotlin/Poetry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import org.apache.logging.log4j.kotlin.Logging

import org.ossreviewtoolkit.analyzer.AbstractPackageManagerFactory
import org.ossreviewtoolkit.analyzer.PackageManager
import org.ossreviewtoolkit.downloader.VersionControlSystem
import org.ossreviewtoolkit.model.ProjectAnalyzerResult
import org.ossreviewtoolkit.model.config.AnalyzerConfiguration
import org.ossreviewtoolkit.model.config.RepositoryConfiguration
Expand Down Expand Up @@ -72,6 +73,13 @@ class Poetry(

return Pip(managerName, analysisRoot, analyzerConfig, repoConfig)
.resolveDependencies(requirementsFile, labels)
.map { projectAnalyzerResult ->
projectAnalyzerResult.copy(
project = projectAnalyzerResult.project.copy(
definitionFilePath = VersionControlSystem.getPathInfo(definitionFile).path
Copy link
Member

Choose a reason for hiding this comment

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

I propose definitionFile.relativeTo(analysisRoot) instead to avoid adding more code that relies on the project to be version controlled.

Copy link
Member Author

Choose a reason for hiding this comment

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

This does not introduce the requirement, because code which computes the value for definitionFilePath already relies on that prior to this change. Furthermore, relativeTo(analysisRoot) seems wrong because the definition file path is not meant to be relative to the analysis root, but the repository root.

Copy link
Member

Choose a reason for hiding this comment

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

This does not introduce the requirement

And I didn't say that. I was talking about adding more code with that requirement.

Furthermore, relativeTo(analysisRoot) seems wrong because the definition file path is not meant to be relative to the analysis root, but the repository root.

Indeed Project.definitionFilePath is documented like that 😞 IMO that's a mistake already, and it will make our lives harder in order to address #2896.

Anyway, we already have a bunch of code like that, so we can bulk-address this later, I guess.

Copy link
Member Author

Choose a reason for hiding this comment

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

And I didn't say that. I was talking about adding more code with that requirement.

I know, I didn't mean to say that you said that. I only intended to clarify that both, the old and the new code path depend on that same logic.

)
)
}
.also { requirementsFile.delete() }
}
}