Skip to content

Commit

Permalink
automatically get distro
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Jul 23, 2021
1 parent abd07b5 commit 325a59b
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions vinca/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,23 @@
import networkx as nx
import subprocess
import shutil
from vinca.main import read_vinca_yaml
import ruamel.yaml


from vinca.distro import Distro

packages_to_migrate = ["libopencv"]
distro_version = "noetic"
ros_prefix = f"ros-{distro_version}"
distro_version = None
ros_prefix = None

arches = ["linux-64", "linux-aarch64", "win-64", "osx-64", "osx-arm64"]
# arches = ["linux-64", "linux-aarch64", "win-64", "osx-64", "osx-arm64"]
# arch_to_fname = {
# "linux-64": "linux",
# "linux-aarch64": "linux_aarch_64",
# "win-64": "win",
# "osx-64": "osx",
# "osx-arm64": "osx_arm64"
# }

def to_ros_name(distro, pkg_name):
shortname = pkg_name[len(ros_prefix) + 1:]
Expand All @@ -26,6 +35,15 @@ def to_ros_name(distro, pkg_name):

def create_migration_instructions(arch, packages_to_migrate, trigger_branch):
url = f"https://conda.anaconda.org/robostack/{arch}/repodata.json"

yaml = ruamel.yaml.YAML()
with open("vinca.yaml", "r") as fi:
vinca_conf = yaml.load(fi)

global distro_version, ros_prefix
distro_version = vinca_conf['ros_distro']
ros_prefix = f"ros-{distro_version}"

print("URL: ", url)
# return
repodata = requests.get(url).json()
Expand All @@ -46,9 +64,6 @@ def create_migration_instructions(arch, packages_to_migrate, trigger_branch):
# print(f"need to migrate {pkey}")
to_migrate.add(pname)

# print(to_migrate)
# print(ros_pkgs)

latest = {}
for pkg in ros_pkgs:
current = current_version = None
Expand All @@ -70,9 +85,7 @@ def create_migration_instructions(arch, packages_to_migrate, trigger_branch):
current = pkey
latest[pkg] = current

# print(latest)

# now we can build the graph ...
# now we can build the graph ...

G = nx.DiGraph()
for pkg, pkgkey in latest.items():
Expand All @@ -98,12 +111,6 @@ def create_migration_instructions(arch, packages_to_migrate, trigger_branch):
ros_names.append(to_ros_name(distro, pkg))
print("Final names: ", ros_names)

from vinca.main import read_vinca_yaml
import ruamel.yaml
yaml = ruamel.yaml.YAML()
with open("vinca.yaml", "r") as fi:
vinca_conf = yaml.load(fi)

vinca_conf["packages_select_by_deps"] = ros_names
vinca_conf["skip_all_deps"] = True
vinca_conf["is_migration"] = True
Expand Down

0 comments on commit 325a59b

Please sign in to comment.