Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SCM syntax highlighting & preventing 3-way merges
pixi.lock merge=binary linguist-language=YAML linguist-generated=true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,6 @@ dmypy.json

# Generated examples
# examples/
# pixi environments
.pixi/*
!.pixi/config.toml
2,134 changes: 2,134 additions & 0 deletions pixi.lock

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[workspace]
channels = ["https://prefix.dev/conda-forge"]
name = "vinca"
platforms = ["win-64", "linux-64", "osx-arm64", "osx-64"]
version = "0.1.0"

[tasks]
# Testing
test = "pytest vinca/"

# Code quality
format = "black --safe --quiet ."
lint = "flake8 vinca/"

[dependencies]
python = ">=3.14.0,<3.15"

# Core dependencies
catkin_pkg = ">=0.4.16"
"ruamel.yaml" = ">=0.16.6,<0.18.0"
rosdistro = ">=0.8.0"
empy = ">=3.3.4,<4.0.0"
requests = ">=2.24.0"
networkx = ">=2.5"
rich = ">=10"
jinja2 = ">=3.0.0"
license-expression = ">=30.0.0"

# Development dependencies
pytest = "*"
black = "*"
flake8 = "*"

[pypi-dependencies]
vinca = { path = ".", editable = true}
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ install_requires =
networkx >=2.5
rich >=10
jinja2 >=3.0.0
license-expression >=30.0.0
packages = find:
zip_safe = false

Expand Down
49 changes: 38 additions & 11 deletions vinca/distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@


class Distro(object):
def __init__(self, distro_name, python_version=None, snapshot=None, additional_packages_snapshot=None):
def __init__(
self,
distro_name,
python_version=None,
snapshot=None,
additional_packages_snapshot=None,
):
index = get_index(get_index_url())
self._distro = get_cached_distribution(index, distro_name)
self.distro_name = distro_name
Expand Down Expand Up @@ -49,20 +55,30 @@ def get_depends(self, pkg, ignore_pkgs=None):
return dependencies

# if pkg comes from additional_packages_snapshot, extract from its package.xml
if self.additional_packages_snapshot and pkg in self.additional_packages_snapshot:
if (
self.additional_packages_snapshot
and pkg in self.additional_packages_snapshot
):
pkg_info = self.additional_packages_snapshot[pkg]
xml_str = self.get_package_xml_for_additional_package(pkg_info)
# parse XML
import xml.etree.ElementTree as ET

root = ET.fromstring(xml_str)
# collect direct dependencies tags from package.xml
dep_tags = [
'depend', 'build_depend', 'buildtool_depend', 'buildtool_export_depend',
'exec_depend', 'run_depend', 'test_depend', 'build_export_depend'
"depend",
"build_depend",
"buildtool_depend",
"buildtool_export_depend",
"exec_depend",
"run_depend",
"test_depend",
"build_export_depend",
]
direct = set()
for tag in dep_tags:
for elem in root.findall(f'.//{tag}'):
for elem in root.findall(f".//{tag}"):
if elem.text:
name = elem.text.strip()
direct.add(name)
Expand Down Expand Up @@ -111,18 +127,26 @@ def get_released_repo(self, pkg_name):
pkg = self._distro.release_packages[pkg_name]
repo = self._distro.repositories[pkg.repository_name].release_repository
release_tag = get_release_tag(repo, pkg_name)
return repo.url, release_tag, 'tag'
return repo.url, release_tag, "tag"

def check_package(self, pkg_name):
# If the package is in the additional_packages_snapshot, it is always considered valid
# even if it is not in the released packages, as it is an additional
# package specified in rosdistro_additional_recipes.yaml
if self.additional_packages_snapshot and pkg_name in self.additional_packages_snapshot:
if (
self.additional_packages_snapshot
and pkg_name in self.additional_packages_snapshot
):
return True
# the .replace('_', '-') is needed for packages like 'hpp-fcl' that have hypen and not underscore
# in the rosdistro metadata
if pkg_name in self._distro.release_packages or pkg_name.replace('_', '-') in self._distro.release_packages:
return self.snapshot is None or (pkg_name in self.snapshot or pkg_name.replace('_', '-') in self.snapshot)
if (
pkg_name in self._distro.release_packages
or pkg_name.replace("_", "-") in self._distro.release_packages
):
return self.snapshot is None or (
pkg_name in self.snapshot or pkg_name.replace("_", "-") in self.snapshot
)
elif pkg_name in self.build_packages:
return True
else:
Expand All @@ -137,7 +161,10 @@ def get_version(self, pkg_name):
return repo.version.split("-")[0]

def get_release_package_xml(self, pkg_name):
if self.additional_packages_snapshot and pkg_name in self.additional_packages_snapshot:
if (
self.additional_packages_snapshot
and pkg_name in self.additional_packages_snapshot
):
pkg_info = self.additional_packages_snapshot[pkg_name]
return self.get_package_xml_for_additional_package(pkg_info)
return self._distro.get_release_package_xml(pkg_name)
Expand Down Expand Up @@ -171,6 +198,6 @@ def get_package_xml_for_additional_package(self, pkg_info):
raw_url = f"https://raw.githubusercontent.com/{owner_repo}/{ref}/{additional_folder}{xml_name}"
try:
with urllib.request.urlopen(raw_url) as resp:
return resp.read().decode('utf-8')
return resp.read().decode("utf-8")
except Exception as e:
raise RuntimeError(f"Failed to fetch package.xml from {raw_url}: {e}")
7 changes: 6 additions & 1 deletion vinca/generate_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,12 @@ def get_full_tree():
config.selected_platform = get_conda_subdir()

python_version = temp_vinca_conf.get("python_version", None)
distro = Distro(temp_vinca_conf["ros_distro"], python_version, temp_vinca_conf["_snapshot"], temp_vinca_conf["_additional_packages_snapshot"])
distro = Distro(
temp_vinca_conf["ros_distro"],
python_version,
temp_vinca_conf["_snapshot"],
temp_vinca_conf["_additional_packages_snapshot"],
)

all_packages = get_selected_packages(distro, temp_vinca_conf)
temp_vinca_conf["_selected_pkgs"] = all_packages
Expand Down
15 changes: 10 additions & 5 deletions vinca/generate_gha.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def build_osx_pipeline(
azure_template=None,
script=azure_unix_script,
target="osx-64",
pipeline_name="build_osx_64"
pipeline_name="build_osx_64",
):
build_unix_pipeline(
stages,
Expand All @@ -337,7 +337,7 @@ def build_osx_pipeline(
runs_on=vm_imagename,
outfile=outfile,
target=target,
pipeline_name=pipeline_name
pipeline_name=pipeline_name,
)


Expand Down Expand Up @@ -428,7 +428,12 @@ def get_full_tree():
config.selected_platform = get_conda_subdir()

python_version = temp_vinca_conf.get("python_version", None)
distro = Distro(temp_vinca_conf["ros_distro"], python_version, temp_vinca_conf["_snapshot"], temp_vinca_conf["_additional_packages_snapshot"])
distro = Distro(
temp_vinca_conf["ros_distro"],
python_version,
temp_vinca_conf["_snapshot"],
temp_vinca_conf["_additional_packages_snapshot"],
)

all_packages = get_selected_packages(distro, temp_vinca_conf)
temp_vinca_conf["_selected_pkgs"] = all_packages
Expand Down Expand Up @@ -562,7 +567,7 @@ def main():
outfile="osx_arm64.yml",
script=azure_unix_script,
target=platform,
pipeline_name="build_osx_arm64"
pipeline_name="build_osx_arm64",
)

if args.platform == "linux-aarch64":
Expand All @@ -573,7 +578,7 @@ def main():
runs_on="ubuntu-24.04-arm",
outfile="linux_aarch64.yml",
target=platform,
pipeline_name="build_linux_aarch64"
pipeline_name="build_linux_aarch64",
)

# windows
Expand Down
Loading