whey.builder
¶
The actual wheel builder.
Classes:
|
Abstract base class for builders of Python distributions using metadata read from |
|
Builds source distributions using metadata read from |
|
Builds wheel binary distributions using metadata read from |
-
class
AbstractBuilder
(project_dir, config, build_dir=None, out_dir=None, *args, verbose=False, colour=None, **kwargs)[source]¶ Bases:
ABC
Abstract base class for builders of Python distributions using metadata read from
pyproject.toml
.- Parameters
project_dir (
PathPlus
) – The project to build the distribution for.build_dir (
Union
[str
,Path
,PathLike
,None
]) – The (temporary) build directory. Default<project_dir>/build/
.out_dir (
Union
[str
,Path
,PathLike
,None
]) – The output directory. Default<project_dir>/dist/
.verbose (
bool
) – Whether to enable verbose output. DefaultFalse
.colour (
Optional
[bool
]) – Whether to use coloured output. DefaultNone
.
Attributes:
The archive name, without the tag
The (temporary) build directory.
The directory containing the code in the build directory.
Whether to use coloured output.
Configuration parsed from
pyproject.toml
.Provides a default for the
build_dir
argument.Provides a default for the
out_dir
argument.The output directory.
The pyproject.toml directory
Whether to enable verbose output.
Methods:
build
()Build the distribution.
Subclasses may call this method to give their subclasses an opportunity to run custom code.
Clear the build directory of any residue from previous builds.
Copy additional files to the build directory, as specified in the
additional-files
key.Copy source files into the build directory.
Generate the content of the
METADATA
/PKG-INFO
file.Iterate over the files in the source directory.
parse_additional_files
(*entries)Copy additional files to the build directory, by parsing MANIFEST.in-style entries.
Parse the
project.authors
andmaintainers
fields into Author, Maintainer-Email etc.report_copied
(source, target)Report that a file has been copied into the build directory.
report_removed
(removed_file)Reports the removal of a file from the build directory.
report_written
(written_file)Report that a file has been written to the build directory.
write_license
(dest_dir[, dest_filename])Write the
LICENSE
file.write_metadata
(metadata_file, metadata_mapping)Write Core Metadata to the given file.
-
archive_name
¶ The archive name, without the tag
-
abstract
build
()[source]¶ Build the distribution.
- Return type
- Returns
The filename of the created archive.
-
build_dir
¶ The (temporary) build directory.
-
call_additional_hooks
()[source]¶ Subclasses may call this method to give their subclasses an opportunity to run custom code.
For example, the wheel builder calls this as the final step before adding files to the archive, giving an opportunity for subclasses of
WheelBuilder
to include additional steps without having to override the entirebuild_wheel()
method.
-
colour
¶ Whether to use coloured output.
-
copy_additional_files
()[source]¶ Copy additional files to the build directory, as specified in the
additional-files
key.
-
out_dir
¶ The output directory.
-
parse_additional_files
(*entries)[source]¶ Copy additional files to the build directory, by parsing MANIFEST.in-style entries.
- Parameters
*entries (
AdditionalFilesEntry
)
Parse the
project.authors
andmaintainers
fields into Author, Maintainer-Email etc.
-
report_copied
(source, target)[source]¶ Report that a file has been copied into the build directory.
The format is:
Copying {source} -> {target.relative_to(self.build_dir)}
-
report_removed
(removed_file)[source]¶ Reports the removal of a file from the build directory.
The format is:
Removing {removed_file.relative_to(self.build_dir)}
- Parameters
removed_file (
Path
)
-
report_written
(written_file)[source]¶ Report that a file has been written to the build directory.
The format is:
Writing {written_file.relative_to(self.build_dir)}
- Parameters
written_file (
Path
)
-
verbose
¶ Whether to enable verbose output.
-
write_metadata
(metadata_file, metadata_mapping)[source]¶ Write Core Metadata to the given file.
- Parameters
metadata_file (
PathPlus
)
-
class
SDistBuilder
(project_dir, config, build_dir=None, out_dir=None, *args, verbose=False, colour=None, **kwargs)[source]¶ Bases:
AbstractBuilder
Builds source distributions using metadata read from
pyproject.toml
.- Parameters
Methods:
build
()Build the source distribution.
Build the source distribution.
Create the sdist archive.
Write the
pyproject.toml
file.Write the
README.*
file.Attributes:
The directory containing the code in the build and project directories.
Provides a default for the
build_dir
argument.-
build
()¶ Build the source distribution.
- Return type
- Returns
The filename of the created archive.
-
build_sdist
()[source]¶ Build the source distribution.
- Return type
- Returns
The filename of the created archive.
-
property
code_directory
¶ The directory containing the code in the build and project directories.
- Return type
-
class
WheelBuilder
(project_dir, config, build_dir=None, out_dir=None, *args, verbose=False, colour=None, **kwargs)[source]¶ Bases:
AbstractBuilder
Builds wheel binary distributions using metadata read from
pyproject.toml
.- Parameters
Methods:
build
()Build the binary wheel distribution.
Build an editable wheel.
Build the binary wheel distribution.
Create the wheel archive.
Returns the parsed value of the
SOURCE_DATE_EPOCH
environment variable, orNone
if unset.Write the list of entry points to the wheel, as specified in
[project.scripts]
,[project.gui-scripts]
and[project.entry-points]
Write the metadata to the
WHEEL
file.Attributes:
Provides a default for the
build_dir
argument.The
*.dist-info
directory in the build directory.The value for the
Generator
field in*.dist-info/WHEEL
.The tag for the wheel.
-
build
()¶ Build the binary wheel distribution.
- Return type
- Returns
The filename of the created archive.
-
build_editable
()[source]¶ Build an editable wheel.
An “editable” wheel uses the wheel format not for distribution but as ephemeral communication between the build system and the front end. This avoids having the build backend install anything directly. This wheel must not be exposed to end users, nor cached, nor distributed.
You should use a different
build_dir
andout_dir
to those used for standard wheel builds.The default implementation of this method does not call
copy_source()
orcopy_additional_files()
.Attention
This method has the following additional requirement:
editables>=0.2
This can be installed as follows:
python -m pip install whey[editable]
- Return type
- Returns
The filename of the created archive.
-
build_wheel
()[source]¶ Build the binary wheel distribution.
- Return type
- Returns
The filename of the created archive.
-
create_editables_files
()[source]¶ Generate files with editables for use in a PEP 660 wheel.
Attention
This method has the following additional requirement:
editables>=0.2
This can be installed as follows:
python -m pip install whey[editable]
- Return type
- Returns
An iterator of additional runtime requirements which should be added to the wheel’s
METADATA
file.
-
create_wheel_archive
()[source]¶ Create the wheel archive.
- Return type
- Returns
The filename of the created archive.
-
static
get_source_epoch
()[source]¶ Returns the parsed value of the
SOURCE_DATE_EPOCH
environment variable, orNone
if unset.See https://reproducible-builds.org/specs/source-date-epoch/ for the specification.
- Raises
ValueError – if the value is in an invalid format.
- Return type