Caution
This API is not finalised, and may change in a patch version.
installer.destinations
¶
Handles all file writing and post-installation processing.
-
class
installer.destinations.
WheelDestination
¶ Represents the location for wheel installation.
Subclasses are expected to handle script generation and rewriting of the RECORD file after installation.
-
write_script
(name, module, attr, section)¶ Write a script in the correct location to invoke given entry point.
The stream should be closed by the caller.
Example usage/behaviour:
>>> dest.write_script("pip", "pip._internal.cli", "main", "console")
- Parameters
name (Text) –
module (Text) –
attr (Text) –
section (ScriptSection) –
- Return type
-
write_file
(scheme, path, stream)¶ Write a file to correct
path
within thescheme
.The stream would be closed by the caller, after this call.
Example usage/behaviour:
>>> with open("__init__.py") as stream: ... dest.write_file("purelib", "pkg/__init__.py", stream)
- Parameters
scheme (Scheme) –
path (FSPath) –
stream (BinaryIO) –
- Return type
-
finalize_installation
(scheme, record_file_path, records)¶ Finalize installation, after all the files are written.
This method is required to (re)write the RECORD file such that it includes all given
records
as well as any additional generated content (eg: scripts).Example usage/behaviour:
>>> dest.finalize_installation("purelib")
- Parameters
scheme (Scheme) –
record_file_path (FSPath) –
records (Iterable[RecordEntry]) –
- Return type
-
-
class
installer.destinations.
SchemeDictionaryDestination
¶ Destination, based on a mapping of {scheme: file-system-path}.
-
__init__
(scheme_dict, interpreter, script_kind, hash_algorithm='sha256')¶ Construct a
SchemeDictionaryDestination
object.- Parameters
scheme_dict (Dict[str, str]) – a mapping of {scheme: file-system-path}
interpreter (str) – the interpreter to use for generating scripts
script_kind (LauncherKind) – the “kind” of launcher script to use
hash_algorithm (str) – the hashing algorithm to use, which is a member of
hashlib.algorithms_available
(ideally fromhashlib.algorithms_guaranteed
).
- Return type
-
write_file
(scheme, path, stream)¶ Write a file to correct
path
within thescheme
.- Parameters
scheme (Scheme) –
path (FSPath) –
stream (BinaryIO) –
- Return type
-
write_script
(name, module, attr, section)¶ Write a script in the correct location to invoke given entry point.
- Parameters
name (Text) –
module (Text) –
attr (Text) –
section (ScriptSection) –
- Return type
-
finalize_installation
(scheme, record_file_path, records)¶ Finalize installation, after all the files are written.
This will write the RECORD file, based on the provided
record_file_path
.- Parameters
scheme (Scheme) –
record_file_path (FSPath) –
records (Iterable[RecordEntry]) –
- Return type
-