setuptools_betterproto
setuptools_betterproto ¤
A modern setuptools plugin to generate Python files from proto files using betterproto.
Classes¤
setuptools_betterproto.AddProtoFiles ¤
Bases: BaseProtoCommand
A command to add the proto files to the source distribution.
Source code in setuptools_betterproto/_command.py
Attributes¤
description
class-attribute
instance-attribute
¤
description: str = (
"compile protobuf files using betterproto"
)
Description of the command.
include_paths
instance-attribute
¤
include_paths: str
Comma-separated list of paths to include when compiling the protobuf files.
out_path
instance-attribute
¤
out_path: str
The path of the root directory where the Python files will be generated.
proto_path
instance-attribute
¤
proto_path: str
The path of the root directory containing the protobuf files.
user_options
class-attribute
instance-attribute
¤
user_options: list[tuple[str, str | None, str]] = [
(
"proto-path=",
None,
"path of the root directory containing the protobuf files",
),
(
"proto-glob=",
None,
"glob pattern to use to find the protobuf files",
),
(
"include-paths=",
None,
"comma-separated list of paths to include when compiling the protobuf files",
),
(
"out-dir=",
None,
"path of the root directory where the Python files will be generated",
),
]
Options of the command.
Functions¤
copy_with_directories ¤
Copy a file from src to dest, creating the destination's directory tree.
Any directories that do not exist in dest will be created.
PARAMETER | DESCRIPTION |
---|---|
src |
The full path of the source file.
TYPE:
|
dest |
The full path of the destination file.
TYPE:
|
Source code in setuptools_betterproto/_command.py
finalize_options ¤
Finalize options by converting them to a ProtobufConfig object.
Source code in setuptools_betterproto/_command.py
initialize_options ¤
Initialize options with default values.
Source code in setuptools_betterproto/_command.py
run ¤
Copy the proto files to the source distribution.
Source code in setuptools_betterproto/_command.py
setuptools_betterproto.CompileBetterproto ¤
Bases: BaseProtoCommand
A command to compile the protobuf files.
Source code in setuptools_betterproto/_command.py
Attributes¤
description
class-attribute
instance-attribute
¤
description: str = (
"compile protobuf files using betterproto"
)
Description of the command.
include_paths
instance-attribute
¤
include_paths: str
Comma-separated list of paths to include when compiling the protobuf files.
out_path
instance-attribute
¤
out_path: str
The path of the root directory where the Python files will be generated.
proto_path
instance-attribute
¤
proto_path: str
The path of the root directory containing the protobuf files.
user_options
class-attribute
instance-attribute
¤
user_options: list[tuple[str, str | None, str]] = [
(
"proto-path=",
None,
"path of the root directory containing the protobuf files",
),
(
"proto-glob=",
None,
"glob pattern to use to find the protobuf files",
),
(
"include-paths=",
None,
"comma-separated list of paths to include when compiling the protobuf files",
),
(
"out-dir=",
None,
"path of the root directory where the Python files will be generated",
),
]
Options of the command.
Functions¤
finalize_options ¤
Finalize options by converting them to a ProtobufConfig object.
Source code in setuptools_betterproto/_command.py
initialize_options ¤
Initialize options with default values.
Source code in setuptools_betterproto/_command.py
run ¤
Compile the protobuf files to Python.
Source code in setuptools_betterproto/_command.py
setuptools_betterproto.ProtobufConfig
dataclass
¤
A configuration for the protobuf files.
The configuration can be loaded from the pyproject.toml
file using the class
method from_pyproject_toml()
.
Source code in setuptools_betterproto/_config.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
|
Attributes¤
expanded_include_files
property
¤
The files in the include_paths
expanded according to the configured glob.
expanded_proto_files
property
¤
The files in the proto_path
expanded according to the configured glob.
include_paths
class-attribute
instance-attribute
¤
The paths to add to the include path when compiling the protobuf files.
out_path
class-attribute
instance-attribute
¤
out_path: str = '.'
The path of the root directory where the Python files will be generated.
proto_glob
class-attribute
instance-attribute
¤
proto_glob: str = '*.proto'
The glob pattern to use to find the protobuf files.
proto_path
class-attribute
instance-attribute
¤
proto_path: str = '.'
The path of the root directory containing the protobuf files.
Functions¤
from_pyproject_toml
classmethod
¤
Create a new configuration by loading the options from a pyproject.toml
file.
The options are read from the [tool.frequenz-repo-config.protobuf]
section of the pyproject.toml
file.
PARAMETER | DESCRIPTION |
---|---|
path |
The path to the
TYPE:
|
**defaults |
The default values for the options missing in the file. If a default is missing too, then the default in this class will be used.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
The configuration. |
Source code in setuptools_betterproto/_config.py
from_strings
classmethod
¤
Create a new configuration from plain strings.
PARAMETER | DESCRIPTION |
---|---|
proto_path |
The path of the root directory containing the protobuf files.
TYPE:
|
proto_glob |
The glob pattern to use to find the protobuf files.
TYPE:
|
include_paths |
The paths to add to the include path when compiling the protobuf files.
TYPE:
|
out_path |
The path of the root directory where the Python files will be generated.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
The configuration. |
Source code in setuptools_betterproto/_config.py
Functions¤
setuptools_betterproto.finalize_distribution_options ¤
Make some final adjustments to the distribution options.
We need to do some stuff early when setuptools runs to make sure all files are compiled and distributed appropriately.
- Replace the sdist command with a custom one that includes the proto files.
- Add the
compile_betterproto
command to the build sub-commands. - If the distribution is a binary distribution, build the proto files early.
PARAMETER | DESCRIPTION |
---|---|
dist |
The distribution object.
TYPE:
|