Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-8560: Port sconsUtils to Python 3 #32

Merged
merged 4 commits into from
Jul 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion python/lsst/sconsUtils/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def SwigLoadableModule(self, target, source, **keywords):
pass
return myenv.LoadableModule(target, source, **keywords)


# @brief Like LoadableModule, but don't insist that all symbols are resolved, and set
# some pybind11-specific flags.
@memberOf(SConsEnvironment)
Expand Down Expand Up @@ -496,7 +497,7 @@ def VersionModule(self, filename, versionString=None):
def calcMd5(filename):
try:
import hashlib
md5 = hashlib.md5("\n".join(open(filename).readlines())).hexdigest()
md5 = hashlib.md5(open(filename, "rb").read()).hexdigest()
except IOError:
md5 = None

Expand Down
3 changes: 2 additions & 1 deletion python/lsst/sconsUtils/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def get(self, name, default=None):
return self.packages.get(name)

def keys(self):
k = self.packages.keys()
k = list(self.packages.keys())
k.append(self.name)
return k

Expand Down Expand Up @@ -584,6 +584,7 @@ def getLibs(env, categories="main"):
pass
return libs


SConsEnvironment.getLibs = getLibs

## @}
1 change: 1 addition & 0 deletions python/lsst/sconsUtils/eupsForScons.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
def haveEups():
return eupsLoaded


if not haveEups():
#
# Fake what we can so sconsUtils can limp along without eups
Expand Down
1 change: 1 addition & 0 deletions python/lsst/sconsUtils/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from stat import ST_MODE
from SCons.Script import SConscript, File, Dir, Glob, BUILD_TARGETS
from distutils.spawn import find_executable
from past.builtins import basestring

from . import dependencies
from . import state
Expand Down
13 changes: 9 additions & 4 deletions python/lsst/sconsUtils/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def ClassifyCc(context):
"parentheses": "equality comparison with extraneous parentheses",
"shorten-64-to-32": "implicit conversion loses integer precision",
"self-assign": "x = x",
"unused-local-typedefs": "unused typedef", # lots from boost
"unused-local-typedefs": "unused typedef", # lots from boost
"unknown-pragmas": "unknown pragma ignored",
"deprecated-register": "register is deprecated",
}
Expand Down Expand Up @@ -449,21 +449,26 @@ def _saveState():
if env.GetOption("clean"):
return

import ConfigParser
# Python 2 uses ConfigParser, Python 3 uses configparser
try:
from configparser import ConfigParser
except ImportError:
from ConfigParser import ConfigParser

config = ConfigParser.ConfigParser()
config = ConfigParser()
config.add_section('Build')
config.set('Build', 'cc', env.whichCc)
if env['opt']:
config.set('Build', 'opt', env['opt'])

try:
confFile = os.path.join(env.Dir(env["CONFIGUREDIR"]).abspath, "build.cfg")
with open(confFile, 'wb') as configfile:
with open(confFile, 'w') as configfile:
config.write(configfile)
except Exception as e:
log.warn("Unexpected exception in _saveState: %s" % e)


_initOptions()
_initLog()
_initVariables()
Expand Down
1 change: 1 addition & 0 deletions python/lsst/sconsUtils/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import re
import sys
from past.builtins import basestring
from SCons.Script import * # So that this file has the same namespace as SConstruct/SConscript
from . import state
from . import utils
Expand Down
7 changes: 5 additions & 2 deletions python/lsst/sconsUtils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def flush(self):

##
# @brief Internal function indicating that the OS has System
# Integrity Protection.
# Integrity Protection.
##
def _has_OSX_SIP():
hasSIP = False
Expand All @@ -67,6 +67,7 @@ def _has_OSX_SIP():
##
# @brief Returns name of library path environment variable to be passed through
# or else returns None if no pass through is required on this platform.
##
def libraryPathPassThrough():
if _has_OSX_SIP():
return "DYLD_LIBRARY_PATH"
Expand All @@ -83,6 +84,7 @@ def libraryPathPassThrough():
# SCons. Caches result and assumes the PATH does not change between
# calls. Runs the "python" command and asks where it is rather than
# scanning the PATH.
##
def whichPython():
global _pythonPath
if _pythonPath is None:
Expand Down Expand Up @@ -136,6 +138,7 @@ def libraryLoaderEnvironment():
# @brief Safe wrapper for running external programs, reading stdout, and sanitizing error messages.
#
# Note that the entire program output is returned, not just a single line.
# @returns Strings not bytes.
##
def runExternal(cmd, fatal=False, msg=None):
if msg is None:
Expand All @@ -151,7 +154,7 @@ def runExternal(cmd, fatal=False, msg=None):
else:
from . import state # can't import at module scope due to circular dependency
state.log.warn("%s: %s" % (msg, stderr))
return stdout
return stdout.decode()


##
Expand Down