Skip to content

Commit

Permalink
Rename python implementations to python2 and python3, see kanaka#665
Browse files Browse the repository at this point in the history
  • Loading branch information
asarhaddon committed Aug 26, 2024
1 parent 87b283a commit 7221ddc
Show file tree
Hide file tree
Showing 58 changed files with 20 additions and 25 deletions.
5 changes: 2 additions & 3 deletions IMPLS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ IMPL:
- {IMPL: ps}
- {IMPL: powershell, NO_SELF_HOST: 1} # works, but too slow be default enabled
- {IMPL: purs}
- {IMPL: python, python_MODE: python2}
- {IMPL: python, python_MODE: python3}
- {IMPL: python.2}
- {IMPL: python2}
- {IMPL: python3}
- {IMPL: r}
- {IMPL: racket}
- {IMPL: rexx}
Expand Down
8 changes: 3 additions & 5 deletions Makefile.impls
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ d_MODE = gdc
haxe_MODE = neko
# octave or matlab
matlab_MODE = octave
# python, python2 or python3
python_MODE = python
# scheme (chibi, kawa, gauche, chicken, sagittarius, cyclone, foment)
scheme_MODE = chibi
# sml (polyml, mlton, mosml)
Expand All @@ -38,7 +36,7 @@ IMPLS = ada ada.2 awk bash basic bbc-basic c c.2 chuck clojure coffee common-lis
elisp elixir elm erlang es6 factor fantom fennel forth fsharp go groovy gnu-smalltalk \
guile haskell haxe hy io janet java java-truffle js jq julia kotlin latex3 livescript logo lua make mal \
matlab miniMAL nasm nim objc objpascal ocaml perl perl6 php picolisp pike plpgsql \
plsql powershell prolog ps purs python python.2 r racket rexx rpython ruby ruby.2 rust scala scheme skew sml \
plsql powershell prolog ps purs python2 python3 r racket rexx rpython ruby ruby.2 rust scala scheme skew sml \
swift swift3 swift4 swift5 tcl ts vala vb vbs vhdl vimscript wasm wren yorick xslt zig

step5_EXCLUDES += bash # never completes at 10,000
Expand Down Expand Up @@ -174,8 +172,8 @@ powershell_STEP_TO_PROG = impls/powershell/$($(1)).ps1
prolog_STEP_TO_PROG = impls/prolog/$($(1)).pl
ps_STEP_TO_PROG = impls/ps/$($(1)).ps
purs_STEP_TO_PROG = impls/purs/$($(1)).js
python_STEP_TO_PROG = impls/python/$($(1)).py
python.2_STEP_TO_PROG = impls/python.2/$($(1)).py
python2_STEP_TO_PROG = impls/python2/$($(1)).py
python3_STEP_TO_PROG = impls/python3/$($(1)).py
r_STEP_TO_PROG = impls/r/$($(1)).r
racket_STEP_TO_PROG = impls/racket/$($(1)).rkt
rexx_STEP_TO_PROG = impls/rexx/$($(1)).rexxpp
Expand Down
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ FAQ](docs/FAQ.md) where I attempt to answer some common questions.
| [PowerShell](#powershell) | [Joel Martin](https://github.com/kanaka) |
| [Prolog](#prolog-logical-language) | [Nicolas Boulenguez](https://github.com/asarhaddon) |
| [PureScript](#purescript) | [mrsekut](https://github.com/mrsekut) |
| [Python](#python-2x-and-3x) (2.X & 3.X) | [Joel Martin](https://github.com/kanaka) |
| [Python #2](#python2-3x) (3.X) | [Gavin Lewis](https://github.com/epylar) |
| [Python2](#python2) | [Joel Martin](https://github.com/kanaka) |
| [Python3](#python3) | [Gavin Lewis](https://github.com/epylar) |
| [RPython](#rpython) | [Joel Martin](https://github.com/kanaka) |
| [R](#r) | [Joel Martin](https://github.com/kanaka) |
| [Racket](#racket-53) | [Joel Martin](https://github.com/kanaka) |
Expand Down Expand Up @@ -962,16 +962,14 @@ make
node ./stepX_YYY.js
```

### Python (2.X and 3.X)
### Python2

```
cd impls/python
python stepX_YYY.py
```
This implementation only uses python2 features, but avoids
incompatibilities with python3.

### Python.2 (3.X)
### Python3

The second Python implementation is checked for style and types
This implementationd is checked for style and types
(flake8, pylint, mypy). It reports all errors with details.
It demonstrates iterators, decorators, functional tools, chain maps,
dataclasses, introspection, match statements, assignement expressions.
Expand Down Expand Up @@ -1380,7 +1378,7 @@ make MAL_IMPL=IMPL "test^mal^step2"
# e.g.
make "test^mal^step2" # js is default
make MAL_IMPL=ruby "test^mal^step2"
make MAL_IMPL=python "test^mal^step2"
make MAL_IMPL=python3 "test^mal^step2"
```

### Starting the REPL
Expand Down Expand Up @@ -1414,7 +1412,7 @@ make MAL_IMPL=IMPL "repl^mal^stepX"
# e.g.
make "repl^mal^step2" # js is default
make MAL_IMPL=ruby "repl^mal^step2"
make MAL_IMPL=python "repl^mal"
make MAL_IMPL=python3 "repl^mal"
```

### Performance tests
Expand Down
2 changes: 0 additions & 2 deletions impls/python/run

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions impls/python2/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec python2 $(dirname $0)/${STEP:-stepA_mal}.py "${@}"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion impls/python/stepA_mal.py → impls/python2/stepA_mal.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def REP(str):
repl_env.set(types._symbol('*ARGV*'), types.List(sys.argv[2:]))

# core.mal: defined using the language itself
REP('(def! *host-language* "python")')
REP('(def! *host-language* "python2")')
REP("(def! not (fn* (a) (if a false true)))")
REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))')
REP("""(defmacro! cond (fn* (& xs)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion impls/python.2/run → impls/python3/run
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
#!/bin/sh
exec python3 $(dirname $0)/${STEP:-stepA_mal}.py "${@}"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion impls/python.2/stepA_mal.py → impls/python3/stepA_mal.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def _(args: Sequence[Form]) -> Form:
(list 'if (first xs) (if (> (count xs) 1) (nth xs 1)
(throw "odd number of forms to cond"))
(cons 'cond (rest (rest xs)))))))""", repl_env)
rep('(def! *host-language* "python.2")', repl_env)
rep('(def! *host-language* "python3")', repl_env)
match sys.argv:
case _, file_name, *args:
repl_env['*ARGV*'] = List(String(a) for a in args)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*host-language*
;=>"python.2"
;=>"python3"

;; Testing Python interop

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 7221ddc

Please sign in to comment.