HappenLee commented on code in PR #57329: URL: https://github.com/apache/doris/pull/57329#discussion_r2470452019
########## be/src/udf/python/python_env.h: ########## @@ -0,0 +1,187 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include <filesystem> + +#include "common/status.h" + +namespace doris { + +namespace fs = std::filesystem; + +enum class PythonEnvType { CONDA, VENV }; + +struct PythonVersion { + std::string version; // e.g. "3.9" + std::string full_version; // e.g. "3.9.16" + std::string base_path; // e.g. "/root/anaconda3/envs/python3.9" + std::string executable_path; // e.g. "{base_path}/bin/python3" + + PythonVersion() = default; + + PythonVersion(std::string version, std::string base_path) + : version(std::move(version)), base_path(std::move(base_path)) {} + + explicit PythonVersion(std::string version, std::string full_version, std::string base_path) + : version(std::move(version)), + full_version(std::move(full_version)), + base_path(std::move(base_path)) {} + + explicit PythonVersion(std::string version, std::string full_version, std::string base_path, + std::string executable_path) + : version(std::move(version)), + full_version(std::move(full_version)), + base_path(std::move(base_path)), + executable_path(std::move(executable_path)) {} + + bool operator==(const PythonVersion& other) const { + return version == other.version && full_version == other.full_version; + } + + const std::string& get_version() const { return version; } + const std::string& get_base_path() const { return base_path; } + std::string get_executable_path() const { + return executable_path.empty() ? fmt::format("{}/bin/python3", base_path) : executable_path; Review Comment: better set executable_path to ` fmt::format("{}/bin/python3", base_path)` in constructor -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
