From b97ac3d805d11b130f3ec1f0373b319e7854df4d Mon Sep 17 00:00:00 2001 From: Christopher Fenner Date: Thu, 11 Sep 2025 11:33:20 +0200 Subject: [PATCH] add toml flag --- cmd/pythonBuild.go | 2 +- cmd/pythonBuild_generated.go | 11 +++++++++++ resources/metadata/pythonBuild.yaml | 8 ++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cmd/pythonBuild.go b/cmd/pythonBuild.go index b964966dc..b43434eb5 100644 --- a/cmd/pythonBuild.go +++ b/cmd/pythonBuild.go @@ -65,7 +65,7 @@ func runPythonBuild(config *pythonBuildOptions, telemetryData *telemetry.CustomD //TODO: use a defer func to cleanup the virtual environment // FEATURE FLAG (com_sap_piper_featureFlag_pythonToml) to switch to new implementation of python build step - if feature.IsFeatureEnabled("pythonToml") { + if config.UseTomlFile || feature.IsFeatureEnabled("pythonToml") { // check project descriptor buildDescriptorFilePath, err := searchDescriptor([]string{"pyproject.toml", "setup.py"}, utils.FileExists) if err != nil { diff --git a/cmd/pythonBuild_generated.go b/cmd/pythonBuild_generated.go index 292d2454f..187f4a618 100644 --- a/cmd/pythonBuild_generated.go +++ b/cmd/pythonBuild_generated.go @@ -29,6 +29,7 @@ type pythonBuildOptions struct { BuildSettingsInfo string `json:"buildSettingsInfo,omitempty"` VirutalEnvironmentName string `json:"virutalEnvironmentName,omitempty"` RequirementsFilePath string `json:"requirementsFilePath,omitempty"` + UseTomlFile bool `json:"useTomlFile,omitempty"` } type pythonBuildCommonPipelineEnvironment struct { @@ -203,6 +204,7 @@ func addPythonBuildFlags(cmd *cobra.Command, stepConfig *pythonBuildOptions) { cmd.Flags().StringVar(&stepConfig.BuildSettingsInfo, "buildSettingsInfo", os.Getenv("PIPER_buildSettingsInfo"), "build settings info is typically filled by the step automatically to create information about the build settings that were used during the maven build . This information is typically used for compliance related processes.") cmd.Flags().StringVar(&stepConfig.VirutalEnvironmentName, "virutalEnvironmentName", `piperBuild-env`, "name of the virtual environment that will be used for the build") cmd.Flags().StringVar(&stepConfig.RequirementsFilePath, "requirementsFilePath", `requirements.txt`, "file path to the requirements.txt file needed for the sbom cycloneDx file creation.") + cmd.Flags().BoolVar(&stepConfig.UseTomlFile, "useTomlFile", false, "Determines if a pyproject.toml file should be used for dependency management.") } @@ -327,6 +329,15 @@ func pythonBuildMetadata() config.StepData { Aliases: []config.Alias{}, Default: `requirements.txt`, }, + { + Name: "useTomlFile", + ResourceRef: []config.ResourceReference{}, + Scope: []string{"STEPS", "STAGES", "PARAMETERS"}, + Type: "bool", + Mandatory: false, + Aliases: []config.Alias{}, + Default: false, + }, }, }, Containers: []config.Container{ diff --git a/resources/metadata/pythonBuild.yaml b/resources/metadata/pythonBuild.yaml index 679128e0f..9ff77a5d4 100644 --- a/resources/metadata/pythonBuild.yaml +++ b/resources/metadata/pythonBuild.yaml @@ -105,6 +105,14 @@ spec: - STAGES - PARAMETERS default: requirements.txt + - name: useTomlFile + type: bool + default: false + description: Determines if a pyproject.toml file should be used for dependency management. + scope: + - STEPS + - STAGES + - PARAMETERS outputs: resources: - name: commonPipelineEnvironment