mesa: correctly use os.path.join in our python scripts
authorEmil Velikov <emil.velikov@collabora.com>
Sun, 9 Dec 2018 20:09:49 +0000 (20:09 +0000)
committerEmil Velikov <emil.l.velikov@gmail.com>
Thu, 24 Jan 2019 18:13:24 +0000 (18:13 +0000)
With Windows in mind, using forward slash isn't the right thing to do.
Even if it just works, we might want to fix it.

As here, use __file__ instead of argv[0] and sys.path.insert over
sys.path.append. With the path tweak being reportedly faster.

Suggested-by: Dylan Baker <dylan@pnwbakers.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
src/mapi/mapi_abi.py
src/mesa/main/get_hash_generator.py

index dc48fa5935fdcd55197184c43f30cb62c9a5e871..bb505561e7c53403aa2f502eab86353df52f4252 100644 (file)
@@ -29,8 +29,8 @@ from __future__ import print_function
 import sys
 # make it possible to import glapi
 import os
-GLAPI = os.path.join(".", os.path.dirname(sys.argv[0]), "glapi/gen")
-sys.path.append(GLAPI)
+GLAPI = os.path.join(".", os.path.dirname(__file__), "glapi", "gen")
+sys.path.insert(0, GLAPI)
 
 from operator import attrgetter
 import re
index f742ebff4b84cd64a9fa4e0a2b665264db432d26..3e9032bd4c82d95ba4f4b09148817fb0a6c126c4 100644 (file)
@@ -34,11 +34,10 @@ import os, sys, getopt
 from collections import defaultdict
 import get_hash_params
 
-cur_dir = os.path.dirname(sys.argv[0])
-param_desc_file = "%s/get_hash_params.py" % cur_dir
+param_desc_file = os.path.join(os.path.dirname(__file__), "get_hash_params.py")
 
-GLAPI = "%s/../../mapi/glapi/gen" % cur_dir
-sys.path.append(GLAPI)
+GLAPI = os.path.join(os.path.dirname(__file__), "..", "..", "mapi", "glapi", "gen")
+sys.path.insert(0, GLAPI)
 import gl_XML
 
 prime_factor = 89