Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions protostar.spec
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ block_cipher = None
extra_files = [
("protostar_cairo", "protostar_cairo"),
("cairo/corelib", "cairo/corelib"),
("cairo/Cargo.toml", "cairo"),
('templates', 'templates'),
('constants.json', 'info'),
] + collect_data_files('starkware')
Expand Down
2 changes: 1 addition & 1 deletion protostar/protostar_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(
name="version",
short_name="v",
type="bool",
description="Show Protostar and Cairo-lang version.",
description="Show Protostar, Cairo-lang and Cairo 1 compiler versions.",
),
ProtostarArgument(
name="no-color",
Expand Down
22 changes: 22 additions & 0 deletions protostar/self/protostar_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
from packaging import version
from packaging.version import Version

from tomlkit import parse

from protostar.git import get_git_version, ProtostarGitException

from .protostar_compatibility_with_project_checker import (
ProtostarVersion,
parse_protostar_version,
)


RuntimeConstantName = Literal["PROTOSTAR_VERSION", "CAIRO_VERSION"]
RuntimeConstantValue = str
RuntimeConstantsDict = dict[RuntimeConstantName, RuntimeConstantValue]
Expand Down Expand Up @@ -52,6 +55,11 @@ def protostar_cairo1_corelib_path(self) -> Path:
assert self.protostar_binary_dir_path is not None
return self.protostar_binary_dir_path / "cairo" / "corelib"

@property
def protostar_cairo1_compiler_path(self) -> Path:
assert self.protostar_binary_dir_path is not None
return self.protostar_binary_dir_path / "cairo"

def _read_runtime_constants(self) -> Optional[RuntimeConstantsDict]:
constants_str = (
self.info_dir_path / ProtostarDirectory.RUNTIME_CONSTANTS_FILE_NAME
Expand Down Expand Up @@ -109,6 +117,20 @@ def git_version(self) -> Optional[Version]:
pass
return None

@property
def cairo1_compiler_version(self) -> Optional[Version]:
try:
compiler_cargo = (
self._protostar_directory.protostar_cairo1_compiler_path / "Cargo.toml"
)
with open(compiler_cargo, "r") as file:
cargo = parse(file.read())
version_str: str = cargo["workspace"]["package"]["version"] # type: ignore
return version.parse(version_str)
except BaseException:
return None

def print_current_version(self) -> None:
print(f"Protostar version: {self.protostar_version or 'unknown'}")
print(f"Cairo-lang version: {self.cairo_version or 'unknown'}")
print(f"Cairo 1 compiler version: {self.cairo1_compiler_version or 'unknown'}")
1 change: 1 addition & 0 deletions tests/e2e/test_misc_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def test_versions(protostar: ProtostarFixture):
result = protostar(["-v"])
assert "Protostar" in result
assert "Cairo-lang" in result
assert "Cairo 1 compiler" in result


def test_init(init_project: ProjectInitializer, project_name: str):
Expand Down
2 changes: 1 addition & 1 deletion website/docs/cli-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Disable colors.
#### `-p` `--profile STRING`
Specifies active configuration profile defined in the configuration file.
#### `-v` `--version`
Show Protostar and Cairo-lang version.
Show Protostar, Cairo-lang and Cairo 1 compiler versions.
## Commands
### `build`
```shell
Expand Down
1 change: 1 addition & 0 deletions website/docs/tutorials/05-compiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ Protostar ships with its own version of Cairo-lang and formatter, so you don't n
$ protostar -v
Protostar version: X.Y.Z
Cairo-lang version: A.B.C
Cairo 1 compiler version: J.K.L
```