mys-lang / mys

The Mys programming language - an attempt to create a statically typed Python-like language that produces fast binaries. See https://mys-lang.org for more information.
Other
132 stars 5 forks source link

cannot execute tutorial #2

Closed mpage38 closed 4 years ago

mpage38 commented 4 years ago

mys is a nice idea !

  1. I followed the tutorial and created foo package: build, Package.toml, and src are created
  2. cd foo
  3. $ mys run gives: Traceback (most recent call last): File "/home/mp/anaconda3/bin/mys", line 8, in sys.exit(main()) File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 733, in main args.func(args) File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 667, in _do_transpile source = transpile(fin.read()) File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 660, in transpile return ModuleVisitor().visit(ast.parse(source)) File "/home/mp/anaconda3/lib/python3.7/ast.py", line 271, in visit return visitor(node) File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 488, in visit_Module for item in node.body File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 488, in for item in node.body File "/home/mp/anaconda3/lib/python3.7/ast.py", line 271, in visit return visitor(node) File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 519, in visit_FunctionDef body.append(indent(BodyVisitor().visit(item))) File "/home/mp/anaconda3/lib/python3.7/ast.py", line 271, in visit return visitor(node) File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 258, in visit_Expr return self.visit(node.value) + ';' File "/home/mp/anaconda3/lib/python3.7/ast.py", line 271, in visit return visitor(node) File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 231, in visit_Call for arg in node.args File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 231, in for arg in node.args File "/home/mp/anaconda3/lib/python3.7/ast.py", line 271, in visit return visitor(node) File "/home/mp/anaconda3/lib/python3.7/site-packages/mys/init.py", line 480, in generic_visit raise Exception(node) Exception: <_ast.Str object at 0x7f83d12d8750> make: *** [Makefile:23 : transpiled/main.mys.cpp] Erreur 1 error: Command '['make', '-C', 'build', '-s']' returned non-zero exit status 2.

I am under ubuntu 20.04 ; Python 3.7.6 ; g++ 9.3.0 ; GNU Make 4.2.1

eerimoq commented 4 years ago

There was a non-backwards compatible change in Python's standard library ast module in 3.8. I've Python 3.8 on my machine.

From ast module documentation:

"Changed in version 3.8: Class ast.Constant is now used for all constants.

Deprecated since version 3.8: Old classes ast.Num, ast.Str, ast.Bytes, ast.NameConstant and ast.Ellipsis are still available, but they will be removed in future Python releases. In the meanwhile, instantiating them will return an instance of a different class."

Mys currently only uses ast.Constant. I guess support for older Python version would be a good addition as there are so many systems with them installed. I can have a look at it later.

eerimoq commented 4 years ago

Fixed. Version 0.15.0 should work with Python 3.6+.

eerimoq commented 4 years ago

Btw, simple arithmetic and print numbers works. The code in the seconds part of the tutorial will like;y not work. Instead, you can run the Fibonacci example.

eerimoq commented 4 years ago

@mpage38 Did it work now?

PS. Install the new version with pip3 install -U mys. DS.

mpage38 commented 4 years ago

Still the same error.

  1. pip3 install -U mys
    • Successfully installed mys-0.16.0 pprintast-1.2.1 toml-0.10.1

  2. mys run -> error: Command '['make', '-C', 'build', '-s']' returned non-zero exit status 2
eerimoq commented 4 years ago

No way. Run mys --version.

eerimoq commented 4 years ago

Closing as Mys works with Python 3.6+ on Travis. Let me know if the problem persists.