pulumi/pkg/codegen/python/pyproject.go

75 lines
3.9 KiB
Go
Raw Permalink Normal View History

package python
// The specification for the pyproject.toml file can be found here.
// https://packaging.python.org/en/latest/specifications/declaring-project-metadata/
type PyprojectSchema struct {
Python SDK generation with pyproject.toml stops generating setup.py (#13812) This change affects projects that use Python SDK generator with the following option enabled: "pyproject": {"enable": true"} Before this change, pyproject.toml was generated alongsie setup.py for such projects. After the change, setup.py is no longer generated, by pyproject.toml is extended to opt into setuptools backend and ensure that building this project embeds metadata files: py.typed # to support mypy and pyright users pulumi-plugin.json # to support Pulumi interop with the generated provider SDK The generated code can then be built with the `build` module to produce source and/or wheel distributions. See also: https://pypa-build.readthedocs.io/en/latest/ <!--- Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation. --> # Description <!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. --> Fixes #13709 - this takes Option 2 (drop setup.py, make pyproject.toml self-sufficient) See also: https://setuptools.pypa.io/en/latest/userguide/datafiles.html#package-data ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [ ] I have run `make lint` to verify my code passes the lint check - [ ] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [ ] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [ ] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2023-09-06 13:08:42 +00:00
Project *Project `toml:"project,omitempty" json:"project,omitempty"`
BuildSystem *BuildSystem `toml:"build-system,omitempty" json:"build-system,omitempty"`
Tool map[string]interface{} `toml:"tool,omitempty" json:"tool,omitempty"`
}
// Project is a view layer for a pyproject.toml file.
type Project struct {
Name *string `toml:"name,omitempty" json:"name,omitempty"`
Authors []Contact `toml:"authors,omitempty" json:"authors,omitempty"`
Classifiers []string `toml:"classifiers,omitempty" json:"classifiers,omitempty"`
Description *string `toml:"description,omitempty" json:"description,omitempty"`
Dependencies []string `toml:"dependencies,omitempty" json:"dependencies,omitempty"`
Dynamic []string `toml:"dynamic,omitempty" json:"dynamic,omitempty"`
EntryPoints Entrypoints `toml:"entry-points,omitempty" json:"entry-points,omitempty"`
GUIScripts Entrypoints `toml:"gui-scripts,omitempty" json:"gui-scripts,omitempty"`
// These are keywords used in package search.
Keywords []string `toml:"keywords,omitempty" json:"keywords,omitempty"`
License *License `toml:"license,omitempty" json:"license,omitempty"`
Maintainers []Contact `toml:"maintainers,omitempty" json:"maintainers,omitempty"`
//nolint:lll
OptionalDependencies OptionalDependencies `toml:"optional-dependencies,omitempty" json:"optional-dependencies,omitempty"`
// README is a path to a .md file or a .rst file
README *string `toml:"readme,omitempty" json:"readme,omitempty"`
// The version constraint e.g. ">=3.8"
RequiresPython *string `toml:"requires-python,omitempty" json:"requires-python,omitempty"`
Scripts Entrypoints `toml:"scripts,omitempty" json:"scripts,omitempty"`
// URLs provides core metadata about this project's website, a link
// to the repo, project documentation, and the project homepage.
URLs map[string]string `toml:"urls,omitempty" json:"urls,omitempty"`
// Version is the package version.
Version *string `toml:"version,omitempty" json:"version,omitempty"`
}
Python SDK generation with pyproject.toml stops generating setup.py (#13812) This change affects projects that use Python SDK generator with the following option enabled: "pyproject": {"enable": true"} Before this change, pyproject.toml was generated alongsie setup.py for such projects. After the change, setup.py is no longer generated, by pyproject.toml is extended to opt into setuptools backend and ensure that building this project embeds metadata files: py.typed # to support mypy and pyright users pulumi-plugin.json # to support Pulumi interop with the generated provider SDK The generated code can then be built with the `build` module to produce source and/or wheel distributions. See also: https://pypa-build.readthedocs.io/en/latest/ <!--- Thanks so much for your contribution! If this is your first time contributing, please ensure that you have read the [CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) documentation. --> # Description <!--- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. --> Fixes #13709 - this takes Option 2 (drop setup.py, make pyproject.toml self-sufficient) See also: https://setuptools.pypa.io/en/latest/userguide/datafiles.html#package-data ## Checklist - [ ] I have run `make tidy` to update any new dependencies - [ ] I have run `make lint` to verify my code passes the lint check - [ ] I have formatted my code using `gofumpt` <!--- Please provide details if the checkbox below is to be left unchecked. --> - [ ] I have added tests that prove my fix is effective or that my feature works <!--- User-facing changes require a CHANGELOG entry. --> - [ ] I have run `make changelog` and committed the `changelog/pending/<file>` documenting my change <!-- If the change(s) in this PR is a modification of an existing call to the Pulumi Cloud, then the service should honor older versions of the CLI where this change would not exist. You must then bump the API version in /pkg/backend/httpstate/client/api.go, as well as add it to the service. --> - [ ] Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version <!-- @Pulumi employees: If yes, you must submit corresponding changes in the service repo. -->
2023-09-06 13:08:42 +00:00
type BuildSystem struct {
Requires []string `toml:"requires,omitempty" json:"requires,omitempty"`
BuildBackend string `toml:"build-backend,omitempty" json:"build-backend,omitempty"`
}
// Contact references someone associated with the project, including
// their contact information. Contacts are used for both Authors and
// Maintainers, since both fields have the same schema and specification.
// It is often easier to specify both fields,
// but the precise rules for specifying either one or the other field
// can be found here:
// https://packaging.python.org/en/latest/specifications/declaring-project-metadata/#authors-maintainers
type Contact struct {
Name string `toml:"name,omitempty" json:"name,omitempty"`
Email string `toml:"email,omitempty" json:"email,omitempty"`
}
// An Entrypoint is an object reference for an executable Python script. These
// scripts can be applications, plugins, or build-time metadata. Since Pulumi
// distributes libraries, we largely don't use this field, though we include it
// for completeness and consistency with the spec.
type Entrypoints map[string]string
// The license instance must populate either
// file or text, but not both. File is a path
// to a license file, while text is either the
// name of the license, or the text of the license.
type License struct {
File string `toml:"file,omitempty" json:"file,omitempty"`
Text string `toml:"text,omitempty" json:"text,omitempty"`
}
// OptionalDependencies provides a map from "Extras" (parlance specific to Python)
// to their dependencies. Each value in the array becomes a required dependency
// if the Extra is enabled.
type OptionalDependencies map[string][]string