Re-added pypi package version fetching script
Some checks failed
autoBIGS.engine-bioconda/pipeline/head There was a failure building this commit

This commit is contained in:
Harrison Deng 2025-02-18 14:49:49 +00:00
parent e1cd2e515d
commit b6c32fbd3c
2 changed files with 32 additions and 1 deletions

2
Jenkinsfile vendored
View File

@ -51,7 +51,7 @@ pipeline {
} }
steps { steps {
dir('auto-updated-bioconda-recipes') { dir('auto-updated-bioconda-recipes') {
sh 'git commit -a -m "Automatically updated autobigs-engine bioconda recipe to $(python ../scripts/package_latest_version.py autoBIGS.engine)."' sh 'git commit -a -m "Automatically updated autobigs-engine bioconda recipe to $(python ../pypi_latest_ver.py autoBIGS.engine)."'
sh 'git push https://${TOKEN}@github.com/Syph-and-VPD-Lab/auto-updated-bioconda-recipes.git update-autobigs-engine' sh 'git push https://${TOKEN}@github.com/Syph-and-VPD-Lab/auto-updated-bioconda-recipes.git update-autobigs-engine'
} }
} }

31
pypi_latest_ver.py Normal file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env python3
import sys
import requests
import json
try:
from packaging.version import parse
except ImportError:
from pip._vendor.packaging.version import parse
# Courtesy of https://stackoverflow.com/questions/28774852/pypi-api-how-to-get-stable-package-version
URL_PATTERN = 'https://pypi.python.org/pypi/{package}/json'
def get_version(package, url_pattern=URL_PATTERN):
"""Return version of package on pypi.python.org using json."""
req = requests.get(url_pattern.format(package=package))
version = parse('0')
if req.status_code == requests.codes.ok:
j = json.loads(req.text.encode(req.encoding or "utf-8"))
releases = j.get('releases', [])
for release in releases:
ver = parse(release)
if not ver.is_prerelease:
version = max(version, ver)
return version
if __name__ == '__main__':
print(get_version(sys.argv[1]), end="")