in package.py [0:0]
def execute() -> None:
expected_cwd = os.path.abspath(os.path.dirname(__file__))
os.chdir(expected_cwd)
if not os.path.exists("libs"):
os.makedirs("libs")
if not os.path.exists("blobs"):
os.makedirs("blobs")
argument_parser = argparse.ArgumentParser(
"Builds CycleCloud GridEngine project with all dependencies.\n"
+ "If you don't specify local copies of scalelib or cyclecloud-api they will be downloaded from github."
)
argument_parser.add_argument("--scalelib", default=None)
argument_parser.add_argument("--cyclecloud-api", default=None)
args = argument_parser.parse_args()
cycle_packages = get_cycle_packages(args)
parser = configparser.ConfigParser()
ini_path = os.path.abspath("project.ini")
with open(ini_path) as fr:
parser.read_file(fr)
version = parser.get("project", "version")
if not version:
raise RuntimeError("Missing [project] -> version in {}".format(ini_path))
tf = tarfile.TarFile.gzopen(
"blobs/cyclecloud-pbspro-pkg-{}.tar.gz".format(version), "w"
)
build_dir = tempfile.mkdtemp("cyclecloud-pbspro")
def _add(name: str, path: Optional[str] = None, mode: Optional[int] = None) -> None:
path = path or name
tarinfo = tarfile.TarInfo("cyclecloud-pbspro/" + name)
tarinfo.size = os.path.getsize(path)
tarinfo.mtime = int(os.path.getmtime(path))
if mode:
tarinfo.mode = mode
with open(path, "rb") as fr:
tf.addfile(tarinfo, fr)
packages = []
for dep in cycle_packages:
dep_path = os.path.abspath(os.path.join("blobs" if "cyclecloud_api" in dep else "libs", dep))
_add("packages/" + dep, dep_path)
packages.append(dep_path)
check_call(["pip", "download"] + packages, cwd=build_dir)
print("Using build dir", build_dir)
by_package: Dict[str, List[str]] = {}
for fil in os.listdir(build_dir):
toks = fil.split("-", 1)
package = toks[0]
if "pyyaml" in fil.lower():
print("Ignoring pyyaml as it is not needed and is platform specific")
os.remove(os.path.join(build_dir, fil))
continue
if "itsdangerous" in fil.lower():
print("Ignoring itsdangerous as it is not needed and is platform specific")
os.remove(os.path.join(build_dir, fil))
continue
if package == "cyclecloud":
package = "{}-{}".format(toks[0], toks[1])
if package not in by_package:
by_package[package] = []
by_package[package].append(fil)
for package, fils in by_package.items():
if len(fils) > 1:
print("WARNING: Ignoring duplicate package found:", package, fils)
assert False
for fil in os.listdir(build_dir):
path = os.path.join(build_dir, fil)
_add("packages/" + fil, path)
_add("install.sh", mode=os.stat("install.sh")[0])
_add("initialize_pbs.sh", mode=os.stat("initialize_pbs.sh")[0])
_add("initialize_default_queues.sh", mode=os.stat("initialize_default_queues.sh")[0])
_add("generate_autoscale_json.sh", mode=os.stat("generate_autoscale_json.sh")[0])
_add("server_dyn_res_wrapper.sh", mode=os.stat("server_dyn_res_wrapper.sh")[0])
_add("autoscale_hook.py", "pbspro/conf/autoscale_hook.py")
_add("logging.conf", "pbspro/conf/logging.conf")
print("Downloading release files...")
download_release_files()