Skip to content

Commit

Permalink
Builder|qmake: Run Python 2 specifically
Browse files Browse the repository at this point in the history
Python 3 is becoming commonplace as the default version, but our
scripts are still using Python 2. These changes ensure that
Python 2 (2.7) is run whenever Python is needed.

On Windows, however, it is up to the user to make sure that Python
2 is the default Python (on the PATH).
  • Loading branch information
skyjake committed Feb 20, 2014
1 parent 24376b0 commit c62f79d
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 77 deletions.
4 changes: 2 additions & 2 deletions distrib/autobuild.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python2.7
# coding=utf-8
#
# Script for performing automated build events.
Expand Down Expand Up @@ -65,7 +65,7 @@ def todays_platform_release():
oldFiles = DirState('releases', subdirs=False)

print 'platform_release.py...'
os.system("python platform_release.py > %s 2> %s" % \
run_python2("platform_release.py > %s 2> %s" % \
('buildlog.txt', 'builderrors.txt'))

for n in DirState('releases', subdirs=False).list_new_files(oldFiles):
Expand Down
2 changes: 1 addition & 1 deletion distrib/build_number.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python2.7
# Determining the number of a build.

import time
Expand Down
11 changes: 11 additions & 0 deletions distrib/builder/utils.py
Expand Up @@ -193,3 +193,14 @@ def system_command(cmd):
result = subprocess.call(cmd, shell=True)
if result != 0:
raise Exception("Error from " + cmd)


def python2_executable():
if sys.platform[:3] == 'win':
return 'python'
else:
return 'python2.7'


def run_python2(script):
system_command(python2_executable() + " " + script)
8 changes: 4 additions & 4 deletions distrib/pilot.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python2.7
# coding=utf-8
#
# The Doomsday Build Pilot
Expand Down Expand Up @@ -35,6 +35,7 @@
import struct
import time
import SocketServer
import builder.utils

def homeDir():
"""Determines the path of the pilot home directory."""
Expand Down Expand Up @@ -414,8 +415,7 @@ def handleCompletedTasks():


def autobuild(cmd):
cmdLine = "python %s %s" % (os.path.join(pilotcfg.DISTRIB_DIR,
'autobuild.py'), cmd)
cmdLine = "%s %s" % (os.path.join(pilotcfg.DISTRIB_DIR, 'autobuild.py'), cmd)
cmdLine += " --distrib %s" % pilotcfg.DISTRIB_DIR
if 'EVENTS_DIR' in dir(pilotcfg):
cmdLine += " --events %s" % pilotcfg.EVENTS_DIR
Expand All @@ -424,7 +424,7 @@ def autobuild(cmd):

cmdLine += " --branch %s" % currentBranch()

systemCommand(cmdLine)
builder.utils.run_python2(cmdLine)
return True


Expand Down
4 changes: 2 additions & 2 deletions distrib/platform_release.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python2.7
# This script builds the distribution packages platform-independently.
# No parameters needed; config is auto-detected.

Expand Down Expand Up @@ -160,7 +160,7 @@ def mac_package_snowberry():
f = file('VERSION', 'wt')
f.write(DOOMSDAY_VERSION_FULL)
f.close()
os.system('python buildapp.py py2app')
builder.utils.run_python2('buildapp.py py2app')

# Share it.
duptree('dist/Doomsday Engine.app', 'shared/')
Expand Down
6 changes: 4 additions & 2 deletions doomsday/build/build.pro
Expand Up @@ -9,8 +9,10 @@ TEMPLATE = subdirs
# Let's print the build configuration during this qmake invocation.
CONFIG += deng_verbosebuildconfig

include(../macros.pri)

# Always update versions.pri.
system(cd "$$PWD/.." && python configure.py)
runPython2InDir($$PWD/.., configure.py)

include(../config.pri)

Expand All @@ -19,7 +21,7 @@ QMAKE_STRIP = true

# Update the PK3 files.
!deng_nopackres {
system(cd $$PWD/scripts/ && python packres.py --quiet \"$$OUT_PWD/..\")
runPython2InDir($$PWD/scripts/, packres.py --quiet \"$$OUT_PWD/..\")
}

# Install the launcher.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/build/scripts/codex.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python2.7
# coding=utf-8
#
# Repository Codex Generator by <jaakko.keranen@iki.fi>
Expand Down
2 changes: 1 addition & 1 deletion doomsday/build/scripts/makehelp.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python2.7

import os, sys
import conhelp
Expand Down
2 changes: 1 addition & 1 deletion doomsday/build/scripts/packres.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python2.7
# This Python script will create a set of PK3 files that contain the files
# that Doomsday needs at runtime. The PK3 files are organized using the
# traditional data/ and defs/ structure.
Expand Down
2 changes: 1 addition & 1 deletion doomsday/build/scripts/wadcompiler.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python2.7

import sys, os.path, struct

Expand Down
6 changes: 3 additions & 3 deletions doomsday/build/win32/qmake_msvc.py
@@ -1,6 +1,6 @@
# qmake_msvc.py is a script that generates a full Visual Studio solution with
# a .vcxproj for each subproject. You must set up envconfig.bat before running
# the script. The solution is always placed in a folder called
# qmake_msvc.py is a Python 2 script that generates a full Visual Studio
# solution with a .vcxproj for each subproject. You must set up envconfig.bat
# before running the script. The solution is always placed in a folder called
# "doomsday-msvc-build" at the repository root.
#
# qmake_msvc.py must be called whenever the .pro/.pri files change. The .sln
Expand Down
61 changes: 5 additions & 56 deletions doomsday/config.pri
Expand Up @@ -47,67 +47,16 @@ DENG_MAC_INCLUDE_DIR = $$DENG_INCLUDE_DIR/macx
DENG_WIN_INCLUDE_DIR = $$DENG_INCLUDE_DIR/windows
DENG_MODULES_DIR = $$PWD/libdeng2/modules

# Versions -------------------------------------------------------------------

# Parse versions from the header files.
!exists(versions.pri): system(python configure.py)

include(versions.pri)

# Macros ---------------------------------------------------------------------

defineTest(echo) {
deng_verbosebuildconfig {
!win32 {
message($$1)
} else {
# We don't want to get the printed messages after everything else,
# so print to stdout.
system(echo $$1)
}
}
}
include(macros.pri)

defineTest(useLibDir) {
btype = ""
win32 {
deng_debug: btype = "/Debug"
else: btype = "/Release"
}
exists($${1}$${btype}) {
LIBS += -L$${1}$${btype}
export(LIBS)
return(true)
}
return(false)
}
# Versions -------------------------------------------------------------------

defineTest(doPostLink) {
isEmpty(QMAKE_POST_LINK) {
QMAKE_POST_LINK = $$1
} else {
QMAKE_POST_LINK = $$QMAKE_POST_LINK && $$1
}
export(QMAKE_POST_LINK)
}
# Parse versions from the header files.
!exists(versions.pri): runPython2(configure.py)

macx {
defineTest(removeQtLibPrefix) {
doPostLink("install_name_tool -change $$[QT_INSTALL_LIBS]/$$2 $$2 $$1")
}
defineTest(fixInstallName) {
# 1: binary file
# 2: library name
# 3: path to Frameworks/
removeQtLibPrefix($$1, $$2)
doPostLink("install_name_tool -change $$2 @executable_path/$$3/Frameworks/$$2 $$1")
}
defineTest(fixPluginInstallId) {
# 1: target name
# 2: version
doPostLink("install_name_tool -id @executable_path/../DengPlugins/$${1}.bundle/Versions/$$2/$$1 $${1}.bundle/Versions/$$2/$$1")
}
}
include(versions.pri)

# Build Options --------------------------------------------------------------

Expand Down
14 changes: 12 additions & 2 deletions doomsday/config_unix_any.pri
Expand Up @@ -36,11 +36,21 @@ deng_qt5 {

# Unix System Tools ----------------------------------------------------------

# Python to be used in generated scripts.
# Python 2 to be used in generated scripts.
isEmpty(SCRIPT_PYTHON) {
exists(/usr/bin/python): SCRIPT_PYTHON = /usr/bin/python
exists(/usr/bin/python2.7): SCRIPT_PYTHON = /usr/bin/python2.7
exists(/usr/bin/python2): SCRIPT_PYTHON = /usr/bin/python2
exists(/usr/bin/python): SCRIPT_PYTHON = /usr/bin/python
exists(/usr/local/bin/python): SCRIPT_PYTHON = /usr/local/bin/python
}
isEmpty(SCRIPT_PYTHON) {
# Check the system path.
SCRIPT_PYTHON = $$system(which python2.7)
}
isEmpty(SCRIPT_PYTHON) {
# Check the system path.
SCRIPT_PYTHON = $$system(which python2)
}
isEmpty(SCRIPT_PYTHON) {
# Check the system path.
SCRIPT_PYTHON = $$system(which python)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/configure.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python2.7
#
# Doomsday Build Configuration Script
#
Expand Down
66 changes: 66 additions & 0 deletions doomsday/macros.pri
@@ -0,0 +1,66 @@
# The Doomsday Engine Project
# Copyright (c) 2011-2014 Jaakko Keränen <jaakko.keranen@iki.fi>
# Copyright (c) 2011-2013 Daniel Swanson <danij@dengine.net>

defineTest(runPython2) {
win32: system(python $$1) # 2.7 still expected
else: system(python2.7 $$1)
}

defineTest(runPython2InDir) {
win32: system(cd "$$1" && python $$2)
else: system(cd "$$1" && python2.7 $$2)
}

defineTest(echo) {
deng_verbosebuildconfig {
!win32 {
message($$1)
} else {
# We don't want to get the printed messages after everything else,
# so print to stdout.
system(echo $$1)
}
}
}

defineTest(useLibDir) {
btype = ""
win32 {
deng_debug: btype = "/Debug"
else: btype = "/Release"
}
exists($${1}$${btype}) {
LIBS += -L$${1}$${btype}
export(LIBS)
return(true)
}
return(false)
}

defineTest(doPostLink) {
isEmpty(QMAKE_POST_LINK) {
QMAKE_POST_LINK = $$1
} else {
QMAKE_POST_LINK = $$QMAKE_POST_LINK && $$1
}
export(QMAKE_POST_LINK)
}

macx {
defineTest(removeQtLibPrefix) {
doPostLink("install_name_tool -change $$[QT_INSTALL_LIBS]/$$2 $$2 $$1")
}
defineTest(fixInstallName) {
# 1: binary file
# 2: library name
# 3: path to Frameworks/
removeQtLibPrefix($$1, $$2)
doPostLink("install_name_tool -change $$2 @executable_path/$$3/Frameworks/$$2 $$1")
}
defineTest(fixPluginInstallId) {
# 1: target name
# 2: version
doPostLink("install_name_tool -id @executable_path/../DengPlugins/$${1}.bundle/Versions/$$2/$$1 $${1}.bundle/Versions/$$2/$$1")
}
}

0 comments on commit c62f79d

Please sign in to comment.