Ability to require minimum Python version (#8296)

Co-authored-by: Komal <komalsali@gmail.com>
Co-authored-by: Justin Van Patten <jvp@justinvp.com>
This commit is contained in:
Ben Schiborr 2021-10-26 14:33:21 -07:00 committed by GitHub
parent 1c0a7e4907
commit df61004e3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View file

@ -1909,7 +1909,7 @@ func genPulumiPluginFile(pkg *schema.Package) ([]byte, error) {
// genPackageMetadata generates all the non-code metadata required by a Pulumi package.
func genPackageMetadata(
tool string, pkg *schema.Package, pyPkgName string, emitPulumiPluginFile bool, requires map[string]string) (string, error) {
tool string, pkg *schema.Package, pyPkgName string, emitPulumiPluginFile bool, requires map[string]string, pythonRequires string) (string, error) {
w := &bytes.Buffer{}
(&modContext{tool: tool}).genHeader(w, false /*needsSDK*/, nil)
@ -1960,6 +1960,9 @@ func genPackageMetadata(
// Finally, the actual setup part.
fmt.Fprintf(w, "setup(name='%s',\n", pyPkgName)
if pythonRequires != "" {
fmt.Fprintf(w, " python_requires='%s',\n", pythonRequires)
}
fmt.Fprintf(w, " version=VERSION,\n")
if pkg.Description != "" {
fmt.Fprintf(w, " description=%q,\n", sanitizePackageDescription(pkg.Description))
@ -2783,7 +2786,7 @@ func GeneratePackage(tool string, pkg *schema.Package, extraFiles map[string][]b
}
// Finally emit the package metadata (setup.py).
setup, err := genPackageMetadata(tool, pkg, pkgName, info.EmitPulumiPluginFile, info.Requires)
setup, err := genPackageMetadata(tool, pkg, pkgName, info.EmitPulumiPluginFile, info.Requires, info.PythonRequires)
if err != nil {
return nil, err
}

View file

@ -34,8 +34,10 @@ type PropertyInfo struct {
// PackageInfo tracks Python-specific information associated with a package.
type PackageInfo struct {
// PackageName is an override for the name of the generated python package.
PackageName string `json:"packageName,omitempty"`
Requires map[string]string `json:"requires,omitempty"`
PackageName string `json:"packageName,omitempty"`
// PythonRequires determines the Python versions that the generated provider supports
PythonRequires string `json:"pythonRequires,omitempty"`
Requires map[string]string `json:"requires,omitempty"`
// Readme contains the text for the package's README.md files.
Readme string `json:"readme,omitempty"`
// Optional overrides for Pulumi module names