def setup(*args, **kwargs): if len(sys.argv) == 1: t0 = datetime.datetime.now() builddir = tempfile.mkdtemp(prefix="c4-") output("build in {}", builddir) pkg_info = find_lib(kwargs["name"]) if pkg_info and os.path.exists(pkg_info): output("read build info from {}", pkg_info) info = json.load(open(pkg_info, "r")) else: info = {} upgrade_pip() upgrade_wheel() core4_source = kwargs.pop("core4", CORE4_SOURCE) core4_commit = upgrade_framework(builddir, info.get("core4_commit", None), core4_source) proj_version = kwargs.get("version", None) proj_commit = upgrade_package(info.get("project_commit", None), proj_version) proj_branch = check_output( ["git", "rev-parse", "--abbrev-ref", "HEAD"], universal_newlines=True).strip() pkg_info = find_lib(kwargs["name"]) output("remove build directory {}", builddir) shutil.rmtree(builddir) delta = datetime.datetime.now() - t0 if pkg_info: if not TEST: output("write build info {}", pkg_info) json.dump( { "core4_commit": core4_commit, "core4_source": core4_source, "project_commit": proj_commit, "project_branch": proj_branch, "project_version": kwargs.get("version", None), "timestamp": str(datetime.datetime.utcnow()), "runtime": delta.total_seconds() }, open(pkg_info, "w")) else: output("failed to write build info") output("runtime {} ({}')", delta, int(delta.total_seconds())) else: if "CORE4_CALL" not in os.environ: output("ERROR!\nuse with $ python setup.py") else: check_requirements() kwargs["cmdclass"] = { 'build_py': BuildPyCommand, 'develop': DevelopCommand } orig_setup(**kwargs)
def setup(name, **attrs): if 'name' not in attrs: attrs['name'] = name if 'license' not in attrs: attrs['license'] = 'AGPL' if 'author_email' not in attrs: attrs['author_email'] = '*****@*****.**' if 'author' not in attrs: attrs['author'] = 'Univention GmbH' if 'url' not in attrs: attrs['url'] = 'https://www.univention.de/' if 'version' not in attrs: attrs['version'] = _get_version() if 'description' not in attrs: attrs['description'] = _get_description(name) return orig_setup(**attrs)
def setup(*args, **kwargs): if len(sys.argv) == 1: t0 = datetime.datetime.now() rlib = os.path.join(os.path.dirname(sys.executable), RLIB) if not os.path.exists(rlib): output("create {}", rlib) if not TEST: os.mkdir(rlib) os.chmod(rlib, 0o777) builddir = tempfile.mkdtemp(prefix="c4-") output("build in {}", builddir) pkg_info = find_lib(kwargs["name"]) if pkg_info and os.path.exists(pkg_info): output("read build info from {}", pkg_info) prev = json.load(open(pkg_info, "r")) else: prev = {"core4": {}, "project": {}} upgrade_pip() upgrade_wheel() core4_source = kwargs.get("core4", CORE4_SOURCE) request = { "core4": { "commit": get_git_commit(core4_source), "source": core4_source, "webapps": CORE4_FE == 2 }, "project": { "commit": check_output(["git", "rev-parse", "HEAD"], universal_newlines=True).strip(), "branch": check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"], universal_newlines=True).strip(), "version": kwargs.get("version", None), "webapps": CORE4_FE != 0 }, "timestamp": datetime.datetime.now().isoformat(), "runtime": None } upgrade_core4 = 0 if kwargs.get("name") != "core4": force = (prev["core4"].get("webapps", None) != request["core4"]["webapps"]) if upgrade_framework(builddir=builddir, source=request["core4"]["source"], installed_commit=prev["core4"].get( "commit", None), latest_commit=request["core4"]["commit"], force=force): upgrade_core4 = 1 force = (prev["project"].get("webapps", None) != request["project"]["webapps"]) upgrade_project = 0 if upgrade_package(installed_commit=prev["project"].get( "commit", None), latest_commit=request["project"]["commit"], force=force): upgrade_project = 2 pkg_info = find_lib(kwargs["name"]) output("remove build directory {}", builddir) shutil.rmtree(builddir) delta = datetime.datetime.now() - t0 request["runtime"] = delta.total_seconds() if pkg_info: if not TEST: output("write build info {}", pkg_info) json.dump(request, open(pkg_info, "w")) else: output("failed to write build info") output("runtime {} ({}')", delta, int(delta.total_seconds())) upgrade = upgrade_core4 + upgrade_project if upgrade == 0: output("result: no changes") elif upgrade == 1: output("result: upgrade core4os") elif upgrade == 2: output("result: upgrade project") else: output("result: upgrade core4os and project") from rpy2.robjects.packages import importr, isinstalled r_requirements = "r.txt" if not os.path.exists(r_requirements): with open(r_requirements, 'w+', encoding="utf-8") as file: file.write('mongolite\nfeather') with open(r_requirements, 'r') as file: data = file.read() packages_required = data.split(sep='\n') utils = importr('utils') utils.chooseCRANmirror(ind=1) for package in packages_required: if package is not None and package != "": output('Checking package: {}', package) output('Installed?: {}', isinstalled(package, lib_loc=rlib)) if not (isinstalled(package, lib_loc=rlib)): utils.install_packages(package, lib=rlib, verbose=False, quiet=True) sys.exit(upgrade) else: check_requirements() kwargs["cmdclass"] = { 'build_py': BuildPyCommand, 'develop': DevelopCommand } orig_setup(**kwargs) try: import core4 except: core4_source = kwargs.get("core4", CORE4_SOURCE) pip_main("install", "git+" + core4_source)
def setup(*args, **kwargs): if len(sys.argv) == 1: t0 = datetime.datetime.now() rlib = os.path.join(os.path.dirname(sys.executable), RLIB) if not os.path.exists(rlib): output("create {}", rlib) if not TEST: os.mkdir(rlib) os.chmod(rlib, 0o777) builddir = tempfile.mkdtemp(prefix="c4-") output("build in {}", builddir) pkg_info = find_lib(kwargs["name"]) if pkg_info and os.path.exists(pkg_info): output("read build info from {}", pkg_info) prev = json.load(open(pkg_info, "r")) else: prev = {"core4": {}, "project": {}} upgrade_pip() upgrade_wheel() core4_source = kwargs.get("core4", CORE4_SOURCE) request = { "core4": { "commit": get_git_commit(core4_source), "source": core4_source, "webapps": CORE4_FE == 2 }, "project": { "commit": check_output( ["git", "rev-parse", "HEAD"], universal_newlines=True).strip(), "branch": check_output( ["git", "rev-parse", "--abbrev-ref", "HEAD"], universal_newlines=True).strip(), "version": kwargs.get("version", None), "webapps": CORE4_FE != 0 }, "timestamp": datetime.datetime.now().isoformat(), "runtime": None } upgrade_core4 = 0 if kwargs.get("name") != "core4": force = (prev["core4"].get("webapps", None) != request["core4"]["webapps"]) if upgrade_framework( builddir=builddir, source=request["core4"]["source"], installed_commit=prev["core4"].get("commit", None), latest_commit=request["core4"]["commit"], force=force): upgrade_core4 = 1 force = (prev["project"].get("webapps", None) != request["project"]["webapps"]) upgrade_project = 0 if upgrade_package( installed_commit=prev["project"].get("commit", None), latest_commit=request["project"]["commit"], force=force): upgrade_project = 2 pkg_info = find_lib(kwargs["name"]) output("remove build directory {}", builddir) shutil.rmtree(builddir) delta = datetime.datetime.now() - t0 request["runtime"] = delta.total_seconds() if pkg_info: if not TEST: output("write build info {}", pkg_info) json.dump(request, open(pkg_info, "w")) else: output("failed to write build info") output("runtime {} ({}')", delta, int(delta.total_seconds())) upgrade = upgrade_core4 + upgrade_project if upgrade == 0: output("result: no changes") elif upgrade == 1: output("result: upgrade core4os") elif upgrade == 2: output("result: upgrade project") else: output("result: upgrade core4os and project") try: install_r_packages(rlib) except Exception: output("R package installation failed ... R not installed?") sys.exit(upgrade) else: check_requirements() kwargs["cmdclass"] = { 'build_py': BuildPyCommand, 'develop': DevelopCommand } orig_setup(**kwargs) try: import core4 except: core4_source = kwargs.get("core4", CORE4_SOURCE) pip_main("install", "git+" + core4_source)