|
| 1 | +"""Module describing the planemo ``slurm_init`` command.""" |
| 2 | +import shutil |
| 3 | +import tempfile |
| 4 | + |
| 5 | +import click |
| 6 | + |
| 7 | +from planemo.cli import command_function |
| 8 | +from planemo.io import info, shell, untar_to |
| 9 | + |
| 10 | +SLRUM_DRMAA_VERSION = "1.1.4" |
| 11 | +DOWNLOAD_URL = f"https://github.com/natefoo/slurm-drmaa/releases/download/{SLRUM_DRMAA_VERSION}/slurm-drmaa-{SLRUM_DRMAA_VERSION}.tar.gz" |
| 12 | + |
| 13 | + |
| 14 | +@click.command("slurm_init") |
| 15 | +@command_function |
| 16 | +def cli(ctx, **kwds): |
| 17 | + """Initialize a copy of the SLURM DRMAA library.""" |
| 18 | + dest = f"{ctx.workspace}/libdrmaa.so" |
| 19 | + tempdir = tempfile.mkdtemp() |
| 20 | + tar_args = ["-zxf", "-", "--strip-components=1"] |
| 21 | + try: |
| 22 | + # This used to show the wget command (and in fact use wget), it doesn't anymore but |
| 23 | + # this should be restored. The point is to show developers what is happening and how to do it. |
| 24 | + untar_to(DOWNLOAD_URL, tar_args=tar_args, dest_dir=tempdir) |
| 25 | + shell(["mkdir", "dest"], cwd=tempdir) |
| 26 | + shell(["./autogen.sh"], cwd=tempdir) |
| 27 | + shell(["./configure", f"--prefix={tempdir}/dist"], cwd=tempdir) |
| 28 | + shell(["make"], cwd=tempdir) |
| 29 | + shell(["make install"], cwd=tempdir) |
| 30 | + shutil.move(f"{tempdir}/dist/lib/libdrmaa.so", dest) |
| 31 | + info(f"SLURM DRMAA library initialized successfully and copied to {dest}.") |
| 32 | + finally: |
| 33 | + shutil.rmtree(tempdir) |
0 commit comments