From 0c1a60370c82babd7919c0131fa393c3c74f35b9 Mon Sep 17 00:00:00 2001 From: Nathan Kern Date: Thu, 6 Mar 2025 19:01:38 -0500 Subject: [PATCH] Add stanalyzer package --- recipes/stanalyzer/__init__.py | 1 + recipes/stanalyzer/build_base.sh | 9 ++ recipes/stanalyzer/conda_build_config.yaml | 8 ++ recipes/stanalyzer/install.py | 56 ++++++++++ recipes/stanalyzer/meta.yaml | 114 +++++++++++++++++++++ 5 files changed, 188 insertions(+) create mode 100644 recipes/stanalyzer/__init__.py create mode 100644 recipes/stanalyzer/build_base.sh create mode 100644 recipes/stanalyzer/conda_build_config.yaml create mode 100644 recipes/stanalyzer/install.py create mode 100644 recipes/stanalyzer/meta.yaml diff --git a/recipes/stanalyzer/__init__.py b/recipes/stanalyzer/__init__.py new file mode 100644 index 0000000000000..bc080941b1417 --- /dev/null +++ b/recipes/stanalyzer/__init__.py @@ -0,0 +1 @@ +from .install import finish_install diff --git a/recipes/stanalyzer/build_base.sh b/recipes/stanalyzer/build_base.sh new file mode 100644 index 0000000000000..1d26287bab65a --- /dev/null +++ b/recipes/stanalyzer/build_base.sh @@ -0,0 +1,9 @@ +if [ "$PKG_NAME" == "stanalyzer-dev" ]; then + # just copy files necessary for post-installer + mkdir $SP_DIR/stanalyzer + cp $SRC_DIR/conda.build/install.py $SP_DIR/stanalyzer + cp $SRC_DIR/conda.build/__init__.py $SP_DIR/stanalyzer +else + export SETUPTOOLS_SCM_PRETEND_VERSION="$PKG_VERSION" + ${PYTHON} -m pip install --no-deps --ignore-installed . +fi diff --git a/recipes/stanalyzer/conda_build_config.yaml b/recipes/stanalyzer/conda_build_config.yaml new file mode 100644 index 0000000000000..024229f895f4d --- /dev/null +++ b/recipes/stanalyzer/conda_build_config.yaml @@ -0,0 +1,8 @@ +python_min: + - "3.10" +numpy: + - 1.26 +channel_sources: + - conda-forge +channel_targets: + - conda-forge stanalyzer_dev diff --git a/recipes/stanalyzer/install.py b/recipes/stanalyzer/install.py new file mode 100644 index 0000000000000..71f2a992882ec --- /dev/null +++ b/recipes/stanalyzer/install.py @@ -0,0 +1,56 @@ +import os +import sys + +pip_e_URL = "https://pip.pypa.io/en/stable/topics/local-project-installs" +\ + "/#editable-installs" +repo = "git@github.com:nk53/stanalyzer.git" + + +def _run_or_die(cmd): + if result := os.system(cmd): + print(cmd[:10], '... failed with status', result, file=sys.stderr) + print("Exiting...", file=sys.stderr) + sys.exit(result) + + +def finish_install(): + saveas = 'stanalyzer' + + prog, args = os.path.basename(sys.argv.pop(0)), sys.argv + match args: + case []: + print("This will clone the git repository and install it as an 'editable' package.") + print("Read here for more info:") + print(" ", pip_e_URL) + print() + try: + saveas = input(f"Desired repository save path (default: {saveas}): ") or saveas + except KeyboardInterrupt: + print() + sys.exit(1) + case '-q': + pass + case '-h' | '--help': + print(f"Usage: {prog} [-h] [-q | -p SAVE_PATH]", file=sys.stderr) + sys.exit(0) + case ['-p', saveas]: + pass + case _: + print(f"Usage: {prog} [-h] [-q | -p SAVE_PATH]", file=sys.stderr) + sys.exit(1) + + cmds = [ + f"git clone {repo} {saveas}", + f"pip install --no-deps --ignore-installed --editable {saveas}", + ] + + for cmd in cmds: + print("Running:", cmd) + _run_or_die(cmd) + + print("Removing temporary stanalyzer dir from site-packages") + import stanalyzer + sta_dir = stanalyzer.__path__[0] + _run_or_die(f"rm -rv {sta_dir}") + + print("Done") diff --git a/recipes/stanalyzer/meta.yaml b/recipes/stanalyzer/meta.yaml new file mode 100644 index 0000000000000..6fd4cee009658 --- /dev/null +++ b/recipes/stanalyzer/meta.yaml @@ -0,0 +1,114 @@ +{%- set base = "stanalyzer" -%} +{%- set short = "sta" -%} +{%- set tag = "1.0.0dev1" -%} +{%- set version = tag|replace('-', '_') -%} + + +package: + name: {{ base }}-metapkg + version: {{ version }} + +source: + url: https://github.com/nk53/stanalyzer/archive/refs/tags/v{{ tag }}.tar.gz + sha256: cff3a28af7defe0c335cf7ddee68fee7244dc918a63dd32985330fe655d09f25 + +build: + number: 0 + noarch: python + +requirements: + host: + - python ={{ python_min }} + - setuptools >=64 + - setuptools_scm >=8 + - pip + +outputs: + - name: {{ base }} + script: build_base.sh + requirements: + build: + - python ={{ python_min }} + - setuptools >=64 + - setuptools_scm >=8 + - pip + run: + - python >={{ python_min }} + - mdanalysis =2.7 + - paramiko =3.5 + - fabric =3.2 + - invoke =2.2 + - pyyaml =6.0 + - fastapi =0.115 + - uvicorn =0.32 + - jinja2 =3.1 + - sqlmodel >=0.0.22 + - email-validator =2.2 + - python-multipart >=0.0.17 + - numpy + run_constrained: + - hole2 =2.3 + - freesasa =2.2 + - dssp + entry_points: + - {{ base }} = {{ base }}.cli.{{ base }}:main + - {{ short }}-server = {{ base }}.cli.{{ base }}:run_server + test: + imports: + - {{ base }} + - {{ base }}.cli.{{ base }} + commands: + - {{ base }} -h + - {{ base }} system_size -h + - name: {{ base }}-dev + script: build_base.sh + requirements: + build: + - python ={{ python_min }} + - setuptools >=64 + - setuptools_scm >=8 + - pip + run: + - python >={{ python_min }} + - mdanalysis =2.7 + - paramiko =3.5 + - fabric =3.2 + - invoke =2.2 + - pyyaml =6.0 + - pylsp-mypy =0.6 + - sphinx =8.1 + - sphinx-js =3.2 + - fastapi =0.115 + - uvicorn =0.32 + - jinja2 =3.1 + - sqlmodel >=0.0.22 + - email-validator =2.2 + - python-multipart >=0.0.17 + run_constrained: + - hole2 =2.3 + - freesasa =2.2 + - dssp + entry_points: + - {{ base }} = {{ base }}.cli.{{ base }}:main + - {{ short }}-server = {{ base }}.cli.{{ base }}:run_server + - {{ short }}-finish-install = {{ base }}:finish_install + test: + imports: + - {{ base }} + +about: + home: https://github.com/nk53/{{ base }} + license: MIT + license_file: LICENSE + license_url: https://github.com/nk53/{{ base }}/blob/{{ short }}/LICENSE + summary: Command-line and web interface for common simulation trajectory analysis + description: | + An extensible framework for analyzing molecular dynamics simulation trajectories. Several analysis programs are provided, and sophisticated users can add their own analysis types. + dev_url: https://github.com/nk53/{{ base }} + doc_url: https://github.com/nk53/{{ base }}/blob/{{ short }}/README.md + doc_source_url: https://github.com/nk53/{{ base }}/blob/{{ short }}/README.md + +extra: + recipe-maintainers: + - nk53 + feedstock-name: stanalyzer