From 7221ddcfc64fb06b343305f1b662a29c5b7681fe Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez Date: Mon, 26 Aug 2024 14:21:30 +0200 Subject: [PATCH] Rename python implementations to python2 and python3, see #665 --- IMPLS.yml | 5 ++--- Makefile.impls | 8 +++----- README.md | 20 +++++++++---------- impls/python/run | 2 -- impls/{python => python2}/Dockerfile | 0 impls/{python => python2}/Makefile | 0 impls/{python => python2}/core.py | 0 impls/{python => python2}/env.py | 0 impls/{python => python2}/mal_readline.py | 0 impls/{python => python2}/mal_types.py | 0 impls/{python => python2}/printer.py | 0 impls/{python => python2}/reader.py | 0 impls/python2/run | 2 ++ impls/{python => python2}/step0_repl.py | 0 impls/{python => python2}/step1_read_print.py | 0 impls/{python => python2}/step2_eval.py | 0 impls/{python => python2}/step3_env.py | 0 impls/{python => python2}/step4_if_fn_do.py | 0 impls/{python => python2}/step5_tco.py | 0 impls/{python => python2}/step6_file.py | 0 impls/{python => python2}/step7_quote.py | 0 impls/{python => python2}/step8_macros.py | 0 impls/{python => python2}/step9_try.py | 0 impls/{python => python2}/stepA_mal.py | 2 +- .../{python.2 => python2}/tests/step5_tco.mal | 0 impls/{python => python2}/tests/stepA_mal.mal | 0 impls/{python.2 => python3}/.gitignore | 0 impls/{python.2 => python3}/Dockerfile | 0 impls/{python.2 => python3}/Makefile | 0 impls/{python.2 => python3}/core.py | 0 impls/{python.2 => python3}/env.py | 0 impls/{python.2 => python3}/mal_readline.py | 0 impls/{python.2 => python3}/mal_types.py | 0 impls/{python.2 => python3}/reader.py | 0 impls/{python.2 => python3}/run | 2 +- impls/{python.2 => python3}/step0_repl.py | 0 .../{python.2 => python3}/step1_read_print.py | 0 impls/{python.2 => python3}/step2_eval.py | 0 impls/{python.2 => python3}/step3_env.py | 0 impls/{python.2 => python3}/step4_if_fn_do.py | 0 impls/{python.2 => python3}/step5_tco.py | 0 impls/{python.2 => python3}/step6_file.py | 0 impls/{python.2 => python3}/step7_quote.py | 0 impls/{python.2 => python3}/step8_macros.py | 0 impls/{python.2 => python3}/step9_try.py | 0 impls/{python.2 => python3}/stepA_mal.py | 2 +- impls/{python.2 => python3}/tests/__init__.py | 0 impls/{python => python3}/tests/step5_tco.mal | 0 .../{python.2 => python3}/tests/stepA_mal.mal | 2 +- .../{python.2 => python3}/tests/test_step2.py | 0 .../{python.2 => python3}/tests/test_step3.py | 0 .../{python.2 => python3}/tests/test_step4.py | 0 .../{python.2 => python3}/tests/test_step5.py | 0 .../{python.2 => python3}/tests/test_step6.py | 0 .../{python.2 => python3}/tests/test_step7.py | 0 .../{python.2 => python3}/tests/test_step8.py | 0 .../{python.2 => python3}/tests/test_step9.py | 0 .../{python.2 => python3}/tests/test_stepA.py | 0 58 files changed, 20 insertions(+), 25 deletions(-) delete mode 100755 impls/python/run rename impls/{python => python2}/Dockerfile (100%) rename impls/{python => python2}/Makefile (100%) rename impls/{python => python2}/core.py (100%) rename impls/{python => python2}/env.py (100%) rename impls/{python => python2}/mal_readline.py (100%) rename impls/{python => python2}/mal_types.py (100%) rename impls/{python => python2}/printer.py (100%) rename impls/{python => python2}/reader.py (100%) create mode 100755 impls/python2/run rename impls/{python => python2}/step0_repl.py (100%) rename impls/{python => python2}/step1_read_print.py (100%) rename impls/{python => python2}/step2_eval.py (100%) rename impls/{python => python2}/step3_env.py (100%) rename impls/{python => python2}/step4_if_fn_do.py (100%) rename impls/{python => python2}/step5_tco.py (100%) rename impls/{python => python2}/step6_file.py (100%) rename impls/{python => python2}/step7_quote.py (100%) rename impls/{python => python2}/step8_macros.py (100%) rename impls/{python => python2}/step9_try.py (100%) rename impls/{python => python2}/stepA_mal.py (99%) rename impls/{python.2 => python2}/tests/step5_tco.mal (100%) rename impls/{python => python2}/tests/stepA_mal.mal (100%) rename impls/{python.2 => python3}/.gitignore (100%) rename impls/{python.2 => python3}/Dockerfile (100%) rename impls/{python.2 => python3}/Makefile (100%) rename impls/{python.2 => python3}/core.py (100%) rename impls/{python.2 => python3}/env.py (100%) rename impls/{python.2 => python3}/mal_readline.py (100%) rename impls/{python.2 => python3}/mal_types.py (100%) rename impls/{python.2 => python3}/reader.py (100%) rename impls/{python.2 => python3}/run (82%) rename impls/{python.2 => python3}/step0_repl.py (100%) rename impls/{python.2 => python3}/step1_read_print.py (100%) rename impls/{python.2 => python3}/step2_eval.py (100%) rename impls/{python.2 => python3}/step3_env.py (100%) rename impls/{python.2 => python3}/step4_if_fn_do.py (100%) rename impls/{python.2 => python3}/step5_tco.py (100%) rename impls/{python.2 => python3}/step6_file.py (100%) rename impls/{python.2 => python3}/step7_quote.py (100%) rename impls/{python.2 => python3}/step8_macros.py (100%) rename impls/{python.2 => python3}/step9_try.py (100%) rename impls/{python.2 => python3}/stepA_mal.py (99%) rename impls/{python.2 => python3}/tests/__init__.py (100%) rename impls/{python => python3}/tests/step5_tco.mal (100%) rename impls/{python.2 => python3}/tests/stepA_mal.mal (96%) rename impls/{python.2 => python3}/tests/test_step2.py (100%) rename impls/{python.2 => python3}/tests/test_step3.py (100%) rename impls/{python.2 => python3}/tests/test_step4.py (100%) rename impls/{python.2 => python3}/tests/test_step5.py (100%) rename impls/{python.2 => python3}/tests/test_step6.py (100%) rename impls/{python.2 => python3}/tests/test_step7.py (100%) rename impls/{python.2 => python3}/tests/test_step8.py (100%) rename impls/{python.2 => python3}/tests/test_step9.py (100%) rename impls/{python.2 => python3}/tests/test_stepA.py (100%) diff --git a/IMPLS.yml b/IMPLS.yml index abd7e0eb08..e660ed7626 100644 --- a/IMPLS.yml +++ b/IMPLS.yml @@ -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} diff --git a/Makefile.impls b/Makefile.impls index 2c1a2129ea..f126bc7612 100644 --- a/Makefile.impls +++ b/Makefile.impls @@ -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) @@ -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 @@ -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 diff --git a/README.md b/README.md index d6ac14fc5c..2b83eebc82 100644 --- a/README.md +++ b/README.md @@ -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) | @@ -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. @@ -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 @@ -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 diff --git a/impls/python/run b/impls/python/run deleted file mode 100755 index 7549617761..0000000000 --- a/impls/python/run +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -exec ${python_MODE:-python} $(dirname $0)/${STEP:-stepA_mal}.py "${@}" diff --git a/impls/python/Dockerfile b/impls/python2/Dockerfile similarity index 100% rename from impls/python/Dockerfile rename to impls/python2/Dockerfile diff --git a/impls/python/Makefile b/impls/python2/Makefile similarity index 100% rename from impls/python/Makefile rename to impls/python2/Makefile diff --git a/impls/python/core.py b/impls/python2/core.py similarity index 100% rename from impls/python/core.py rename to impls/python2/core.py diff --git a/impls/python/env.py b/impls/python2/env.py similarity index 100% rename from impls/python/env.py rename to impls/python2/env.py diff --git a/impls/python/mal_readline.py b/impls/python2/mal_readline.py similarity index 100% rename from impls/python/mal_readline.py rename to impls/python2/mal_readline.py diff --git a/impls/python/mal_types.py b/impls/python2/mal_types.py similarity index 100% rename from impls/python/mal_types.py rename to impls/python2/mal_types.py diff --git a/impls/python/printer.py b/impls/python2/printer.py similarity index 100% rename from impls/python/printer.py rename to impls/python2/printer.py diff --git a/impls/python/reader.py b/impls/python2/reader.py similarity index 100% rename from impls/python/reader.py rename to impls/python2/reader.py diff --git a/impls/python2/run b/impls/python2/run new file mode 100755 index 0000000000..095e1963d0 --- /dev/null +++ b/impls/python2/run @@ -0,0 +1,2 @@ +#!/bin/sh +exec python2 $(dirname $0)/${STEP:-stepA_mal}.py "${@}" diff --git a/impls/python/step0_repl.py b/impls/python2/step0_repl.py similarity index 100% rename from impls/python/step0_repl.py rename to impls/python2/step0_repl.py diff --git a/impls/python/step1_read_print.py b/impls/python2/step1_read_print.py similarity index 100% rename from impls/python/step1_read_print.py rename to impls/python2/step1_read_print.py diff --git a/impls/python/step2_eval.py b/impls/python2/step2_eval.py similarity index 100% rename from impls/python/step2_eval.py rename to impls/python2/step2_eval.py diff --git a/impls/python/step3_env.py b/impls/python2/step3_env.py similarity index 100% rename from impls/python/step3_env.py rename to impls/python2/step3_env.py diff --git a/impls/python/step4_if_fn_do.py b/impls/python2/step4_if_fn_do.py similarity index 100% rename from impls/python/step4_if_fn_do.py rename to impls/python2/step4_if_fn_do.py diff --git a/impls/python/step5_tco.py b/impls/python2/step5_tco.py similarity index 100% rename from impls/python/step5_tco.py rename to impls/python2/step5_tco.py diff --git a/impls/python/step6_file.py b/impls/python2/step6_file.py similarity index 100% rename from impls/python/step6_file.py rename to impls/python2/step6_file.py diff --git a/impls/python/step7_quote.py b/impls/python2/step7_quote.py similarity index 100% rename from impls/python/step7_quote.py rename to impls/python2/step7_quote.py diff --git a/impls/python/step8_macros.py b/impls/python2/step8_macros.py similarity index 100% rename from impls/python/step8_macros.py rename to impls/python2/step8_macros.py diff --git a/impls/python/step9_try.py b/impls/python2/step9_try.py similarity index 100% rename from impls/python/step9_try.py rename to impls/python2/step9_try.py diff --git a/impls/python/stepA_mal.py b/impls/python2/stepA_mal.py similarity index 99% rename from impls/python/stepA_mal.py rename to impls/python2/stepA_mal.py index 4560b0896b..75914fe620 100644 --- a/impls/python/stepA_mal.py +++ b/impls/python2/stepA_mal.py @@ -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) diff --git a/impls/python.2/tests/step5_tco.mal b/impls/python2/tests/step5_tco.mal similarity index 100% rename from impls/python.2/tests/step5_tco.mal rename to impls/python2/tests/step5_tco.mal diff --git a/impls/python/tests/stepA_mal.mal b/impls/python2/tests/stepA_mal.mal similarity index 100% rename from impls/python/tests/stepA_mal.mal rename to impls/python2/tests/stepA_mal.mal diff --git a/impls/python.2/.gitignore b/impls/python3/.gitignore similarity index 100% rename from impls/python.2/.gitignore rename to impls/python3/.gitignore diff --git a/impls/python.2/Dockerfile b/impls/python3/Dockerfile similarity index 100% rename from impls/python.2/Dockerfile rename to impls/python3/Dockerfile diff --git a/impls/python.2/Makefile b/impls/python3/Makefile similarity index 100% rename from impls/python.2/Makefile rename to impls/python3/Makefile diff --git a/impls/python.2/core.py b/impls/python3/core.py similarity index 100% rename from impls/python.2/core.py rename to impls/python3/core.py diff --git a/impls/python.2/env.py b/impls/python3/env.py similarity index 100% rename from impls/python.2/env.py rename to impls/python3/env.py diff --git a/impls/python.2/mal_readline.py b/impls/python3/mal_readline.py similarity index 100% rename from impls/python.2/mal_readline.py rename to impls/python3/mal_readline.py diff --git a/impls/python.2/mal_types.py b/impls/python3/mal_types.py similarity index 100% rename from impls/python.2/mal_types.py rename to impls/python3/mal_types.py diff --git a/impls/python.2/reader.py b/impls/python3/reader.py similarity index 100% rename from impls/python.2/reader.py rename to impls/python3/reader.py diff --git a/impls/python.2/run b/impls/python3/run similarity index 82% rename from impls/python.2/run rename to impls/python3/run index f82a47e536..1e7632cd57 100755 --- a/impls/python.2/run +++ b/impls/python3/run @@ -1,2 +1,2 @@ -#!/bin/bash +#!/bin/sh exec python3 $(dirname $0)/${STEP:-stepA_mal}.py "${@}" diff --git a/impls/python.2/step0_repl.py b/impls/python3/step0_repl.py similarity index 100% rename from impls/python.2/step0_repl.py rename to impls/python3/step0_repl.py diff --git a/impls/python.2/step1_read_print.py b/impls/python3/step1_read_print.py similarity index 100% rename from impls/python.2/step1_read_print.py rename to impls/python3/step1_read_print.py diff --git a/impls/python.2/step2_eval.py b/impls/python3/step2_eval.py similarity index 100% rename from impls/python.2/step2_eval.py rename to impls/python3/step2_eval.py diff --git a/impls/python.2/step3_env.py b/impls/python3/step3_env.py similarity index 100% rename from impls/python.2/step3_env.py rename to impls/python3/step3_env.py diff --git a/impls/python.2/step4_if_fn_do.py b/impls/python3/step4_if_fn_do.py similarity index 100% rename from impls/python.2/step4_if_fn_do.py rename to impls/python3/step4_if_fn_do.py diff --git a/impls/python.2/step5_tco.py b/impls/python3/step5_tco.py similarity index 100% rename from impls/python.2/step5_tco.py rename to impls/python3/step5_tco.py diff --git a/impls/python.2/step6_file.py b/impls/python3/step6_file.py similarity index 100% rename from impls/python.2/step6_file.py rename to impls/python3/step6_file.py diff --git a/impls/python.2/step7_quote.py b/impls/python3/step7_quote.py similarity index 100% rename from impls/python.2/step7_quote.py rename to impls/python3/step7_quote.py diff --git a/impls/python.2/step8_macros.py b/impls/python3/step8_macros.py similarity index 100% rename from impls/python.2/step8_macros.py rename to impls/python3/step8_macros.py diff --git a/impls/python.2/step9_try.py b/impls/python3/step9_try.py similarity index 100% rename from impls/python.2/step9_try.py rename to impls/python3/step9_try.py diff --git a/impls/python.2/stepA_mal.py b/impls/python3/stepA_mal.py similarity index 99% rename from impls/python.2/stepA_mal.py rename to impls/python3/stepA_mal.py index 01ef8a24d5..29691fb995 100644 --- a/impls/python.2/stepA_mal.py +++ b/impls/python3/stepA_mal.py @@ -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) diff --git a/impls/python.2/tests/__init__.py b/impls/python3/tests/__init__.py similarity index 100% rename from impls/python.2/tests/__init__.py rename to impls/python3/tests/__init__.py diff --git a/impls/python/tests/step5_tco.mal b/impls/python3/tests/step5_tco.mal similarity index 100% rename from impls/python/tests/step5_tco.mal rename to impls/python3/tests/step5_tco.mal diff --git a/impls/python.2/tests/stepA_mal.mal b/impls/python3/tests/stepA_mal.mal similarity index 96% rename from impls/python.2/tests/stepA_mal.mal rename to impls/python3/tests/stepA_mal.mal index c5007053be..8d8731a87e 100644 --- a/impls/python.2/tests/stepA_mal.mal +++ b/impls/python3/tests/stepA_mal.mal @@ -1,5 +1,5 @@ *host-language* -;=>"python.2" +;=>"python3" ;; Testing Python interop diff --git a/impls/python.2/tests/test_step2.py b/impls/python3/tests/test_step2.py similarity index 100% rename from impls/python.2/tests/test_step2.py rename to impls/python3/tests/test_step2.py diff --git a/impls/python.2/tests/test_step3.py b/impls/python3/tests/test_step3.py similarity index 100% rename from impls/python.2/tests/test_step3.py rename to impls/python3/tests/test_step3.py diff --git a/impls/python.2/tests/test_step4.py b/impls/python3/tests/test_step4.py similarity index 100% rename from impls/python.2/tests/test_step4.py rename to impls/python3/tests/test_step4.py diff --git a/impls/python.2/tests/test_step5.py b/impls/python3/tests/test_step5.py similarity index 100% rename from impls/python.2/tests/test_step5.py rename to impls/python3/tests/test_step5.py diff --git a/impls/python.2/tests/test_step6.py b/impls/python3/tests/test_step6.py similarity index 100% rename from impls/python.2/tests/test_step6.py rename to impls/python3/tests/test_step6.py diff --git a/impls/python.2/tests/test_step7.py b/impls/python3/tests/test_step7.py similarity index 100% rename from impls/python.2/tests/test_step7.py rename to impls/python3/tests/test_step7.py diff --git a/impls/python.2/tests/test_step8.py b/impls/python3/tests/test_step8.py similarity index 100% rename from impls/python.2/tests/test_step8.py rename to impls/python3/tests/test_step8.py diff --git a/impls/python.2/tests/test_step9.py b/impls/python3/tests/test_step9.py similarity index 100% rename from impls/python.2/tests/test_step9.py rename to impls/python3/tests/test_step9.py diff --git a/impls/python.2/tests/test_stepA.py b/impls/python3/tests/test_stepA.py similarity index 100% rename from impls/python.2/tests/test_stepA.py rename to impls/python3/tests/test_stepA.py