Skip to content

Commit 8a65ba7

Browse files
added compiler version info to --version (#1842)
1 parent 9ce680d commit 8a65ba7

File tree

6 files changed

+27
-2
lines changed

6 files changed

+27
-2
lines changed

protostar.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ block_cipher = None
77
extra_files = [
88
("protostar_cairo", "protostar_cairo"),
99
("cairo/corelib", "cairo/corelib"),
10+
("cairo/Cargo.toml", "cairo"),
1011
('templates', 'templates'),
1112
('constants.json', 'info'),
1213
] + collect_data_files('starkware')

protostar/protostar_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def __init__(
6161
name="version",
6262
short_name="v",
6363
type="bool",
64-
description="Show Protostar and Cairo-lang version.",
64+
description="Show Protostar, Cairo-lang and Cairo 1 compiler versions.",
6565
),
6666
ProtostarArgument(
6767
name="no-color",

protostar/self/protostar_directory.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77
from packaging import version
88
from packaging.version import Version
99

10+
from tomlkit import parse
11+
1012
from protostar.git import get_git_version, ProtostarGitException
1113

1214
from .protostar_compatibility_with_project_checker import (
1315
ProtostarVersion,
1416
parse_protostar_version,
1517
)
1618

19+
1720
RuntimeConstantName = Literal["PROTOSTAR_VERSION", "CAIRO_VERSION"]
1821
RuntimeConstantValue = str
1922
RuntimeConstantsDict = dict[RuntimeConstantName, RuntimeConstantValue]
@@ -52,6 +55,11 @@ def protostar_cairo1_corelib_path(self) -> Path:
5255
assert self.protostar_binary_dir_path is not None
5356
return self.protostar_binary_dir_path / "cairo" / "corelib"
5457

58+
@property
59+
def protostar_cairo1_compiler_path(self) -> Path:
60+
assert self.protostar_binary_dir_path is not None
61+
return self.protostar_binary_dir_path / "cairo"
62+
5563
def _read_runtime_constants(self) -> Optional[RuntimeConstantsDict]:
5664
constants_str = (
5765
self.info_dir_path / ProtostarDirectory.RUNTIME_CONSTANTS_FILE_NAME
@@ -109,6 +117,20 @@ def git_version(self) -> Optional[Version]:
109117
pass
110118
return None
111119

120+
@property
121+
def cairo1_compiler_version(self) -> Optional[Version]:
122+
try:
123+
compiler_cargo = (
124+
self._protostar_directory.protostar_cairo1_compiler_path / "Cargo.toml"
125+
)
126+
with open(compiler_cargo, "r") as file:
127+
cargo = parse(file.read())
128+
version_str: str = cargo["workspace"]["package"]["version"] # type: ignore
129+
return version.parse(version_str)
130+
except BaseException:
131+
return None
132+
112133
def print_current_version(self) -> None:
113134
print(f"Protostar version: {self.protostar_version or 'unknown'}")
114135
print(f"Cairo-lang version: {self.cairo_version or 'unknown'}")
136+
print(f"Cairo 1 compiler version: {self.cairo1_compiler_version or 'unknown'}")

tests/e2e/test_misc_commands.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def test_versions(protostar: ProtostarFixture):
2222
result = protostar(["-v"])
2323
assert "Protostar" in result
2424
assert "Cairo-lang" in result
25+
assert "Cairo 1 compiler" in result
2526

2627

2728
def test_init(init_project: ProjectInitializer, project_name: str):

website/docs/cli-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Disable colors.
55
#### `-p` `--profile STRING`
66
Specifies active configuration profile defined in the configuration file.
77
#### `-v` `--version`
8-
Show Protostar and Cairo-lang version.
8+
Show Protostar, Cairo-lang and Cairo 1 compiler versions.
99
## Commands
1010
### `build`
1111
```shell

website/docs/tutorials/05-compiling.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@ Protostar ships with its own version of Cairo-lang and formatter, so you don't n
4949
$ protostar -v
5050
Protostar version: X.Y.Z
5151
Cairo-lang version: A.B.C
52+
Cairo 1 compiler version: J.K.L
5253
```

0 commit comments

Comments
 (0)