Exemplo n.º 1
0
  def _UnityPostBuild(*args, **kwargs):
    if sys.platform == "darwin":
      
      macos_dir = excons.joinpath(excons.OutputBaseDirectory(), PluginPrefix(pluginname, package=package))
      contents_dir = os.path.dirname(macos_dir)
      
      plist_path = excons.joinpath(contents_dir, "Info.plist")
      
      if not os.path.isfile(plist_path):
        plist_content = """
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>English</string>
	<key>CFBundleExecutable</key>
	<string>%s</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundlePackageType</key>
	<string>BNDL</string>
	<key>CFBundleSignature</key>
	<string>????</string>
	<key>CFBundleVersion</key>
	<string>1.0</string>
	<key>CSResourcesFileMapped</key>
	<string>yes</string>
</dict>
</plist>
""" % pluginname
        
        f = open(plist_path, "w")
        f.write(plist_content)
        f.close()
Exemplo n.º 2
0
def Plugin(target, libs=[], package=None):
    if not isinstance(target, dict):
        return

    if not "name" in target:
        return

    name = target["name"]

    prefix = PluginPrefix(name, package=package)

    post = target.get("post", [])
    post.append(PluginPost(name, package=package))

    install = target.get("install", {})
    if libs:
        libs_dir = excons.joinpath(excons.OutputBaseDirectory(), prefix)
        if sys.platform == "darwin":
            libs_dir = excons.joinpath(os.path.dirname(libs_dir), "Libraries")
        install[libs_dir] = libs

    target["ext"] = PluginExt()
    target["prefix"] = prefix
    target["install"] = install
    target["post"] = post
    # For linux, rpath defaults to $ORIGIN
    if sys.platform == "darwin":
        target["rpath"] = "../Libraries"
Exemplo n.º 3
0
def Plugin(target, libs=[], package=None):
  if not isinstance(target, dict):
    return
  
  if not "name" in target:
    return
  
  name = target["name"]

  prefix = PluginPrefix(name, package=package)
  
  post = target.get("post", [])
  post.append(PluginPost(name, package=package))
  
  install = target.get("install", {})
  if libs:
    libs_dir = excons.joinpath(excons.OutputBaseDirectory(), prefix)
    if sys.platform == "darwin":
      libs_dir = excons.joinpath(os.path.dirname(libs_dir), "Libraries")
    install[libs_dir] = libs
  
  target["ext"] = PluginExt()
  target["prefix"] = prefix
  target["install"] = install
  target["post"] = post
  # For linux, rpath defaults to $ORIGIN
  if sys.platform == "darwin":
    target["rpath"] = "../Libraries"
Exemplo n.º 4
0
def Version(asString=True, compat=False):
    mtoa_inc, mtoa_lib = excons.GetDirs(
        "mtoa", libdirname=("lib" if sys.platform == "win32" else "bin"))
    if mtoa_inc and mtoa_lib:
        versionh = excons.joinpath(mtoa_inc, "utils", "Version.h")
        varch, vmaj, vmin = 0, 0, 0
        if os.path.isfile(versionh):
            defexp = re.compile(
                r"^\s*#define\s+MTOA_(ARCH|MAJOR|MINOR)_VERSION_NUM\s+([^\s]+)"
            )
            f = open(versionh, "r")
            for line in f.readlines():
                m = defexp.match(line)
                if m:
                    which = m.group(1)
                    if which == "ARCH":
                        varch = int(m.group(2))
                    elif which == "MAJOR":
                        vmaj = int(m.group(2))
                    elif which == "MINOR":
                        vmin = int(m.group(2))
            f.close()
        if compat:
            rv = (varch, vmaj)
            return ("%s.%s" % rv if asString else rv)
        else:
            rv = (varch, vmaj, vmin)
            return ("%s.%s.%s" % rv if asString else rv)
    else:
        if compat:
            return ("0.0" if asString else (0, 0))
        else:
            return ("0.0.0" if asString else (0, 0, 0))
Exemplo n.º 5
0
def Version(asString=True, compat=False):
   mtoa_inc, mtoa_lib = excons.GetDirs("mtoa", libdirname=("lib" if sys.platform == "win32" else "bin"))
   if mtoa_inc and mtoa_lib:
      versionh = excons.joinpath(mtoa_inc, "utils", "Version.h")
      varch, vmaj, vmin = 0, 0, 0
      if os.path.isfile(versionh):
         defexp = re.compile(r"^\s*#define\s+MTOA_(ARCH|MAJOR|MINOR)_VERSION_NUM\s+([^\s]+)")
         f = open(versionh, "r")
         for line in f.readlines():
            m = defexp.match(line)
            if m:
               which = m.group(1)
               if which == "ARCH":
                  varch = int(m.group(2))
               elif which == "MAJOR":
                  vmaj = int(m.group(2))
               elif which == "MINOR":
                  vmin = int(m.group(2))
         f.close()
      if compat:
         rv = (varch, vmaj)
         return ("%s.%s" % rv if asString else rv)
      else:
         rv = (varch, vmaj, vmin)
         return ("%s.%s.%s" % rv if asString else rv)
   else:
      if compat:
         return ("0.0" if asString else (0, 0))
      else:
         return ("0.0.0" if asString else (0, 0, 0))
Exemplo n.º 6
0
def Version(asString=True, nice=False):
    vrayinc, _ = excons.GetDirs("vray")

    vraybase = excons.joinpath(vrayinc, "vraybase.h")

    if os.path.isfile(vraybase):
        defexp = re.compile(
            r"^\s*#define\s+VRAY_DLL_VERSION\s+(0x[a-fA-F0-9]+)")
        f = open(vraybase, "r")
        for line in f.readlines():
            m = defexp.match(line)
            if m:
                #rv = (int(m.group(1), 16) if not asString else m.group(1)[2:])
                rv = m.group(1)[2:]
                if nice:
                    iv = int(rv)
                    major = iv / 10000
                    minor = (iv % 10000) / 100
                    patch = iv % 100
                    rv = (major, minor, patch)
                    if asString:
                        rv = "%d.%d.%d" % rv
                else:
                    if not asString:
                        rv = int(rv)
                return rv
        f.close()

    return ("" if asString else (0 if not nice else (0, 0, 0)))
Exemplo n.º 7
0
def Version(asString=True, nice=False):
  vrayinc, _ = excons.GetDirs("vray")

  vraybase = excons.joinpath(vrayinc, "vraybase.h")
  
  if os.path.isfile(vraybase):
    defexp = re.compile(r"^\s*#define\s+VRAY_DLL_VERSION\s+(0x[a-fA-F0-9]+)")
    f = open(vraybase, "r")
    for line in f.readlines():
      m = defexp.match(line)
      if m:
        #rv = (int(m.group(1), 16) if not asString else m.group(1)[2:])
        rv = m.group(1)[2:]
        if nice:
          iv = int(rv)
          major = iv / 10000
          minor = (iv % 10000) / 100
          patch = iv % 100
          rv = (major, minor, patch)
          if asString:
            rv = "%d.%d.%d" % rv
        else:
          if not asString:
            rv = int(rv)
        return rv
    f.close()

  return ("" if asString else (0 if not nice else (0, 0, 0)))
Exemplo n.º 8
0
def Require(env):
  excons.AddHelpOptions(houdini=GetOptionsString())

  ver, hfs = GetVersionAndDirectory(noexc=True)
  if not ver or not hfs:
    return
  
  # Call hcustom -c, hcustom -m to setup compile and link flags
  
  hcustomenv = os.environ.copy()
  hcustomenv["HFS"] = hfs
  if sys.platform == "win32":
    # Oldver version of hcustom on windows require MSVCDir to be set
    cmntools = "VS%sCOMNTOOLS" % env["MSVC_VERSION"].replace(".", "")
    if cmntools in hcustomenv:
      cmntools = hcustomenv[cmntools]
      if cmntools.endswith("\\") or cmntools.endswith("/"):
        cmntools = cmntools[:-1]
      cmntools = excons.joinpath(os.path.split(os.path.split(cmntools)[0])[0], "VC")
      hcustomenv["MSVCDir"] = cmntools
  
  hcustom = "%s/bin/hcustom" % hfs
  
  cmd = "\"%s\" -c" % hcustom
  p = subprocess.Popen(cmd, shell=True, env=hcustomenv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  out, _ = p.communicate()
  ccflags = out.strip()
  if not "DLLEXPORT" in ccflags:
    if sys.platform == "win32":
      ccflags += ' /DDLLEXPORT="__declspec(dllexport)"'
    else:
      ccflags += ' -DDLLEXPORT='
  if sys.platform != "win32":
    if int(ver.split(".")[0]) >= 14:
      if not "-std=c++11" in ccflags:
        ccflags += ' -DBOOST_NO_DEFAULTED_FUNCTIONS -DBOOST_NO_DELETED_FUNCTIONS'
  
  cmd = "\"%s\" -m" % hcustom
  p = subprocess.Popen(cmd, shell=True, env=hcustomenv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  out, _ = p.communicate()
  linkflags = out.strip()
  if sys.platform == "win32":
    linkflags = re.sub(r"-link\s+", "", linkflags)
  elif sys.platform != "darwin":
    # On linux, $HFS/dsolib doesn't seem appear in linkflags
    linkflags += " -L %s/dsolib" % hfs
  else:
    # On OSX, linkflags does not provide frameworks or libraries to link
    libs = ["HoudiniUI", "HoudiniOPZ", "HoudiniOP3", "HoudiniOP2", "HoudiniOP1",
            "HoudiniSIM", "HoudiniGEO", "HoudiniPRM", "HoudiniUT"]
    
    libdir = "%s/Libraries" % "/".join(hfs.split("/")[:-1])
    linkflags += " -flat_namespace -L %s -l%s" % (libdir, " -l".join(libs))
  
  env.Append(CXXFLAGS=" %s" % ccflags)
  env.Append(LINKFLAGS=" %s" % linkflags)
Exemplo n.º 9
0
def Require(env):
  excons.AddHelpOptions(houdini=GetOptionsString())

  ver, hfs = GetVersionAndDirectory(noexc=True)
  if not ver or not hfs:
    return
  
  # Call hcustom -c, hcustom -m to setup compile and link flags
  
  hcustomenv = os.environ.copy()
  hcustomenv["HFS"] = hfs
  if sys.platform == "win32":
    # Oldver version of hcustom on windows require MSVCDir to be set
    cmntools = "VS%sCOMNTOOLS" % env["MSVC_VERSION"].replace(".", "")
    if cmntools in hcustomenv:
      cmntools = hcustomenv[cmntools]
      if cmntools.endswith("\\") or cmntools.endswith("/"):
        cmntools = cmntools[:-1]
      cmntools = excons.joinpath(os.path.split(os.path.split(cmntools)[0])[0], "VC")
      hcustomenv["MSVCDir"] = cmntools
  
  hcustom = "%s/bin/hcustom" % hfs
  
  cmd = "\"%s\" -c" % hcustom
  p = subprocess.Popen(cmd, shell=True, env=hcustomenv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  out, err = p.communicate()
  ccflags = out.strip()
  if not "DLLEXPORT" in ccflags:
    if sys.platform == "win32":
      ccflags += ' /DDLLEXPORT="__declspec(dllexport)"'
    else:
      ccflags += ' -DDLLEXPORT='
  if sys.platform != "win32":
    if int(ver.split(".")[0]) >= 14:
      if not "-std=c++11" in ccflags:
        ccflags += ' -DBOOST_NO_DEFAULTED_FUNCTIONS -DBOOST_NO_DELETED_FUNCTIONS'
  
  cmd = "\"%s\" -m" % hcustom
  p = subprocess.Popen(cmd, shell=True, env=hcustomenv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  out, err = p.communicate()
  linkflags = out.strip()
  if sys.platform == "win32":
    linkflags = re.sub(r"-link\s+", "", linkflags)
  elif sys.platform != "darwin":
    # On linux, $HFS/dsolib doesn't seem appear in linkflags
    linkflags += " -L %s/dsolib" % hfs
  else:
    # On OSX, linkflags does not provide frameworks or libraries to link
    libs = ["HoudiniUI", "HoudiniOPZ", "HoudiniOP3", "HoudiniOP2", "HoudiniOP1",
            "HoudiniSIM", "HoudiniGEO", "HoudiniPRM", "HoudiniUT"]
    
    libdir = "%s/Libraries" % "/".join(hfs.split("/")[:-1])
    linkflags += " -flat_namespace -L %s -l%s" % (libdir, " -l".join(libs))
  
  env.Append(CXXFLAGS=" %s" % ccflags)
  env.Append(LINKFLAGS=" %s" % linkflags)
Exemplo n.º 10
0
def _GetPythonVersionWIN(pythonPath):
  # On windows, pythonPath must be the path to the python executable
  # i.e.  with-python=C:/Python27/python.exe
  dn = os.path.dirname(pythonPath)
  fl = excons.glob(excons.joinpath(dn, "python*.dll"))
  if len(fl) == 1:
    m = re.match(r"python(\d)(\d)\.dll", os.path.basename(fl[0]), re.IGNORECASE)
    if m is not None:
      return "%s.%s" % (m.group(1), m.group(2))
  return None
Exemplo n.º 11
0
def _GetPythonVersionWIN(pythonPath):
  # On windows, pythonPath must be the path to the python executable
  # i.e.  with-python=C:/Python27/python.exe
  dn = os.path.dirname(pythonPath)
  fl = excons.glob(excons.joinpath(dn, "python*.dll"))
  if len(fl) == 1:
    m = re.match(r"python(\d)(\d)\.dll", os.path.basename(fl[0]), re.IGNORECASE)
    if m is not None:
      return "%s.%s" % (m.group(1), m.group(2))
  return None
Exemplo n.º 12
0
    def _UnityPostBuild(*args, **kwargs):
        if sys.platform == "darwin":

            macos_dir = excons.joinpath(
                excons.OutputBaseDirectory(),
                PluginPrefix(pluginname, package=package))
            contents_dir = os.path.dirname(macos_dir)

            plist_path = excons.joinpath(contents_dir, "Info.plist")

            if not os.path.isfile(plist_path):
                plist_content = """
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>English</string>
	<key>CFBundleExecutable</key>
	<string>%s</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundlePackageType</key>
	<string>BNDL</string>
	<key>CFBundleSignature</key>
	<string>????</string>
	<key>CFBundleVersion</key>
	<string>1.0</string>
	<key>CSResourcesFileMapped</key>
	<string>yes</string>
</dict>
</plist>
""" % pluginname

                f = open(plist_path, "w")
                f.write(plist_content)
                f.close()
Exemplo n.º 13
0
def Version(asString=True, nice=False):
    mayadir = GetMayaRoot(noWarn=True)
    if not mayadir:
        return (None if not asString else "")

    mayainc = GetMayaInc(mayadir)

    mayaspec = excons.GetArgument("with-maya")
    if mayaspec is not None and not os.path.isdir(mayaspec):
        wantedver = mayaspec
    else:
        wantedver = None

    mtypes = excons.joinpath(mayainc, "maya", "MTypes.h")

    if os.path.isfile(mtypes):
        defexp = re.compile(r"^\s*#define\s+MAYA_API_VERSION\s+([0-9]+)")
        f = open(mtypes, "r")
        for line in f.readlines():
            m = defexp.match(line)
            if m:
                year = int(m.group(1)[:4])
                sub = int(m.group(1)[4])
                if wantedver is not None:
                    usever = "%d%s" % (year, ".5" if sub >= 5 else "")
                    if usever != wantedver:
                        excons.WarnOnce(
                            "Maya headers version (%s) doesn't seem to match requested one (%s).\nMake sure to set or reset devkit path using 'with-mayadevkit=' flag."
                            % (usever, wantedver))
                if nice:
                    # Maya 2013 and 2016 have a binary incompatible .5 version
                    if sub >= 5 and year in (2013, 2016):
                        return (year + 0.5 if not asString else "%d.5" % year)
                    else:
                        return (year if not asString else str(year))
                else:
                    return (int(m.group(1)) if not asString else m.group(1))
        f.close()

    excons.WarnOnce("Cannot find maya headers (missing with-mayadevkit= ?).")
    return (None if not asString else "")
Exemplo n.º 14
0
def Version(asString=True, compat=False):
    arnoldinc, _ = excons.GetDirs(
        "arnold", libdirname=("bin" if sys.platform != "win32" else "lib"))

    if arnoldinc is None:
        if compat:
            return ("0.0" if asString else (0, 0))
        else:
            return ("0.0.0.0" if asString else (0, 0, 0, 0))

    ai_version = excons.joinpath(arnoldinc, "ai_version.h")

    varch, vmaj, vmin, vpatch = 0, 0, 0, 0

    if os.path.isfile(ai_version):
        defexp = re.compile(
            r"^\s*#define\s+AI_VERSION_(ARCH_NUM|MAJOR_NUM|MINOR_NUM|FIX)\s+([^\s]+)"
        )
        f = open(ai_version, "r")
        for line in f.readlines():
            m = defexp.match(line)
            if m:
                which = m.group(1)
                if which == "ARCH_NUM":
                    varch = int(m.group(2))
                elif which == "MAJOR_NUM":
                    vmaj = int(m.group(2))
                elif which == "MINOR_NUM":
                    vmin = int(m.group(2))
                elif which == "FIX":
                    m = re.search(r"\d+", m.group(2))
                    vpatch = (0 if m is None else int(m.group(0)))
        f.close()

    rv = (varch, vmaj, vmin, vpatch)

    if compat:
        cv = (rv[0], rv[1])
        return ("%s.%s" % cv if asString else cv)
    else:
        return ("%s.%s.%s.%s" % rv if asString else rv)
Exemplo n.º 15
0
def Version(asString=True, nice=False):
  mayadir = GetMayaRoot(noWarn=True)
  if not mayadir:
    return (None if not asString else "")
  
  mayainc = GetMayaInc(mayadir)
  
  mayaspec = excons.GetArgument("with-maya")
  if mayaspec is not None and not os.path.isdir(mayaspec):
    wantedver = mayaspec
  else:
    wantedver = None
  
  mtypes = excons.joinpath(mayainc, "maya", "MTypes.h")
  
  if os.path.isfile(mtypes):
    defexp = re.compile(r"^\s*#define\s+MAYA_API_VERSION\s+([0-9]+)")
    f = open(mtypes, "r")
    for line in f.readlines():
      m = defexp.match(line)
      if m:
        year = int(m.group(1)[:4])
        sub = int(m.group(1)[4])
        if wantedver is not None:
          usever = "%d%s" % (year, ".5" if sub >= 5 else "")
          if usever != wantedver:
            excons.WarnOnce("Maya headers version (%s) doesn't seem to match requested one (%s).\nMake sure to set or reset devkit path using 'with-mayadevkit=' flag." % (usever, wantedver))
        if nice:
          # Maya 2013 and 2016 have a binary incompatible .5 version
          if sub >= 5 and year in (2013, 2016):
            return (year+0.5 if not asString else "%d.5" % year)
          else:
            return (year if not asString else str(year))
        else:
          return (int(m.group(1)) if not asString else m.group(1))
    f.close()
  
  excons.WarnOnce("Cannot find maya headers (missing with-mayadevkit= ?).")
  return (None if not asString else "")
Exemplo n.º 16
0
def GetPath(name):
    return excons.joinpath(excons.out_dir, "%s.status" % name)
Exemplo n.º 17
0
def _GetPythonSpec(specString):
  global _specCache

  if specString in _specCache:
    return _specCache[specString]

  spec = None
  specErr = ""

  plat = str(Platform())

  if re.match(r"\d+\.\d+", specString):
    ver = specString

    # Look in standard locations

    if plat == "darwin":
      searchPaths = ["/System/Library/Frameworks", "/Library/Frameworks"]
      for searchPath in searchPaths:
        pythonPath = excons.joinpath(searchPath, "Python.framework", "Versions", ver)
        if os.path.isdir(pythonPath):
          incdir = None
          for isd in ("include/python%s" % ver, "Headers"):
            _incdir = pythonPath + "/" + isd
            if os.path.isdir(_incdir):
              incdir = _incdir
              break
          if incdir is not None:
            if ver == _GetPythonVersionOSX(excons.joinpath(searchPath, "Python.framework")):
              spec = (ver, incdir, searchPath, "Python")
              specErr = ""
              break
            else:
              spec = (ver, incdir, None, "%s/Python" % (pythonPath))
              specErr = ""
              break
          else:
            specErr += "\n  Cannot find python %s include directory in %s" % (ver, pythonPath)
        else:
          specErr += "\n  Cannot find python %s in %s" % (ver, searchPath)

    elif plat == "win32":
      pythonPath = "C:\\Python%s" % ver.replace(".", "")
      if os.path.isdir(pythonPath):
        incdir = excons.joinpath(pythonPath, "include")
        libdir = excons.joinpath(pythonPath, "libs")
        lib = "python%s" % ver.replace(".", "")
        spec = (ver, incdir, libdir, lib)

    else:
      searchPaths = ["/usr", "/usr/local"]
      for searchPath in searchPaths:
        pythonPath = excons.joinpath(searchPath, "bin", "python%s" % ver)
        if not os.path.isfile(pythonPath):
          pythonPath = excons.joinpath(searchPath, "python")
          if os.path.isfile(pythonPath) and _GetPythonVersionUNIX() == ver:
            spec = (ver, searchPath)
            break
        else:
          spec = (ver, searchPath)
          break

      if spec:
        ver, prefix = spec
        incdir = excons.joinpath(prefix, "include", "python%s" % ver)
        libdir = excons.joinpath(prefix, ("lib64" if excons.Build64() else "lib"))
        lib = "python%s" % ver
        spec = (ver, incdir, libdir, lib)

    if spec is None:
      curver = str(sysconfig.get_python_version())
      specErr += "\n"
      if curver != ver:
        excons.PrintOnce("Couldn't find stock python %s.%sCurrent version doesn't match (%s), aborting build." % (ver, specErr, curver), tool="python")
        sys.exit(1)
      else:
        excons.PrintOnce("Couldn't find stock python %s.%sUse currently running version instead." % (ver, specErr), tool="python")

  else:
    if plat == "darwin":
      if specString[-1] == "/":
        specString = specString[:-1]
      m = re.search(r"/([^/]+)\.framework/Versions/([^/]+)/?$", specString)
      if m:
        fwn = m.group(1)
        ver = m.group(2)
        fw = "%s/%s" % (specString, fwn)
        fwh = "%s/Headers" % specString
        if not os.path.isdir(fwh):
          fwh = "%s/include/python%s" % (specString, ver)
        if os.path.isfile(fw) and os.path.isdir(fwh):
          # if it is the current version, use framework directory
          fwd = re.sub(r"/Versions/.*$", "", specString)
          if ver == _GetPythonVersionOSX(fwd):
            spec = (ver, fwh, os.path.dirname(fwd), fwn)
          else:
            spec = (ver, fwh, None, fw)
        else:
          if not os.path.isfile(fwh):
            specErr += "\n  Cannot find python %s include directory in %s" % (ver, specString)
          if not os.path.isfile(fw):
            specErr += "\n  Cannot find python framework in %s" % specString
      else:
        ver = _GetPythonVersionOSX(specString)
        if ver is not None:
          d = os.path.dirname(specString)
          n = os.path.splitext(os.path.basename(specString))[0]
          incdir = None
          for isd in ("include/python%s" % ver, "Headers"):
            _incdir = "%s/Versions/%s/%s" % (specString, ver, isd)
            if os.path.isdir(_incdir):
              incdir = _incdir
              break
          if incdir is not None:
            spec = (ver, incdir, d, n)
          else:
            specErr += "\n  Cannot find python %s include directory in %s" % (ver, specString)
    
    elif plat == "win32":
      ver = _GetPythonVersionWIN(specString)
      if ver is not None:
        d = os.path.dirname(specString)
        incdir = excons.joinpath(d, "include")
        libdir = excons.joinpath(d, "libs")
        lib = "python%s" % ver.replace(".", "")
        spec = (ver, incdir, libdir, lib)
    
    else:
      ver = _GetPythonVersionUNIX(specString)
      if ver is not None:
        # not specString but 2 dirs up (as specString is the path to the python executable)
        d = os.path.dirname(specString)
        if os.path.basename(d) == "bin":
          d = os.path.dirname(d)
          incdir = excons.joinpath(d, "include", "python%s" % ver)
          libdir = excons.joinpath(d, ("lib64" if excons.Build64() else "lib"))
          lib = "python%s" % ver
          spec = (ver, incdir, libdir, lib)
    
    if spec is None:
      specErr += "\n"
      excons.PrintOnce("Invalid python specification \"%s\".%sAborting build." % (specErr, specString), tool="python")
      sys.exit(1)

  # check setup validity
  if spec is not None:
    if plat == "darwin":
      _, incdir, fwdir, fw = spec
      if fwdir is None:
        # directly linking version specific framework
        if not os.path.isdir(incdir) or not os.path.isfile(fw):
          spec = None
      else:
        if not os.path.isdir(incdir) or not os.path.isdir(fwdir):
          spec = None
    else:
      ver, incdir, libdir, lib = spec
      if not os.path.isdir(incdir) or not os.path.isdir(libdir):
        spec = None
      else:
        if plat == "win32":
          if not os.path.isfile(excons.joinpath(libdir, "%s.lib" % lib)):
            spec = None
        else:
          if not os.path.isfile(os.path.join(libdir, "lib%s.so" % lib)):
            spec = None
    
    if spec is None:
      excons.PrintOnce("Invalid python specification \"%s\". Aborting build." % specString, tool="python")
      sys.exit(1)
  
  excons.PrintOnce("Resolved python for \"%s\": %s" % (specString, ('<current>' if spec is None else spec)), tool="python")
  
  _specCache[specString] = spec

  return spec
Exemplo n.º 18
0
def GetPath(name):
   return excons.joinpath(excons.out_dir, "%s.status" % name)
Exemplo n.º 19
0
def _GetPythonSpec(specString):
    global _specCache

    if specString in _specCache:
        return _specCache[specString]

    spec = None
    specErr = ""

    plat = str(SCons.Script.Platform())

    if re.match(r"\d+\.\d+", specString):
        ver = specString

        # Look in standard locations

        if plat == "darwin":
            searchPaths = ["/System/Library/Frameworks", "/Library/Frameworks"]
            for searchPath in searchPaths:
                pythonPath = excons.joinpath(searchPath, "Python.framework",
                                             "Versions", ver)
                if os.path.isdir(pythonPath):
                    incdir = None
                    for isd in ("include/python%s" % ver, "Headers"):
                        _incdir = pythonPath + "/" + isd
                        if os.path.isdir(_incdir):
                            incdir = _incdir
                            break
                    if incdir is not None:
                        if ver == _GetPythonVersionOSX(
                                excons.joinpath(searchPath,
                                                "Python.framework")):
                            spec = (ver, incdir, searchPath, "Python")
                            specErr = ""
                            break
                        else:
                            spec = (ver, incdir, None,
                                    "%s/Python" % (pythonPath))
                            specErr = ""
                            break
                    else:
                        specErr += "\n  Cannot find python %s include directory in %s" % (
                            ver, pythonPath)
                else:
                    specErr += "\n  Cannot find python %s in %s" % (ver,
                                                                    searchPath)

        elif plat == "win32":
            pythonPath = "C:\\Python%s" % ver.replace(".", "")
            if os.path.isdir(pythonPath):
                incdir = excons.joinpath(pythonPath, "include")
                libdir = excons.joinpath(pythonPath, "libs")
                lib = "python%s" % ver.replace(".", "")
                spec = (ver, incdir, libdir, lib)

        else:
            searchPaths = ["/usr", "/usr/local"]
            for searchPath in searchPaths:
                pythonPath = excons.joinpath(searchPath, "bin",
                                             "python%s" % ver)
                if not os.path.isfile(pythonPath):
                    pythonPath = excons.joinpath(searchPath, "python")
                    if os.path.isfile(pythonPath) and _GetPythonVersionUNIX(
                            pythonPath) == ver:
                        spec = (ver, searchPath)
                        break
                else:
                    spec = (ver, searchPath)
                    break

            if spec:
                ver, prefix = spec
                incdir = excons.joinpath(prefix, "include", "python%s" % ver)
                libdir = excons.joinpath(
                    prefix, ("lib64" if excons.Build64() else "lib"))
                lib = "python%s" % ver
                spec = (ver, incdir, libdir, lib)

        if spec is None:
            curver = str(distutils.sysconfig.get_python_version())
            specErr += "\n"
            if curver != ver:
                excons.PrintOnce(
                    "Couldn't find stock python %s.%sCurrent version doesn't match (%s), aborting build."
                    % (ver, specErr, curver),
                    tool="python")
                sys.exit(1)
            else:
                excons.PrintOnce(
                    "Couldn't find stock python %s.%sUse currently running version instead."
                    % (ver, specErr),
                    tool="python")

    else:
        if plat == "darwin":
            if specString[-1] == "/":
                specString = specString[:-1]
            m = re.search(r"/([^/]+)\.framework/Versions/([^/]+)/?$",
                          specString)
            if m:
                fwn = m.group(1)
                ver = m.group(2)
                fw = "%s/%s" % (specString, fwn)
                fwh = "%s/Headers" % specString
                if not os.path.isdir(fwh):
                    fwh = "%s/include/python%s" % (specString, ver)
                if os.path.isfile(fw) and os.path.isdir(fwh):
                    # if it is the current version, use framework directory
                    fwd = re.sub(r"/Versions/.*$", "", specString)
                    if ver == _GetPythonVersionOSX(fwd):
                        spec = (ver, fwh, os.path.dirname(fwd), fwn)
                    else:
                        spec = (ver, fwh, None, fw)
                else:
                    if not os.path.isfile(fwh):
                        specErr += "\n  Cannot find python %s include directory in %s" % (
                            ver, specString)
                    if not os.path.isfile(fw):
                        specErr += "\n  Cannot find python framework in %s" % specString
            else:
                ver = _GetPythonVersionOSX(specString)
                if ver is not None:
                    d = os.path.dirname(specString)
                    n = os.path.splitext(os.path.basename(specString))[0]
                    incdir = None
                    for isd in ("include/python%s" % ver, "Headers"):
                        _incdir = "%s/Versions/%s/%s" % (specString, ver, isd)
                        if os.path.isdir(_incdir):
                            incdir = _incdir
                            break
                    if incdir is not None:
                        spec = (ver, incdir, d, n)
                    else:
                        specErr += "\n  Cannot find python %s include directory in %s" % (
                            ver, specString)

        elif plat == "win32":
            ver = _GetPythonVersionWIN(specString)
            if ver is not None:
                d = os.path.dirname(specString)
                incdir = excons.joinpath(d, "include")
                libdir = excons.joinpath(d, "libs")
                lib = "python%s" % ver.replace(".", "")
                spec = (ver, incdir, libdir, lib)

        else:
            ver = _GetPythonVersionUNIX(specString)
            if ver is not None:
                # not specString but 2 dirs up (as specString is the path to the python executable)
                d = os.path.dirname(specString)
                if os.path.basename(d) == "bin":
                    d = os.path.dirname(d)
                    incdir = excons.joinpath(d, "include", "python%s" % ver)
                    libdir = excons.joinpath(
                        d, ("lib64" if excons.Build64() else "lib"))
                    lib = "python%s" % ver
                    spec = (ver, incdir, libdir, lib)

        if spec is None:
            specErr += "\n"
            excons.PrintOnce(
                "Invalid python specification \"%s\".%sAborting build." %
                (specErr, specString),
                tool="python")
            sys.exit(1)

    # check setup validity
    if spec is not None:
        if plat == "darwin":
            _, incdir, fwdir, fw = spec
            if fwdir is None:
                # directly linking version specific framework
                if not os.path.isdir(incdir) or not os.path.isfile(fw):
                    spec = None
            else:
                if not os.path.isdir(incdir) or not os.path.isdir(fwdir):
                    spec = None
        else:
            ver, incdir, libdir, lib = spec
            if not os.path.isdir(incdir) or not os.path.isdir(libdir):
                spec = None
            else:
                if plat == "win32":
                    if not os.path.isfile(
                            excons.joinpath(libdir, "%s.lib" % lib)):
                        spec = None
                else:
                    if not os.path.isfile(
                            os.path.join(libdir, "lib%s.so" % lib)):
                        spec = None

        if spec is None:
            excons.PrintOnce(
                "Invalid python specification \"%s\". Aborting build." %
                specString,
                tool="python")
            sys.exit(1)

    excons.PrintOnce("Resolved python for \"%s\": %s" %
                     (specString, ('<current>' if spec is None else spec)),
                     tool="python")

    _specCache[specString] = spec

    return spec
Exemplo n.º 20
0
def MakeBundle(target=None, source=None, env=None):
  binaryPath = str(target[0])
  
  excons.PrintOnce("MakeBundle for \"%s\"" % binaryPath, tool="openfx")
  
  outPath = excons.joinpath(os.path.dirname(binaryPath), "openfx")
  ofxName = os.path.basename(binaryPath)
  BundleDir = excons.joinpath(outPath, ofxName+".bundle")
  ContentsDir = excons.joinpath(BundleDir, "Contents")
  
  try:
    os.makedirs(ContentsDir)
  except:
    pass
  
  BinaryDir = None
  
  if sys.platform == "darwin":
    plistPath = excons.joinpath(ContentsDir, "Info.plist")
    plist = """
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>%s</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleVersion</key>
<string>1.0</string>
</dict>
</plist>
""" % ofxName
    
    f = open(plistPath, "w")
    f.write(plist)
    f.close()
    
    if env["TARGET_ARCH"] == "x64" and "OFX_NEW_PACKAGE" in env and env["OFX_NEW_PACKAGE"]:
      BinaryDir = excons.joinpath(ContentsDir, "MacOS-x86-64")
      
    else:
      BinaryDir = excons.joinpath(ContentsDir, "MacOS")
  
  elif sys.platform in ["win32", "cygwin"]:
    #if pyplat.architecture()[0] == '64bit':
    if env["TARGET_ARCH"] == "x64":
      BinaryDir = excons.joinpath(ContentsDir, "Win64")
      
    else:
      BinaryDir = excons.joinpath(ContentsDir, "Win32")
  
  else:
    #if pyplat.architecture()[0] == '64bit':
    if env["TARGET_ARCH"] == "x64":
      BinaryDir = excons.joinpath(ContentsDir, "Linux-x86-64")
      
    else:
      BinaryDir = excons.joinpath(ContentsDir, "Linux-x86")
  
  try:
    os.mkdir(BinaryDir)
  except:
    pass
  
  shutil.copy(binaryPath, BinaryDir)
  
  # Doesn't seem to work
  env.Clean(target, BundleDir)
Exemplo n.º 21
0
def MakeBundle(target=None, source=None, env=None):
    binaryPath = str(target[0])

    excons.PrintOnce("MakeBundle for \"%s\"" % binaryPath, tool="openfx")

    outPath = excons.joinpath(os.path.dirname(binaryPath), "openfx")
    ofxName = os.path.basename(binaryPath)
    BundleDir = excons.joinpath(outPath, ofxName + ".bundle")
    ContentsDir = excons.joinpath(BundleDir, "Contents")

    try:
        os.makedirs(ContentsDir)
    except:
        pass

    BinaryDir = None

    if sys.platform == "darwin":
        plistPath = excons.joinpath(ContentsDir, "Info.plist")
        plist = """
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>%s</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleVersion</key>
<string>1.0</string>
</dict>
</plist>
""" % ofxName

        f = open(plistPath, "w")
        f.write(plist)
        f.close()

        if env["TARGET_ARCH"] == "x64" and "OFX_NEW_PACKAGE" in env and env[
                "OFX_NEW_PACKAGE"]:
            BinaryDir = excons.joinpath(ContentsDir, "MacOS-x86-64")

        else:
            BinaryDir = excons.joinpath(ContentsDir, "MacOS")

    elif sys.platform in ["win32", "cygwin"]:
        #if pyplat.architecture()[0] == '64bit':
        if env["TARGET_ARCH"] == "x64":
            BinaryDir = excons.joinpath(ContentsDir, "Win64")

        else:
            BinaryDir = excons.joinpath(ContentsDir, "Win32")

    else:
        #if pyplat.architecture()[0] == '64bit':
        if env["TARGET_ARCH"] == "x64":
            BinaryDir = excons.joinpath(ContentsDir, "Linux-x86-64")

        else:
            BinaryDir = excons.joinpath(ContentsDir, "Linux-x86")

    try:
        os.mkdir(BinaryDir)
    except:
        pass

    shutil.copy(binaryPath, BinaryDir)

    # Doesn't seem to work
    env.Clean(target, BundleDir)