def __init__(self): if not VirtualEnv.Running() and VirtualEnv.Exists(): VirtualEnv.Activate() global buildSetup Task.buildSetup = self buildSetup = self self.pyVersionStr = "%d%d" % sys.version_info[:2] self.buildDir = abspath(join(dirname(__file__), "..")) self.sourceDir = abspath(join(self.buildDir, "..")) self.libraryName = "lib%s" % self.pyVersionStr self.libraryDir = join(self.sourceDir, self.libraryName) self.dataDir = join(self.buildDir, "data") self.docsDir = join(self.dataDir, "docs") self.pyVersionDir = join(self.dataDir, "Python%s" % self.pyVersionStr) self.outputDir = join(self.buildDir, "output") self.websiteDir = join(self.outputDir, "website") if Is64bitInterpreter(): print( "ERROR: Sorry, EventGhost can't be built with the 64-bit " "version of Python!" ) sys.exit(1) elif not exists(self.pyVersionDir): print( "ERROR: Sorry, EventGhost can't be built with Python %d.%d!" % sys.version_info[:2] ) sys.exit(1) sys.path.append(self.sourceDir) sys.path.append(join(self.libraryDir, "site-packages")) self.args = self.ParseArgs() self.showGui = not ( self.args.build or self.args.check or self.args.package or self.args.release or self.args.sync ) if os.environ.get( "APPVEYOR_REPO_COMMIT_MESSAGE", "" ).upper().startswith("VERBOSE:"): self.args.verbose = True os.chdir(self.buildDir) if not exists(self.outputDir): os.mkdir(self.outputDir) LogToFile(join(self.outputDir, "Build.log"), self.args.verbose) from CheckDependencies import CheckDependencies if not CheckDependencies(self): sys.exit(1) try: self.gitConfig = GetGitHubConfig() except Exception as e: msg = ( "WARNING: To change version or release to GitHub, you must:\n" " $ git config --global github.user <your github username>\n" " $ git config --global github.token <your github token>\n" "To create a token, go to: https://github.com/settings/tokens\n" ) if type(e) is ValueError: msg = "WARNING: Specified `github.token` is invalid!\n" + msg if not IsCIBuild(): token = "" print msg else: token = os.environ["GITHUB_TOKEN"] self.gitConfig = { "all_repos": { "EventGhost/EventGhost": { "all_branches": ["master"], "def_branch": "master", "name": "EventGhost", }, }, "branch": "master", "repo": "EventGhost", "repo_full": "EventGhost/EventGhost", "token": token, "user": "******", } self.appVersion = None self.appVersionInfo = None self.tmpDir = tempfile.mkdtemp() self.appName = self.name
def CheckDependencies(buildSetup): failedDeps = [] for dep in DEPENDENCIES: dep.buildSetup = buildSetup try: dep.Check() except (WrongVersion, MissingDependency): failedDeps.append(dep) if failedDeps and buildSetup.args.make_env and not os.environ.get("_REST"): if not IsAdmin(): print WrapText( "ERROR: Can't create virtual environment from a command " "prompt without administrative privileges." ) return False if not VirtualEnv.Running(): if not VirtualEnv.Exists(): print "Creating our virtual environment..." CreateVirtualEnv() print "" VirtualEnv.Activate() for dep in failedDeps[:]: print "Installing %s..." % dep.name try: if InstallDependency(dep): #and dep.Check(): failedDeps.remove(dep) else: print "ERROR: Installation of %s failed!" % dep.name except MissingChocolatey: print WrapText( "ERROR: To complete installation of this package, I need " "package manager Chocolatey, which wasn't found and " "couldn't be installed automatically. Please install it " "by hand and try again." ) except MissingPip: print WrapText( "ERROR: To complete installation of this package, I need " "package manager pip, which wasn't found. Note that " "all versions of Python capable of building EventGhost " "come bundled with pip, so please install a supported " "version of Python and try again." ) except MissingPowerShell: print WrapText( "ERROR: To complete installation of this package, I need " "package manager Chocolatey, which can't be installed " "without PowerShell. Please install PowerShell by hand " "and try again." ) print "" VirtualEnv.Restart() if failedDeps: print WrapText( "Before we can continue, the following dependencies must " "be installed:" ) print "" for dep in failedDeps: print " *", dep.name, dep.version if dep.url: print " Link:", dep.url print "" print WrapText( "Dependencies without an associated URL can be installed via " "`pip install [package-name]`. Dependencies in .whl format " "can be installed via `pip install [url]`. All other dependencies " "will need to be installed manually or via Chocolatey " "<https://chocolatey.org/>." ) if not buildSetup.args.make_env: print "" print WrapText( "Alternately, from a command prompt with administrative " "privileges, I can try to create a virtual environment for " "you that satisfies all dependencies via `%s %s --make-env`." % (basename(sys.executable).split(".")[0], sys.argv[0]) ) return not failedDeps