Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
36980da
Add POST support (including json request bodies) to WSGI support.
albu-diku Sep 23, 2025
15769f0
Allow declaring expected error log messages.
albu-diku Sep 23, 2025
25c67db
Add support for adding request contextual data to configuration objects.
albu-diku Jul 25, 2025
a0dd8ee
Introduce support for jinja2-based templates.
albu-diku Jan 20, 2025
2a918ed
addendum to previous: contain template rendering within the templates…
albu-diku Oct 6, 2025
9747194
Cover peersactionwith a basic test.
albu-diku Nov 5, 2025
f3b72e7
Heavily extend (any|every)thing peer related within accountreq.
albu-diku Nov 5, 2025
fb6f4ca
make common the identical parts of ONWRITE and ONREAD hints selection
albu-diku Nov 27, 2025
2e9404c
Cnvert template support code to package loading.
albu-diku Dec 7, 2025
4767bb0
do all template cache directory ahead of time during priming
albu-diku Dec 8, 2025
1c64c10
explicitly create configuration for testing of tempate defaults
albu-diku Dec 13, 2025
be42efa
repair support for html fragments in the output path and test the res…
albu-diku Dec 15, 2025
4e89125
Expose template rendering via a handler.
albu-diku Oct 6, 2025
e94ec0f
fixup: ensure tmplinterface works when called via the cgi-bin
albu-diku Dec 15, 2025
9d32c7c
serve html from tmplinterface
albu-diku Dec 15, 2025
5a19288
make tmplinterface accessible via cgi
albu-diku Dec 15, 2025
88aa950
Wire the ability to specify a template cache dir through shared/install.
albu-diku Dec 17, 2025
868cf40
avoid config loading reaching out for log file in the templates cli
albu-diku Dec 15, 2025
3c25607
template cli: repair prime and restore a "cache" command. add tests
albu-diku Dec 17, 2025
17e2ccd
rework the tests added for the CLI
albu-diku Dec 29, 2025
d3f2f59
repair the first peersaction test
albu-diku Jan 11, 2026
ea318f8
Place the priming code into a method attached to TemplateStore.
albu-diku Jan 9, 2026
99ef38e
rework tmplinterface
albu-diku Jan 7, 2026
e9410e6
Get tmplinterface returning accepted peers and cover with real data.
albu-diku Jan 11, 2026
6c0ec9c
Get requested peers being returned via tmplinterface.
albu-diku Jan 12, 2026
3e4ce03
switch tmpl interface tests to snapshots
albu-diku Feb 11, 2026
9ef037f
add datainterface
albu-diku Jan 7, 2026
2d11181
datainterface - implement /peer/new and alwats return JSON with a status
albu-diku Jan 19, 2026
31ac353
Implement the deletion of accepted peers.
albu-diku Jan 25, 2026
c1d34e8
restore test suite to full function (also meaning peersaction itself)
albu-diku Jan 27, 2026
ee9bcbd
Handle peer deletion as a bulk POST to a .../delete endpoint.
albu-diku Jan 29, 2026
2d359dc
Unify the lack of a need to prefix routes between (data|tmpl)interface.
albu-diku Jan 29, 2026
f420cf0
Define peers UI backend routes as though overrides for the migux pack…
albu-diku Jan 29, 2026
fb460cf
update datainerface documentation
albu-diku Jan 29, 2026
f243b3a
Pull out much of the finer grained user test support code into a user…
albu-diku Feb 2, 2026
9653df7
Place the error key at the top level and nest a data key in JSON resp…
albu-diku Feb 2, 2026
1c95859
Decide a location for peers app assets and reference its bootstrap.
albu-diku Dec 13, 2025
6b39dd0
implement the peers summary endpoint
albu-diku Feb 5, 2026
ccb239c
Set only the necessary content-type header across (data|tmpl)interface
albu-diku Feb 5, 2026
1df30e8
Enforce a header check when expecting JSON responses via content_format.
albu-diku Feb 5, 2026
835245c
Remove unused import.
albu-diku Feb 5, 2026
0cd41a5
Remove repetetive boilerplate from all (data|tmpl)interface tests.
albu-diku Feb 5, 2026
1fc072b
Switch provisioning of pending peers over to taking a DN argument.
albu-diku Feb 6, 2026
2727ff9
WIP peer acceptance
albu-diku Feb 6, 2026
5a80ccc
fix logger local in accountreq
albu-diku Feb 13, 2026
ae56a4f
fix condtional attr access in shared/configuration
albu-diku Feb 13, 2026
c8e9797
fix condtional attr access in datainterface
albu-diku Feb 13, 2026
325054a
fixup - shared/configuration
albu-diku Feb 13, 2026
c0af8f1
Implement deletion of requested peers.
albu-diku Feb 14, 2026
ef32bb0
Provide well contained user peers and user pending peers assertions.
albu-diku Feb 15, 2026
3b71982
Remove the pending user entry when we reject the peer.
albu-diku Feb 15, 2026
81906ae
rename test support pending user retrieval
albu-diku Feb 15, 2026
cb1bb2c
Cover peer creation and removal of the pending user file on accept.
albu-diku Feb 15, 2026
77b693f
Get migux package installed automatically across all local invocations.
albu-diku Feb 23, 2026
c54d92f
replace calling out to wget with download via urllib3
albu-diku Feb 24, 2026
44fbae5
replace calling out to unip with the use of zipfile
albu-diku Feb 24, 2026
bc3126c
urllib3 in local reqs
albu-diku Feb 24, 2026
e574394
Axe unused tests and improve comments in datainterface.
albu-diku Feb 24, 2026
8099311
restore wget fetch but tie its use to an argument
albu-diku Mar 5, 2026
dd7a10f
Move to a feature specific requirement file for migux.
albu-diku Mar 9, 2026
3db7cdd
support writing the indexurls to a file
albu-diku Mar 11, 2026
642b0a6
fixup
albu-diku Mar 13, 2026
cbfaf9a
Always use fresh packages and allow for postinstall (add one for migux).
albu-diku Mar 15, 2026
08f980c
Be more straightforward when setting templates values from a config.
albu-diku Mar 19, 2026
3c0a9cc
Make config file arugment required in templates CLI.
albu-diku Mar 20, 2026
036d209
Arrange covering empty templates base packages from config and fix it.
albu-diku Mar 20, 2026
489343d
enable migux by default
albu-diku Mar 21, 2026
b4d2c14
Add a comment for a new commit id.
albu-diku Mar 22, 2026
d847268
Nudge to latest version.
albu-diku Mar 25, 2026
b7f2a43
Nudge to latest version.
albu-diku Mar 25, 2026
ce4c90f
Switch local package installation to a single local file url.
albu-diku Mar 27, 2026
6829b42
Nudge to latest version.
albu-diku Mar 27, 2026
5c27b73
Nudge to latest version.
albu-diku Mar 27, 2026
d94b039
Attempt to persuade dumb-pypi to execute within GitHub actions.
albu-diku Mar 30, 2026
3343a93
Restore fixturesupp chunk lost to rebase.
albu-diku Mar 30, 2026
4e49075
Remove duplication due to rebase.
albu-diku Mar 30, 2026
24bd023
Axe wrapper properties for config vars within accountreq tests.
albu-diku Mar 30, 2026
f513bb9
Axe remnants of earlier iterations from tmplinterface.
albu-diku Mar 30, 2026
d9e1a5a
Fix some fallout from splitting peersaction.
albu-diku Mar 30, 2026
d0ec87c
try to account for image differences in CI
albu-diku Mar 30, 2026
2897eb3
maybe?
albu-diku Mar 30, 2026
cca97bf
Are we hitting differences between the CI targets?
albu-diku Mar 31, 2026
f11e0f2
Ensure the base now date will always allow month replacement.
albu-diku Mar 31, 2026
4781843
Avoid a variable that can be two types to appease linter.
albu-diku Mar 31, 2026
1e1ef79
Avoid a variable that can be two types to appease linter.
albu-diku Mar 31, 2026
37c6cd7
Align some request handling basics across data and tmpl interfaces.
albu-diku Mar 31, 2026
4a49e4a
alignment 2/x
albu-diku Mar 31, 2026
1a3988f
repair invoke in local dev environments
albu-diku Mar 31, 2026
d69b53a
Remove arg fiddling in tmplinterface and use explicit tmpl route vari…
albu-diku Apr 1, 2026
0eb04b3
Fix tmplinterface test case name.
albu-diku Apr 1, 2026
7bbe9ac
Rework template handlers for direct return of render info.
albu-diku Apr 2, 2026
17d053f
Use "staging" as the name for the dir serving that purpose within env…
albu-diku Apr 4, 2026
4cc1a52
Repair "Rework template handlers for direct return of render info."
albu-diku Apr 4, 2026
61ed761
Restore filtering of peer listings.
albu-diku Apr 4, 2026
fa6be5b
Repair make unittest after 'Use "staging" as the name for the dir...'.
albu-diku Apr 5, 2026
33372d6
Further refinement to plugin interface and a bunch of polish.
albu-diku Apr 5, 2026
b986e21
Relocate RuntimeConfiguration to align with further iterations.
albu-diku Apr 7, 2026
74794b2
strip out the _send_email function pointer
albu-diku Apr 8, 2026
3c1d32f
Align to RuntimeConfiguration as a proxy object.
albu-diku Apr 8, 2026
f63279c
Rework email send as a reference in context and provide its fake.
albu-diku Apr 8, 2026
0850eec
Repair email sending in peersaction thus activating it for datainterf…
albu-diku Apr 8, 2026
ddd3bfb
Use a flag to make peer processing work as before by default.
albu-diku Apr 9, 2026
392661a
Overhaul peer validation thereby restoring checking lost during rebase.
albu-diku Apr 11, 2026
7a059ee
Return 400 status codes when a failure occurs during a new peer creat…
albu-diku Apr 11, 2026
00a1faf
appease checks on CI by reworking some code for pylint's benefit alone
albu-diku Apr 11, 2026
c328b40
Add documentation to datainterface and module header to tmplinterface.
albu-diku Apr 12, 2026
cc11131
Unify the common portions of request coalescing into a reqinfo lib.
albu-diku Apr 13, 2026
d0bbc05
pull out the one-off peer_user_dict given there is a better alternative
albu-diku Apr 14, 2026
3d7958f
use a better on disk fixture format for the single peer fixture
albu-diku Apr 15, 2026
0e7eb10
Add support for filtering by expire.
albu-diku Apr 15, 2026
9b7f06b
contain the AND and OR supporting search within tmplinterface
albu-diku Apr 15, 2026
3e64788
support requested peers filtering by kind
albu-diku Apr 15, 2026
8aafb86
Nudge to latest version.
albu-diku Apr 15, 2026
7192706
patch booleanify so its resilient against in-practice data
albu-diku Apr 16, 2026
66c9ae8
Nudge to latest version.
albu-diku Apr 16, 2026
6582cf8
cover peer import support in peersaction
albu-diku Apr 20, 2026
8c717d6
restore the peers import route
albu-diku Apr 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ jobs:
dnf install -y python3 python3-pip make
- name: Setup environment
run: |
make dependencies
make PYTHON_BIN=python3 dependencies
- name: Run tests
run: |
make unittest
make PYTHON_BIN=python3 unittest

python3-rocky9:
name: Run internal tests in default python3 on Rocky9
Expand All @@ -111,7 +111,7 @@ jobs:
dnf install -y python3 python3-pip make
- name: Setup environment
run: |
make dependencies
make PYTHON_BIN=python3 dependencies
- name: Run tests
run: |
make unittest
make PYTHON_BIN=python3 unittest
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Byte-compiled / optimized / DLL files
__jinja__/
__pycache__/
*.py[cod]
*$py.class
Expand Down Expand Up @@ -27,6 +28,9 @@ wheels/
*.egg
MANIFEST

# Plugins
mig/assets/migux/

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
Expand Down Expand Up @@ -182,6 +186,7 @@ mig/images/site-conf.js

# self-test
/envhelp/output/
/envhelp/staging/
/envhelp/venv/
/envhelp/*.depends
/envhelp/*.imageid
Expand Down
31 changes: 26 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ FORMAT_ENFORCE_DIRS = state/
FORMAT_EXCLUDE_REGEX = '.*'
FORMAT_EXCLUDE_GLOB = '*'
FORMAT_LINE_LENGTH = 80

LOCAL_PYTHON_BIN = './envhelp/lpython'
ROOT_DIR=$(realpath .)
STAGING_DIR="$(ROOT_DIR)/envhelp/staging"

ifdef PYTHON_BIN
LOCAL_PYTHON_BIN = $(PYTHON_BIN)
else
PYTHON_BIN = './envhelp/python3'
endif


ifeq ($(ALLDEPS),1)
REQS_PATH = ./recommended.txt
else
Expand Down Expand Up @@ -81,6 +83,7 @@ clean:
distclean: clean
@rm -rf ./envhelp/venv
@rm -rf ./envhelp/output
@rm -rf ./envhelp/staging
@rm -rf ./tests/__pycache__
@rm -f ./tests/*.pyc

Expand All @@ -101,18 +104,36 @@ testconfig: ./envhelp/output/testconfs
./envhelp/output/testconfs:
@./envhelp/makeconfig test --docker
@./envhelp/makeconfig test
@echo "prime any configured templates"
@$(LOCAL_PYTHON_BIN) -m mig.lib.templates prime \
-c ./envhelp/output/testconfs-local/MiGserver.conf

ifeq ($(MIG_ENV),'local')
./envhelp/local.depends: $(REQS_PATH) local-requirements.txt
else
./envhelp/local.depends: $(REQS_PATH)
endif
ifeq ($(MIG_ENV),'local')
@echo "installing development dependencies"
@$(LOCAL_PYTHON_BIN) -m pip install \
-r local-requirements.txt
@echo "expanding local packages"
@$(LOCAL_PYTHON_BIN) ./envhelp/scripts/expand_sources.py
@echo "generating local package index"
@./envhelp/invoke dumb-pypi \
--package-list "$(STAGING_DIR)/.packages.lst" \
--packages-url='../..' \
--output-dir "$(STAGING_DIR)"
endif
@echo "installing dependencies from $(REQS_PATH)"
@$(LOCAL_PYTHON_BIN) -m pip install -r $(REQS_PATH)
ifeq ($(MIG_ENV),'local')
@echo ""
@echo "installing development dependencies"
@$(LOCAL_PYTHON_BIN) -m pip install -r local-requirements.txt
@echo "installing plugins"
@$(LOCAL_PYTHON_BIN) -m pip install \
-r ./mig/install/requirements/migux-requirements.txt \
--extra-index-url="file://$(STAGING_DIR)/simple"
@echo "running plugins postinstall"
@$(LOCAL_PYTHON_BIN) ./mig/install/postinstall/migux-postinstall
endif
@touch ./envhelp/local.depends

Expand All @@ -121,4 +142,4 @@ endif
@/usr/bin/env python3 -m venv ./envhelp/venv
@rm -f ./envhelp/local.depends
@echo "upgrading venv pip as required for some dependencies"
@./envhelp/venv/bin/pip3 install --upgrade pip
@$(LOCAL_PYTHON_BIN) -m pip install --upgrade pip
8 changes: 8 additions & 0 deletions envhelp/docker/Dockerfile.py3
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ WORKDIR /usr/src/app
COPY requirements.txt local-requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt -r local-requirements.txt

# insert dist files for our local packages
RUN mkdir -p ./envhelp
COPY ./envhelp/staging ./envhelp/staging
COPY ./mig/install/requirements ./envhelp/requirements
RUN pip install --no-cache-dir \
--index-url=file:///usr/src/app/envhelp/staging/simple \
-r ./envhelp/requirements/migux-requirements.txt

CMD [ "python", "--version" ]
7 changes: 6 additions & 1 deletion envhelp/dpython
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ IMAGEID_STORED=$(cat "$DOCKER_IMAGEID_FILE" 2>/dev/null || echo "")
# explicit statement of the uid for use within the container for clarity
CONTAINER_USER_UID=$LOCAL_USER_UID

IMAGEID=$(${DOCKER_BIN} build -f "$DOCKER_FILE" . -q --build-arg "pyver=$PYVER" --build-arg "CONTAINER_USER_UID=$CONTAINER_USER_UID")
IMAGEID=$(${DOCKER_BIN} build -f "$DOCKER_FILE" . -q \
--build-arg "pyver=$PYVER" \
--build-arg "CONTAINER_USER_UID=$CONTAINER_USER_UID" \
--build-arg "EXTRA_INDEX_URL=$EXTRA_INDEX_URL" \
)

if [ "$IMAGEID" != "$IMAGEID_STORED" ]; then
echo "rebuilt for changes"

Expand Down
49 changes: 49 additions & 0 deletions envhelp/invoke
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh
#
# --- BEGIN_HEADER ---
#
# python3 - wrapper to invoke a local python3 virtual environment
# Copyright (C) 2003-2024 The MiG Project by the Science HPC Center at UCPH
#
# This file is part of MiG.
#
# MiG is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# MiG is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
#
# --- END_HEADER ---
#

set -e

SCRIPT_PATH=$(realpath "$0")
SCRIPT_BASE=$(dirname -- "$SCRIPT_PATH")
MIG_BASE=$(realpath "$SCRIPT_BASE/..")

PYTHON_BIN=${PYTHON_BIN:-"$SCRIPT_BASE/venv/bin/python3"}

if [ "$1" = "" ]; then
echo "No binary requested"
exit 1
fi

BIN_PATH=$("$PYTHON_BIN" "$SCRIPT_BASE/which.py" $1)
if [ "$BIN_PATH" = "" ]; then
echo "Unable to find the binary to invoke"
exit 1
fi

shift 1

"$BIN_PATH" "$@"
2 changes: 2 additions & 0 deletions envhelp/makeconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@

sys.path.append(_LOCAL_MIG_BASE)

from mig.shared.conf import get_configuration_object

Check warning on line 42 in envhelp/makeconfig.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

module level import not at top of file
from mig.shared.install import MIG_BASE, generate_confs

Check warning on line 43 in envhelp/makeconfig.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

module level import not at top of file
from mig.shared.useradm import _ensure_dirs_needed_for_userdb

Check warning on line 44 in envhelp/makeconfig.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

module level import not at top of file

_LOCAL_ENVHELP_OUTPUT_DIR = os.path.join(_LOCAL_MIG_BASE, "envhelp/output")
_MAKECONFIG_ALLOWED = ["local", "test"]
Expand Down Expand Up @@ -82,6 +82,8 @@
'mig_code': os.path.join(conf_dir_path, 'mig'),
'mig_certs': os.path.join(conf_dir_path, 'certs'),
'mig_state': os.path.join(conf_dir_path, 'state'),
'admin_email': 'admin@example.com',
'support_email': 'support@example.com',
})

if is_docker:
Expand Down
91 changes: 91 additions & 0 deletions envhelp/scripts/expand_sources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/usr/bin/env python3

import glob
import os
import shutil
import subprocess
import sys
import urllib.request
import zipfile


SCRIPT_DIR = os.path.dirname(__file__)
ROOT_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, '../..'))
STAGING_DIR = os.path.join(ROOT_DIR, 'envhelp/staging')
SOURCE_URL_BASE = 'http://github.com/ucphhpc'

PACKAGE_REPOS_TO_BRANCH = {
'migux': {
'repository': 'migrid-ux',
'branch': 'next',
}
}


def download_url(url, output_file, use_wget=False):
if use_wget:
download_url_wget(url, output_file)
else:
urllib.request.urlretrieve(url, output_file)


def download_url_wget(url, output_file):
subprocess.run(["wget", "-O", output_file, url], stderr=subprocess.DEVNULL)


def main(argv):
use_wget = '--use-wget' in argv

# start with an entirely clean state
shutil.rmtree(STAGING_DIR, ignore_errors=True)

# make the package directory
os.makedirs(STAGING_DIR)

# make the temporary download directory
staging_dir = os.path.join(STAGING_DIR, ".download")
os.mkdir(staging_dir)

for package_name, package_dict in PACKAGE_REPOS_TO_BRANCH.items():

Check warning on line 49 in envhelp/scripts/expand_sources.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

multiple spaces before keyword
package_repo = package_dict['repository']
branch_name = package_dict['branch']

package_repo_with_branch = "%s-%s" % (package_repo, branch_name)
package_dir_staging = os.path.join(staging_dir, package_repo_with_branch)

Check warning on line 54 in envhelp/scripts/expand_sources.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (82 > 80 characters)
downloaded_archive_file = os.path.join(staging_dir, "_%s.zip" % (package_repo,))

Check warning on line 55 in envhelp/scripts/expand_sources.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (88 > 80 characters)

# grab an archive containing installable package files
package_url = os.path.join(SOURCE_URL_BASE, package_repo, 'archive/refs/heads', "%s.zip" % (branch_name,))

Check warning on line 58 in envhelp/scripts/expand_sources.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (114 > 80 characters)
download_url(package_url, downloaded_archive_file, use_wget=use_wget)

# extract it
archive = zipfile.ZipFile(downloaded_archive_file)
archive.extractall(staging_dir)

# find the raw package files
packages_glob = os.path.join(package_dir_staging, "dist/%s-*" % (package_name,))

Check warning on line 66 in envhelp/scripts/expand_sources.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (88 > 80 characters)
packages_paths = glob.glob(packages_glob)

# copy the raw package files into a common packages directory
for package_path in packages_paths:
package_file_name = os.path.basename(package_path)
target_path_path = os.path.join(STAGING_DIR, package_file_name)
shutil.copyfile(package_path, target_path_path)

# remove all staged files
shutil.rmtree(staging_dir)

packages_list = os.path.join(STAGING_DIR, ".packages.lst")

# write a listing of the available package files alongside them
with open(packages_list, "w") as outfile:
package_names_only = [file_name for file_name in os.listdir(STAGING_DIR)
if not file_name.startswith('.')]

Check warning on line 83 in envhelp/scripts/expand_sources.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

continuation line over-indented for visual indent
package_names_only.sort()
print(*package_names_only, sep='\n', file=outfile)

return 0


if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
59 changes: 59 additions & 0 deletions envhelp/which.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*-
#
# --- BEGIN_HEADER ---
#
# python3 - wrapper to invoke a local python3 virtual environment
# Copyright (C) 2003-2024 The MiG Project by the Science HPC Center at UCPH
#
# This file is part of MiG.
#
# MiG is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# MiG is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
#
# --- END_HEADER ---
#

"""Locate a binary via the active python interpreter."""

import os
import shutil
import sys

ROOT_DIR = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
VENV_BIN_DIR = os.path.join(ROOT_DIR, 'envhelp/venv/bin')


def main(args):
if len(args) != 1:
return 1

location = shutil.which(args[0])
if location is not None:
print(location)
return 0

# locally in development we do not require activating the venv and thus
# it is possible the binary is installed but not path visible - try the
# local venv as a fallback path to try to catch this
location = os.path.join(VENV_BIN_DIR, args[0])
if os.path.exists(location):
print(location)
return 0

return 1


if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
1 change: 1 addition & 0 deletions local-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# We only need autopep8 on py 3 as it's used in 'make fmt' (with py3)
autopep8;python_version >= "3"
black
dumb-pypi
isort
# We need paramiko for the ssh unit tests
# NOTE: paramiko-3.0.0 dropped python2 and python3.6 support
Expand Down
Empty file added mig/assets/templates/.gitkeep
Empty file.
Loading
Loading