mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-17 04:51:10 +00:00
Fix FileNotFoundError
This commit is contained in:
20
.github/workflows/conda-pack-build.yml
vendored
20
.github/workflows/conda-pack-build.yml
vendored
@@ -84,12 +84,24 @@ jobs:
|
||||
echo "Using mamba for faster and more reliable dependency resolution..."
|
||||
mamba install uni-lab::unilabos conda-pack -c uni-lab -c robostack-staging -c conda-forge -y
|
||||
|
||||
- name: Get latest ros-humble-unilabos-msgs version
|
||||
if: steps.should_build.outputs.should_build == 'true'
|
||||
id: msgs_version
|
||||
- name: Get latest ros-humble-unilabos-msgs version (Windows)
|
||||
if: steps.should_build.outputs.should_build == 'true' && matrix.platform == 'win-64'
|
||||
id: msgs_version_win
|
||||
run: |
|
||||
Write-Host "Checking installed ros-humble-unilabos-msgs version..."
|
||||
$version = (conda list ros-humble-unilabos-msgs --json | ConvertFrom-Json)[0].version
|
||||
Write-Output "installed_version=$version" >> $env:GITHUB_OUTPUT
|
||||
Write-Host "Installed ros-humble-unilabos-msgs version: $version"
|
||||
|
||||
- name: Get latest ros-humble-unilabos-msgs version (Unix)
|
||||
if: steps.should_build.outputs.should_build == 'true' && matrix.platform != 'win-64'
|
||||
id: msgs_version_unix
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Checking installed ros-humble-unilabos-msgs version..."
|
||||
python scripts/get_package_version.py ros-humble-unilabos-msgs
|
||||
VERSION=$(conda list ros-humble-unilabos-msgs --json | python -c "import sys, json; pkgs=json.load(sys.stdin); print(pkgs[0]['version'] if pkgs else 'not-found')")
|
||||
echo "installed_version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "Installed ros-humble-unilabos-msgs version: $VERSION"
|
||||
|
||||
- name: Check for newer ros-humble-unilabos-msgs
|
||||
if: steps.should_build.outputs.should_build == 'true'
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Get Conda Package Version
|
||||
==========================
|
||||
|
||||
Get the installed version of a conda package and output it for GitHub Actions.
|
||||
|
||||
Usage:
|
||||
python get_package_version.py <package_name>
|
||||
|
||||
Example:
|
||||
python get_package_version.py ros-humble-unilabos-msgs
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def get_package_version(package_name: str) -> str:
|
||||
"""
|
||||
Get the installed version of a conda package.
|
||||
|
||||
Args:
|
||||
package_name: Name of the package to check
|
||||
|
||||
Returns:
|
||||
str: Version string or 'not-found'
|
||||
"""
|
||||
try:
|
||||
# Use conda list with JSON output for reliable parsing
|
||||
result = subprocess.run(["conda", "list", package_name, "--json"], capture_output=True, text=True, check=True)
|
||||
|
||||
packages = json.loads(result.stdout)
|
||||
|
||||
if packages:
|
||||
version = packages[0]["version"]
|
||||
return version
|
||||
else:
|
||||
return "not-found"
|
||||
|
||||
except (subprocess.CalledProcessError, json.JSONDecodeError, KeyError, IndexError) as e:
|
||||
print(f"Error getting package version: {e}", file=sys.stderr)
|
||||
return "error"
|
||||
|
||||
|
||||
def main():
|
||||
"""Main entry point."""
|
||||
if len(sys.argv) != 2:
|
||||
print(f"Usage: {sys.argv[0]} <package_name>", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
package_name = sys.argv[1]
|
||||
version = get_package_version(package_name)
|
||||
|
||||
# Output for GitHub Actions
|
||||
github_output = os.getenv("GITHUB_OUTPUT")
|
||||
if github_output:
|
||||
with open(github_output, "a") as f:
|
||||
f.write(f"installed_version={version}\n")
|
||||
|
||||
# Also print for logs
|
||||
print(f"Installed {package_name} version: {version}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user