Skip to content

Commit 09ba199

Browse files
authored
Merge pull request #19 from sharktide/1.1.0
1.1.0
2 parents ef29305 + 7e6179e commit 09ba199

8 files changed

Lines changed: 69 additions & 20 deletions

File tree

docs/source/changelog.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ reStructuredPython Changelog
66
Major release 1
77
---------------
88

9+
.. raw:: html
10+
11+
<details>
12+
<summary>1.1.0</summary>
13+
<ul>
14+
<li>Added the repycl command, which autocompiles and launches reStructuredPython programs</li>
15+
</ul>
16+
</details>
17+
918
.. raw:: html
1019

1120
<details>

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
copyright = '2025, Rihaan Meher'
1111
author = 'Rihaan Meher'
1212

13-
release = '1.0.0'
13+
release = '1.1.0'
1414
html_favicon = "_static/icon.png"
1515

1616
# -- General configuration ---------------------------------------------------

docs/source/index.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@ To begin using reStructuredPython, install the compiler via pip:
1212
1313
pip install --upgrade restructuredpython
1414
15-
After installation, you can compile your .repy files using the following command:
15+
After installation, you can compile your .repy files to .py using the following command:
1616

1717
.. code-block:: shell
1818
1919
repy path/to/your/file.repy
2020
21+
Or you can directly run .repy programs via the ``repycl`` command if using 1.1.0+
22+
.. code-block:: shell
23+
24+
repycl path/to/your/file.repy
25+
2126
Features
2227
--------
2328

docs/source/roadmap.rst

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
Roadmap
22
=======
33

4-
1.0.0
5-
-----
6-
7-
Enhance reStructuredPython ``include`` function to allow for new decorators that will be implemented as built-in to the reStructuredPython compiler.
8-
9-
Expected release dates:
10-
11-
03/16/2025 - 03/18/2025
12-
13-
1.1.1
4+
1.2.0
145
-----
156

167
Possibly add built-in functions, not only decorators. This will definetly happen, we just aren't sure if it will happen in 1.1.1

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "restructuredpython"
7-
version = "1.0.0"
7+
version = "1.1.0"
88
description = "A superset of Python with js-like syntax"
99
authors = [{name = "Rihaan Meher", email = "meherrihaan@gmail.com"}]
1010
license = {text = "MIT"}
1111
classifiers = [
1212
"Programming Language :: Python :: 3",
13-
"Programming Language :: Python :: 3.9",
1413
"Programming Language :: Python :: 3.10",
1514
"Programming Language :: Python :: 3.11",
1615
"Programming Language :: Python :: 3.12",
16+
"Programming Language :: Python :: 3.13",
1717
]
1818

1919
[project.scripts]
2020
repy = "restructuredpython.restructuredpython:main"
21+
repycl = "restructuredpython.restructuredpython:launch"
22+
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
Metadata-Version: 2.2
1+
Metadata-Version: 2.4
22
Name: restructuredpython
3-
Version: 1.0.0
3+
Version: 1.1.0
44
Summary: A superset of Python with js-like syntax
55
Author-email: Rihaan Meher <meherrihaan@gmail.com>
66
License: MIT
77
Classifier: Programming Language :: Python :: 3
8-
Classifier: Programming Language :: Python :: 3.9
9-
Classifier: Programming Language :: Python :: 3.10
8+
Classifier: Programming Language :: Python :: 3.19
109
Classifier: Programming Language :: Python :: 3.11
1110
Classifier: Programming Language :: Python :: 3.12
11+
Classifier: Programming Language :: Python :: 3.13
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[console_scripts]
22
repy = restructuredpython.restructuredpython:main
3+
repycl = restructuredpython.restructuredpython:launch

restructuredpython/restructuredpython.py

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sys
44
import os
55
import warnings
6+
import tempfile
67
from pathlib import Path
78

89
token_specification = [
@@ -231,6 +232,16 @@ def process_includes(code, input_file):
231232

232233
return header_code, code_without_includes
233234

235+
def execute_code_temporarily(code):
236+
with tempfile.TemporaryDirectory() as tmpdir:
237+
temp_file_path = os.path.join(tmpdir, "compiled_repy.py")
238+
with open(temp_file_path, 'w') as temp_file:
239+
temp_file.write(code)
240+
try:
241+
exec(open(temp_file_path).read(), {"__name__": "__main__"})
242+
except Exception as e:
243+
print(f"Error during execution: {e}")
244+
print(f"You can view the generated file at {(temp_file_path)}")
234245

235246
def main():
236247
parser = argparse.ArgumentParser(description="Compile REPY files.")
@@ -258,8 +269,38 @@ def main():
258269
with open(output_file, 'w') as f:
259270
f.write(final_code)
260271

261-
print(f"Successfully compiled {input_file} to {output_file}")
272+
print(f"Successfully compiled {input_file} to {output_file}")
273+
274+
def launch():
275+
parser = argparse.ArgumentParser(description="Preview REPY execution.")
276+
parser.add_argument("filename", help="The REPY file to preview.")
277+
args = parser.parse_args()
278+
279+
input_file = args.filename
280+
281+
if not os.path.exists(input_file):
282+
print(f"Error: The file {input_file} does not exist.")
283+
return
284+
285+
with open(input_file, 'r') as f:
286+
source_code = f.read()
287+
288+
header_code, code_without_includes = process_includes(
289+
source_code, input_file)
290+
291+
python_code = parse_repython(code_without_includes)
292+
293+
final_code = header_code + python_code
294+
295+
# Execute the compiled code directly
296+
try:
297+
execute_code_temporarily(final_code)
298+
except Exception as e:
299+
print(f"Error during execution: {e}")
262300

263301

264302
if __name__ == "__main__":
265-
main()
303+
main(1)
304+
305+
if __name__ == "__launch__":
306+
main(2)

0 commit comments

Comments
 (0)