Ejemplo n.º 1
0
    def initialize_options(self):
        global global_dist_directory
        # Don't use hard links when building source distribution.
        # It's great, apart from under VirtualBox where it falls
        # apart due to a bug
        try:
            del os.link
        except:
            pass

        if os.path.exists(P4_RELNOTES):
            self.deleteReleaseNotes()
        self.copyReleaseNotes()

        version = VersionInfo(".")

        distdir = global_dist_directory + version.getDistVersion()
        if os.path.exists(distdir):
            shutil.rmtree(distdir, False, self.force_remove_file)

        sdist_module.initialize_options(self)
Ejemplo n.º 2
0
def do_setup():
    global global_dist_directory
    global p4_extension

    p4_extension = Extension("P4API", ["P4API.cpp", "PythonClientAPI.cpp",
                                           "PythonClientUser.cpp", "SpecMgr.cpp",
                                           "P4Result.cpp",
                                           "PythonMergeData.cpp", "P4MapMaker.cpp",
                                           "PythonSpecData.cpp", "PythonMessage.cpp",
                                           "PythonActionMergeData.cpp", "PythonClientProgress.cpp",
                                           "P4PythonDebug.cpp"],
                                 include_dirs=[],
                                 library_dirs=[],
                                 libraries=[],
                                 extra_compile_args=[],
                                 define_macros=[],
                                 extra_link_args=[]
                                 )

    setup(name=NAME,
          version=VersionInfo(".").getDistVersion(),
          description=DESCRIPTION,
          author=AUTHOR,
          author_email=AUTHOR_EMAIL,
          maintainer=MAINTAINER,
          maintainer_email=MAINTAINER_EMAIL,
          license=LICENSE,
          url=URL,
          keywords=KEYWORDS,
          classifiers=[x for x in classifiers.split("\n") if x],
          long_description="\n".join(doclines[2:]),
          py_modules=PY_MODULES,
          ext_modules=[p4_extension],
          cmdclass={
              'build': p4build,
              'build_ext': p4build_ext,
              'sdist': p4build_sdist,
          }
          )
Ejemplo n.º 3
0
    def run(self, *args, **kwargs):
        global p4_api_dir, p4_ssl_dir, p4_ssl_ver, ssl_src, ssl_tarball, loaded_ssl_from_ftp, loaded_api_from_ftp
        global global_dist_directory
        global releaseVersion
        global p4_extension

        ssl_ver = ""
        if not p4_ssl_dir:
            if (not self.ssl) and (sys.platform == "linux" or sys.platform == "linux2"):
                # check for a version of SSL already installed via 'openssl version'
                self.ssl, ssl_ver = self.check_installed_ssl()  # return libpath or None

                # we only support 1.0.2 or 1.1.1 using 2019.1 p4api
                if not (("1.0.2" in ssl_ver) or ("1.1.1" in ssl_ver)):
                    self.ssl = ""

                if not self.ssl:
                    # try downloading and building ssl
                    if self.is_super():
                        (self.ssl, ssl_src, ssl_tarball, loaded_ssl_from_ftp) = self.build_ssl_lib(ssl_ver)
                        p4_ssl_dir = self.ssl
                        p4_ssl_ver = ssl_ver
                    else:
                        print("must be root to build and install SSL")

        if not self.ssl:
            print("***********************************************", file=sys.stderr)
            print("** Cannot build P4Python without SSL support **", file=sys.stderr)
            print("***********************************************", file=sys.stderr)
            raise Exception("Parameter --ssl is needed")
        p4_ssl_dir = self.ssl

        if not p4_api_dir:
            if (not self.apidir) and (sys.platform == "linux" or sys.platform == "linux2"):
                # Attempt to download P4 API which matches our versions
                (self.apidir, api_tarball) = self.download_p4api(VersionInfo(".").getVersion(), ssl_ver)
                p4_api_dir = self.apidir

        if not self.apidir:
            print("***********************************************", file=sys.stderr)
            print("** Cannot build P4Python without P4API       **", file=sys.stderr)
            print("***********************************************", file=sys.stderr)
            raise Exception("Parameter --apidir is needed")
        p4_api_dir = self.apidir

        try:
            apiVersion = VersionInfo(p4_api_dir)
            releaseVersion = VersionInfo(".")
        except IOError:
            print("Cannot find Version file in API dir {0}.".format(p4_api_dir))
            exit(1)

        ryear = int(apiVersion.release_year)
        rversion = int(apiVersion.release_version)
        global_dist_directory += releaseVersion.getDistVersion()

        if ryear < 2019:
            print("API Release %s.%s not supported by p4python, Minimum API requirement is 2019.1" % (ryear, rversion))
            print("Please download a more recent API release from the Perforce ftp site.")
            exit(1)
        else:
            print("Using API Release %s.%s" % (ryear, rversion))

        # monkey patch nt_quote_args (Only works in the debugger!)
        #spawn._nt_quote_args = monkey_nt_quote_args

        # add the paths for p4 headers and library
        inc_path = [str(os.path.join(p4_api_dir, "include", "p4"))]
        lib_path = [str(os.path.join(p4_api_dir, "lib")), str(p4_ssl_dir)]

        # check if the interpreter is mayapy.exe
        namedir = os.path.dirname(os.path.dirname(sys.executable))
        if "maya" in namedir.lower():
            inc_path.append(str(os.path.join(namedir, "include")))
            inc_path.append(str(os.path.join(namedir, "include", "python2.7")))
            lib_path.append(str(os.path.join(namedir, "lib")))

        info = PlatformInfo(apiVersion, releaseVersion, str(p4_ssl_dir), p4_ssl_ver)

        # Extend the extension specification with the new configuration
        p4_extension.include_dirs += inc_path
        p4_extension.library_dirs += lib_path
        p4_extension.libraries += info.libraries
        p4_extension.extra_compile_args += info.extra_compile_args
        p4_extension.define_macros += info.define_macros
        p4_extension.extra_link_args += info.extra_link_args
        build_ext_module.run(self, *args, **kwargs)