Python wrapper for `MacroEnergy.jl`, a Julia multi-sector capacity expansion modelling framework
Project description
macroenergy
Python wrapper for MacroEnergy.jl.
Installation
From PyPI:
pip install macroenergy
Then run setup once to install/compile the Julia package:
uv run macroenergy-setup
If not using uv, run:
macroenergy-setup
Import paths after install
After pip install macroenergy, prefer importing directly from the top-level namespace:
from macroenergy import run_case, setup_macroenergy_jl, list_examples
Internal implementation lives in setup, examples, and run_tools; macroenergy is the public flat API facade.
Package structure
Public API is exposed at macroenergy.* for convenience.
Internal modules are organized as:
setupexamplesrun_tools
Julia package setup
Setup helper functions:
install_macroenergy_jl(...)compile_macroenergy_jl(...)setup_macroenergy_jl(...)
Example:
from macroenergy import setup_macroenergy_jl
setup_macroenergy_jl(
url="https://github.com/macroenergy/MacroEnergy.jl",
rev="main",
)
CLI:
uv run macroenergy-setup
uv run macroenergy-setup --install-only
uv run macroenergy-setup --compile-only
uv run macroenergy-setup --url https://github.com/macroenergy/MacroEnergy.jl --rev main
MacroEnergy examples
Example helper functions (mapped to MacroEnergy.jl):
authenticate_github(token)list_examples(auth=...)download_example(example_name, target_dir=".", auth=...)download_examples(target_dir=".", pause_seconds=1.0, auth=...)example_readme(example_name, auth=...)example_contents(example_name, auth=...)
Example:
from macroenergy import download_example, list_examples
examples = list_examples()
download_example(examples[0], target_dir=".")
CLI examples:
uv run macroenergy-examples list
uv run macroenergy-examples download MyExample --target-dir .
uv run macroenergy-examples readme MyExample
uv run macroenergy-examples contents MyExample
uv run macroenergy-examples download-all --target-dir . --pause-seconds 1.0
Testing
- Unit tests:
uv run pytest - Integration tests (includes explicit setup test first):
uv run pytest -m integration
Integration tests are marked with @pytest.mark.integration and are excluded by default via pytest config.
Running cases
Python wrapper:
from macroenergy import run_case
systems, solution = run_case("/path/to/case")
The wrapper is a passthrough to MacroEnergy.run_case, so supported keyword arguments follow the Julia function (for example lazy_load, log_to_console, log_to_file, log_file_path, log_level, optimizer-related keywords, etc.).
CLI:
uv run macroenergy-run-case /path/to/case
uv run macroenergy-run-case /path/to/case --no-lazy-load --no-log-to-console
uv run macroenergy-run-case /path/to/case --log-level Info
Optional setup + run in one command:
uv run macroenergy-run-case /path/to/case --setup-first --url https://github.com/macroenergy/MacroEnergy.jl --rev main
Compatibility note
juliacall may be unstable with some Python/runtime combinations (for example, occasional VS Code crashes during interpreter shutdown on newer Python versions). If you see native crashes, prefer a stable Python version such as 3.12/3.13 for development and CI, and keep Julia/juliacall versions pinned in your environment.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file macroenergy-0.1.0.tar.gz.
File metadata
- Download URL: macroenergy-0.1.0.tar.gz
- Upload date:
- Size: 15.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a12347c7de218aa72ad8868acc37e84c408362f13e2319e3ee5221b34b2506d
|
|
| MD5 |
ebc9caa370eed91aadd895deb691e3ce
|
|
| BLAKE2b-256 |
a9d8045234fc0e2cab0d68c296326e6fdda85764a82d84e5428e8d02c14c166c
|
File details
Details for the file macroenergy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: macroenergy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e37ed2b33b673472d7b117fc8d77802682f1f290164afa50279250d7739cb40
|
|
| MD5 |
2236de7f294c661d493316ee1a18bd0c
|
|
| BLAKE2b-256 |
a4ee64d1f48e7065b9976b6f780e0783e4d402296f88994b27b65f1328da7ec4
|