From 5b174285e631cf0f349b623acd1d8e748d17c0f0 Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Sat, 16 May 2015 15:23:49 +0200 Subject: [PATCH] Switch Python to single script + Makefile tricks Instead of relying on shebang to call Python correctly, move to a single script (non-executable) plus Makefile tricks to build the desired python invocations. This also allows overriding the Python versions from the command line. --- Makefile | 14 ++++++++------ python/{null.py26 => null.py} | 2 +- python/null.py26-s | 5 ----- python/null.py27 | 5 ----- python/null.py27-o | 5 ----- python/null.py27-s | 5 ----- python/null.py32 | 5 ----- python/null.py32-o | 5 ----- python/null.py32-s | 5 ----- python/null.pypy | 5 ----- python/null.pypy-s | 5 ----- 11 files changed, 9 insertions(+), 52 deletions(-) rename python/{null.py26 => null.py} (51%) mode change 100755 => 100644 delete mode 100755 python/null.py26-s delete mode 100755 python/null.py27 delete mode 100755 python/null.py27-o delete mode 100755 python/null.py27-s delete mode 100755 python/null.py32 delete mode 100755 python/null.py32-o delete mode 100755 python/null.py32-s delete mode 100755 python/null.pypy delete mode 100755 python/null.pypy-s diff --git a/Makefile b/Makefile index 022c803..8f2378c 100644 --- a/Makefile +++ b/Makefile @@ -16,11 +16,7 @@ SCRIPTS = \ awk/null.mawk awk/null.gawk \ ruby/null.rb18 ruby/null.rb19 \ php/null.php php/null.php-n \ - tcl/null.tcl84 tcl/null.tcl85 tcl/null.tcl86 \ - python/null.py26 python/null.py26-s \ - python/null.py27 python/null.py27-s python/null.py27-o \ - python/null.py32 python/null.py32-s python/null.py32-o \ - python/null.pypy python/null.pypy-s + tcl/null.tcl84 tcl/null.tcl85 tcl/null.tcl86 #METRICS = \ # cycles,instructions,branches,branch-misses \ @@ -34,6 +30,11 @@ JAVA_VMS = server zero cacao jamvm # see below for how this is called JAVA_INVOCS = $(JAVA_VMS:%="java -cp java -% Null") +PYTHON_VERSIONS ?= python2.7 python3.4 pypy +PYTHON_VARIANTS = "" -O -S +PYTHON_INVOCS = $(foreach py,$(PYTHON_VERSIONS), \ + $(foreach opt,$(PYTHON_VARIANTS), "$(py) $(opt) python/null.py")) + EXTRA_RUN = /bin/true REPS = 100 @@ -94,7 +95,8 @@ java/Null.class: java/Null.java Makefile log: $(PROGS) $(SCRIPTS) java/Null.class Makefile rm -f log; \ - for prog in $(PROGS:%=./%) $(SCRIPTS:%=./%) $(EXTRA_RUN) $(JAVA_INVOCS); do \ + for prog in $(PROGS:%=./%) $(SCRIPTS:%=./%) \ + $(EXTRA_RUN) $(JAVA_INVOCS) $(PYTHON_INVOCS); do \ echo $$prog; \ for metric in $(METRICS); do \ LC_ALL=C $(PERF) stat -e "$$metric" -r $(REPS) -o log --append $$prog; \ diff --git a/python/null.py26 b/python/null.py old mode 100755 new mode 100644 similarity index 51% rename from python/null.py26 rename to python/null.py index 9fea3b9..dfb5a79 --- a/python/null.py26 +++ b/python/null.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2.6 +# this is not a shebang import sys diff --git a/python/null.py26-s b/python/null.py26-s deleted file mode 100755 index 5987b46..0000000 --- a/python/null.py26-s +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/python2.6 -S - -import sys - -sys.exit(0) diff --git a/python/null.py27 b/python/null.py27 deleted file mode 100755 index f9c8f17..0000000 --- a/python/null.py27 +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/python2.7 - -import sys - -sys.exit(0) diff --git a/python/null.py27-o b/python/null.py27-o deleted file mode 100755 index 77548af..0000000 --- a/python/null.py27-o +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/python2.7 -O - -import sys - -sys.exit(0) diff --git a/python/null.py27-s b/python/null.py27-s deleted file mode 100755 index f30d22d..0000000 --- a/python/null.py27-s +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/python2.7 -S - -import sys - -sys.exit(0) diff --git a/python/null.py32 b/python/null.py32 deleted file mode 100755 index 0c96776..0000000 --- a/python/null.py32 +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/python3.2 - -import sys - -sys.exit(0) diff --git a/python/null.py32-o b/python/null.py32-o deleted file mode 100755 index bf38b2f..0000000 --- a/python/null.py32-o +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/python3.2 -O - -import sys - -sys.exit(0) diff --git a/python/null.py32-s b/python/null.py32-s deleted file mode 100755 index 19f2647..0000000 --- a/python/null.py32-s +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/python3.2 -S - -import sys - -sys.exit(0) diff --git a/python/null.pypy b/python/null.pypy deleted file mode 100755 index 6f3f52b..0000000 --- a/python/null.pypy +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/pypy - -import sys - -sys.exit(0) diff --git a/python/null.pypy-s b/python/null.pypy-s deleted file mode 100755 index 0e40cb2..0000000 --- a/python/null.pypy-s +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/pypy -S - -import sys - -sys.exit(0) -- 2.39.5