ape-pm
- class ape_pm.compiler.InterfaceCompiler(*, compiler_settings: dict = {})
A compiler plugin for interface JSONs (ABIs). Also, this compiler can “compile” already-compiled
ContractType
JSON files.- compile(contract_filepaths: Iterable[Path], project: ProjectManager | None, settings: dict | None = None) Iterator[ContractType]
Compile the given source files. All compiler plugins must implement this function.
- Parameters:
contract_filepaths (Iterable[pathlib.Path]) – A list of source file paths to compile.
project (Optional[
ProjectManager
]) – Optionally provide the project containing the base paths and full source set. Defaults to the local project. Dependencies will change this value to their respective projects.settings (Optional[dict]) – Adhoc compiler settings.
- Returns:
list[
ContractType
]
- compile_code(code: str, project: ProjectManager | None = None, **kwargs) ContractType
Compile a program.
- Parameters:
code (str) – The code to compile.
project (Optional[
ProjectManager
]) – Optionally provide the project containing the base paths and full source set. Defaults to the local project. Dependencies will change this value to their respective projects.settings (Optional[Dict]) – Adhoc compiler settings.
**kwargs – Additional overrides for the
ethpm_types.ContractType
model.
- Returns:
A compiled contract artifact.
- Return type:
ContractType
- enrich_error(err: ContractLogicError) ContractLogicError
Enrich a contract logic error using compiler information, such as known PC locations for compiler runtime errors.
- Parameters:
err (
ContractLogicError
) – The exception to enrich.- Returns:
The enriched exception.
- Return type:
- get_versions(all_paths: Iterable[Path]) set[str]
Retrieve the set of available compiler versions for this plugin to compile
all_paths
.- Parameters:
all_paths (Iterable[pathlib.Path]) – The list of paths.
- Returns:
A set of available compiler versions.
- Return type:
set[str]
- property name: str
The name of the compiler.
- class ape_pm.dependency.GithubDependency(*, name: str, config_override: dict = <factory>, github: str, ref: str | None = None, version: str | None = None)
A dependency from Github. Use the
github
key in yourdependencies:
section of yourape-config.yaml
file to declare a dependency from GitHub.Config example:
dependencies: - name: OpenZeppelin github: OpenZeppelin/openzeppelin-contracts version: 4.4.0
- fetch(destination: Path)
Fetch the dependency. E.g. for GitHub dependency, download the files to the destination.
- Parameters:
destination (Path) – The destination for the dependency files.
- github: str
The Github repo ID e.g. the organization name followed by the repo name, such as
dapphub/erc20
.
- property package_id: str
The full name of the package, used for storage. Example:
OpenZeppelin/openzeppelin-contracts
.
- ref: str | None
The branch or tag to use. When using this field instead of the ‘release’ field, the repository gets cloned instead of downloaded via the official GitHub release API.
NOTE: Will be ignored if given a ‘release’.
- property uri: str
The URI for the package.
- version: str | None
The release version to use. When using this field instead of the ‘ref’ field, the GitHub release API is used to fetch instead of cloning.
NOTE: Will be ignored if given a ‘ref’.
- property version_id: str
The ID to use as the sub-directory in the download cache. Most often, this is either a version number or a branch name.
- class ape_pm.dependency.LocalDependency(*, name: str, config_override: dict = <factory>, local: ~pathlib.Path, version: str | None = None)
A dependency located on the local machine.
- fetch(destination: Path)
Fetch the dependency. E.g. for GitHub dependency, download the files to the destination.
- Parameters:
destination (Path) – The destination for the dependency files.
- local: Path
The root path (and API defining key) to the dependency files.
- property package_id: str
The full name of the package, used for storage. Example:
OpenZeppelin/openzeppelin-contracts
.
- property uri: str
The URI for the package.
- version: str | None
Specified version.
- property version_id: str
The ID to use as the sub-directory in the download cache. Most often, this is either a version number or a branch name.
- class ape_pm.dependency.NpmDependency(*, name: str, config_override: dict = <factory>, npm: ~pathlib.Path, version: str | None = None)
A dependency from the Node Package Manager (NPM).
Config example:
dependencies: - name: safe-singleton-factory npm: "@gnosis.pm/safe-singleton-factory" version: 1.0.14
- fetch(destination: Path)
Fetch the dependency. E.g. for GitHub dependency, download the files to the destination.
- Parameters:
destination (Path) – The destination for the dependency files.
- npm: Path
The NPM repo ID e.g. the organization name followed by the repo name, such as
"@gnosis.pm/safe-singleton-factory"
. Note: Resolves to a ‘path’ after serialization. The package must already be installed!
- property package_id: str
The full name of the package, used for storage. Example:
OpenZeppelin/openzeppelin-contracts
.
- property uri: str
The URI for the package.
- version: str | None
Specify the version, if not wanting to use discovered version from install.
- property version_from_installed_package_json: str | None
The version from package.json in the installed package. Requires having run npm install.
- property version_from_project_package_json: str | None
The version from your project’s package.json, if exists.
- property version_id: str
The ID to use as the sub-directory in the download cache. Most often, this is either a version number or a branch name.
- class ape_pm.dependency.PythonDependency(*, name: str, config_override: dict = <factory>, site_package: str | None = None, pypi: str | None = None, version: str | None = None)
A dependency installed from Python tooling, such as pip.
- fetch(destination: Path)
Fetch the dependency. E.g. for GitHub dependency, download the files to the destination.
- Parameters:
destination (Path) – The destination for the dependency files.
- property package_id: str
The full name of the package, used for storage. Example:
OpenZeppelin/openzeppelin-contracts
.
- pypi: str | None
The
pypi
reference, such as"snekmate"
. Cannot use withpython:
. When set, downloads the dependency frompypi
using HTTP directly (notpip
).
- site_package: str | None
The Python site-package name, such as
"snekmate"
. Cannot use withpypi:
. Requires the dependency to have been installed either viapip
or something alike.
- property uri: str
The URI for the package.
- version: str | None
Optionally specify the version expected to be installed.
- property version_id: str
The ID to use as the sub-directory in the download cache. Most often, this is either a version number or a branch name.
- class ape_pm.project.BrownieProject(*, path: Path)
Allows traditional Brownie projects to work with Ape. This class implements the necessary methods in order to detect config settings in a Brownie project and treat it like an Ape project.
- extract_config(**overrides) ApeConfig
Extra configuration from the project so that Ape understands the dependencies and how to compile everything.
- Parameters:
**overrides – Config overrides.
- Returns:
ApeConfig
- property is_valid: bool
Return
True
when detecting a project of this type.
- class ape_pm.project.FoundryProject(*, path: Path)
Helps Ape read configurations from foundry projects and lessens the need of specifying
config_override:
for foundry-based dependencies.- extract_config(**overrides) ApeConfig
Extra configuration from the project so that Ape understands the dependencies and how to compile everything.
- Parameters:
**overrides – Config overrides.
- Returns:
ApeConfig
- property is_valid: bool
Return
True
when detecting a project of this type.