Skip to content

Commit 87ad936

Browse files
authored
Merge pull request #14 from RoboStack/ros2
2 parents b910e3b + 0fd3443 commit 87ad936

13 files changed

+133
-119
lines changed

vinca/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.1"
1+
__version__ = "0.0.1-ros2"

vinca/distro.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def name(self):
3737
def add_packages(self, packages):
3838
self.build_packages = set(packages)
3939

40-
def get_depends(self, pkg):
40+
def get_depends(self, pkg, ignore_pkgs=None):
4141
dependencies = set()
4242
dependencies |= self._walker.get_recursive_depends(
4343
pkg,
@@ -51,6 +51,7 @@ def get_depends(self, pkg):
5151
"exec",
5252
],
5353
ros_packages_only=True,
54+
ignore_pkgs=ignore_pkgs
5455
)
5556
return dependencies
5657

vinca/generate_azure.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def main():
367367
print(stages)
368368

369369
# Build Linux pipeline
370-
azure_template = {"pool": {"vmImage": "ubuntu-16.04"}}
370+
azure_template = {"pool": {"vmImage": "ubuntu-latest"}}
371371

372372
azure_stages = []
373373

@@ -381,7 +381,7 @@ def main():
381381
pkg_jobname = '_'.join([normalize_name(pkg) for pkg in batch])
382382
stage["jobs"].append(
383383
{
384-
"job": pkg_jobname,
384+
"job": f"stage_{i}_job_{len(stage['jobs'])}",
385385
"steps": [
386386
{
387387
"script": azure_linux_script,
@@ -424,7 +424,7 @@ def main():
424424
pkg_jobname = '_'.join([normalize_name(pkg) for pkg in batch])
425425
stage["jobs"].append(
426426
{
427-
"job": pkg_jobname,
427+
"job": f"stage_{i}_job_{len(stage['jobs'])}",
428428
"steps": [
429429
{
430430
"script": azure_osx_script,
@@ -466,7 +466,7 @@ def main():
466466
pkg_jobname = '_'.join([normalize_name(pkg) for pkg in batch])
467467
stage["jobs"].append(
468468
{
469-
"job": pkg_jobname,
469+
"job": f"stage_{i}_job_{len(stage['jobs'])}",
470470
"steps": [
471471
{
472472
"script": azure_osx_arm64_script,
@@ -542,7 +542,7 @@ def main():
542542
fo.write(yaml.dump(azure_template, sort_keys=False))
543543

544544
# windows
545-
azure_template = {"pool": {"vmImage": "vs2017-win2016"}}
545+
azure_template = {"pool": {"vmImage": "windows-2019"}}
546546

547547
azure_stages = []
548548

@@ -561,7 +561,7 @@ def main():
561561
pkg_jobname = '_'.join([normalize_name(pkg) for pkg in batch])
562562
stage["jobs"].append(
563563
{
564-
"job": pkg_jobname,
564+
"job": f"stage_{i}_job_{len(stage['jobs'])}",
565565
"variables": {"CONDA_BLD_PATH": "C:\\\\bld\\\\"},
566566
"steps": [
567567
{

vinca/main.py

Lines changed: 47 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ def get_depmods(vinca_conf, pkg_name):
145145
add_deps[dep_type].append(dict(el))
146146
else:
147147
add_deps[dep_type].append(el)
148-
149148
return rm_deps, add_deps
150149

151150

@@ -174,13 +173,18 @@ def read_vinca_yaml(filepath):
174173
if splitted[1] in ("osx", "linux", "win"):
175174
patches[splitted[0]][splitted[1]].append(x)
176175
continue
176+
if splitted[1] == "unix":
177+
patches[splitted[0]]["linux"].append(x)
178+
patches[splitted[0]]["osx"].append(x)
179+
continue
180+
177181
patches[splitted[0]]["any"].append(x)
178182

179183
vinca_conf["_patches"] = patches
180184

181185
if (patch_dir / "dependencies.yaml").exists():
182186
vinca_conf["depmods"] = yaml.load(open(patch_dir / "dependencies.yaml"))
183-
else:
187+
if not vinca_conf.get("depmods"):
184188
vinca_conf["depmods"] = {}
185189

186190
config.ros_distro = vinca_conf["ros_distro"]
@@ -189,7 +193,7 @@ def read_vinca_yaml(filepath):
189193
return vinca_conf
190194

191195

192-
def generate_output(pkg_shortname, vinca_conf, distro, version):
196+
def generate_output(pkg_shortname, vinca_conf, distro, version, all_pkgs=[]):
193197
if pkg_shortname not in vinca_conf["_selected_pkgs"]:
194198
return None
195199

@@ -211,6 +215,7 @@ def generate_output(pkg_shortname, vinca_conf, distro, version):
211215
"{{ compiler('c') }}",
212216
"ninja",
213217
{"sel(unix)": "make"},
218+
{"sel(osx)": "tapi"},
214219
"cmake",
215220
{"sel(build_platform != target_platform)": "python"},
216221
{"sel(build_platform != target_platform)": "cross-python_{{ target_platform }}"},
@@ -258,15 +263,23 @@ def generate_output(pkg_shortname, vinca_conf, distro, version):
258263
output["requirements"]["host"].append(vinca_conf["mutex_package"])
259264
output["requirements"]["run"].append(vinca_conf["mutex_package"])
260265

266+
if not distro.check_ros1() and pkg_shortname not in ['ament_cmake_core', 'ament_package', 'ros_workspace']:
267+
output["requirements"]["run"].append(f"ros-{config.ros_distro}-ros-workspace")
261268

262269
rm_deps, add_deps = get_depmods(vinca_conf, pkg.name)
270+
gdeps = []
271+
if pkg.group_depends:
272+
for gdep in pkg.group_depends:
273+
gdep.extract_group_members(all_pkgs)
274+
gdeps += gdep.members
263275

264276
build_deps = pkg.build_depends
265277
build_deps += pkg.buildtool_depends
266278
build_deps += pkg.build_export_depends
267279
build_deps += pkg.buildtool_export_depends
268280
build_deps += pkg.test_depends
269281
build_deps = [d.name for d in build_deps if d.evaluated_condition]
282+
build_deps += gdeps
270283

271284
for dep in build_deps:
272285
if dep in ["REQUIRE_OPENGL", "REQUIRE_GL"]:
@@ -284,6 +297,7 @@ def generate_output(pkg_shortname, vinca_conf, distro, version):
284297
run_deps += pkg.build_export_depends
285298
run_deps += pkg.buildtool_export_depends
286299
run_deps = [d.name for d in run_deps if d.evaluated_condition]
300+
run_deps += gdeps
287301

288302
for dep in run_deps:
289303
if dep in ["REQUIRE_OPENGL", "REQUIRE_GL"]:
@@ -303,8 +317,13 @@ def generate_output(pkg_shortname, vinca_conf, distro, version):
303317
while dep in output["requirements"][dep_type]:
304318
output["requirements"][dep_type].remove(dep)
305319

306-
output["requirements"]["run"] = sorted(output["requirements"]["run"])
307-
output["requirements"]["host"] = sorted(output["requirements"]["host"])
320+
def sortkey(k):
321+
if isinstance(k, dict):
322+
return list(k.values())[0]
323+
return k
324+
325+
output["requirements"]["run"] = sorted(output["requirements"]["run"], key=sortkey)
326+
output["requirements"]["host"] = sorted(output["requirements"]["host"], key=sortkey)
308327

309328
output["requirements"]["run"] += [
310329
{
@@ -401,9 +420,19 @@ def generate_output(pkg_shortname, vinca_conf, distro, version):
401420

402421
def generate_outputs(distro, vinca_conf):
403422
outputs = []
423+
424+
def get_pkg(pkg_name):
425+
pkg = catkin_pkg.package.parse_package_string(
426+
distro.get_release_package_xml(pkg_name)
427+
)
428+
pkg.evaluate_conditions(os.environ)
429+
return pkg
430+
431+
all_pkgs = [get_pkg(pkg) for pkg in distro.get_depends('ros_base')]
432+
404433
for pkg_shortname in vinca_conf["_selected_pkgs"]:
405434
output = generate_output(
406-
pkg_shortname, vinca_conf, distro, distro.get_version(pkg_shortname)
435+
pkg_shortname, vinca_conf, distro, distro.get_version(pkg_shortname), all_pkgs
407436
)
408437
if output is not None:
409438
outputs.append(output)
@@ -523,87 +552,33 @@ def get_selected_packages(distro, vinca_conf):
523552
if vinca_conf.get("build_all", False):
524553
selected_packages = set(distro._distro.release_packages.keys())
525554
elif vinca_conf["packages_select_by_deps"]:
555+
556+
if (
557+
"packages_skip_by_deps" in vinca_conf
558+
and vinca_conf["packages_skip_by_deps"] is not None
559+
):
560+
for i in vinca_conf["packages_skip_by_deps"]:
561+
skipped_packages = skipped_packages.union([i, i.replace("-", "_")])
562+
print("Skipped pkgs: ", skipped_packages)
526563
for i in vinca_conf["packages_select_by_deps"]:
527564
i = i.replace("-", "_")
528565
selected_packages = selected_packages.union([i])
529566
if "skip_all_deps" not in vinca_conf or not vinca_conf["skip_all_deps"]:
567+
if i in skipped_packages:
568+
continue
530569
try:
531-
pkgs = distro.get_depends(i)
570+
pkgs = distro.get_depends(i, ignore_pkgs=skipped_packages)
532571
except KeyError:
533572
# handle (rare) package names that use "-" as separator
534573
pkgs = distro.get_depends(i.replace("_", "-"))
535574
selected_packages.remove(i)
536575
selected_packages.add(i.replace("_", "-"))
537576
selected_packages = selected_packages.union(pkgs)
538577

539-
if (
540-
"packages_skip_by_deps" in vinca_conf
541-
and vinca_conf["packages_skip_by_deps"] is not None
542-
):
543-
for i in vinca_conf["packages_skip_by_deps"]:
544-
i = i.replace("-", "_")
545-
skipped_packages = skipped_packages.union([i])
546-
try:
547-
pkgs = distro.get_depends(i)
548-
except KeyError:
549-
# handle (rare) package names that use "-" as separator
550-
pkgs = distro.get_depends(i.replace("_", "-"))
551-
selected_packages.remove(i)
552-
selected_packages.add(i.replace("_", "-"))
553-
skipped_packages = skipped_packages.union(pkgs)
554-
result = selected_packages.difference(skipped_packages)
555-
result = sorted(list(result))
578+
result = sorted(list(selected_packages))
556579
return result
557580

558581

559-
# def parse_dep(dep, vinca_conf, distro):
560-
# res = dep.name
561-
# res = resolve_pkgname(res, vinca_conf, distro)
562-
563-
# if dep.version_eq :
564-
# return res + " ==" + dep.version_eq
565-
566-
# if dep.version_gt :
567-
# res = res + " >" + dep.version_gt
568-
569-
# if dep.version_lt :
570-
# res = res + ", <" + dep.version_lt
571-
572-
# if dep.version_lte :
573-
# res = res + ", <=" + dep.version_lte
574-
575-
# return res
576-
577-
# if dep.version_gte :
578-
# res = res + " >=" + dep.version_gte
579-
580-
# if dep.version_lt :
581-
# res = res + ", <" + dep.version_lt
582-
583-
# return res
584-
585-
# if dep.version_lt :
586-
# res = res + " <" + dep.version_lt
587-
588-
# if dep.version_gt :
589-
# res = res + ", >" + dep.version_gt
590-
591-
# if dep.version_gte :
592-
# res = res + ", >=" + dep.version_gte
593-
594-
# return res
595-
596-
# if dep.version_lte :
597-
# res = res + " <=" + dep.version_lte
598-
599-
# if dep.version_gt :
600-
# res = res + ", >" + dep.version_gt
601-
602-
# return res
603-
604-
# return res
605-
606-
607582
def parse_package(pkg, distro, vinca_conf, path):
608583

609584
name = pkg["name"].replace("_", "-")

vinca/resolve.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,28 @@ def resolve_pkgname_from_indexes(pkg_shortname, conda_index):
4545
return None
4646

4747

48+
def should_skip_pkg(pkg_shortname, vinca_conf):
49+
skip = vinca_conf.get("packages_remove_from_deps", [])
50+
if not skip:
51+
return False
52+
53+
if pkg_shortname in skip:
54+
return True
55+
if pkg_shortname.replace('_', '-') in skip:
56+
return True
57+
4858
def resolve_pkgname(pkg_shortname, vinca_conf, distro, is_rundep=False):
4959
pkg_names = resolve_pkgname_from_indexes(
5060
pkg_shortname, vinca_conf["_conda_indexes"]
5161
)
5262
if pkg_names is None:
53-
if not distro.check_package(pkg_shortname):
63+
if not distro.check_package(pkg_shortname) or should_skip_pkg(pkg_shortname, vinca_conf):
5464
return []
5565
else:
56-
if (
57-
"packages_remove_from_deps" in vinca_conf
58-
and vinca_conf["packages_remove_from_deps"] is not None
59-
and not (
60-
pkg_shortname.replace("_", "-") in vinca_conf["packages_remove_from_deps"] or
61-
pkg_shortname in vinca_conf["packages_remove_from_deps"])
62-
):
63-
return [
64-
"ros-%s-%s"
65-
% (vinca_conf["ros_distro"], pkg_shortname.replace("_", "-"))
66-
]
67-
else:
68-
return []
66+
return [
67+
"ros-%s-%s"
68+
% (vinca_conf["ros_distro"], pkg_shortname.replace("_", "-"))
69+
]
6970
else:
7071
if is_rundep: # for run dependencies, remove the version
7172
pkg_names_pinned = []

vinca/template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def write_recipe(source, outputs, build_number=0, single_file=True):
8585

8686
for key, script in meta['build']['script'].items():
8787
shutil.copyfile(script, recipe_dir / script)
88-
if "catkin" in o["package"]["name"]:
88+
if "catkin" in o["package"]["name"] or "workspace" in o["package"]["name"]:
8989
shutil.copyfile("activate.sh", recipe_dir / "activate.sh")
9090
shutil.copyfile("activate.bat", recipe_dir / "activate.bat")
9191
shutil.copyfile("deactivate.sh", recipe_dir / "deactivate.sh")

vinca/templates/activate.bat.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
@@call "%CONDA_PREFIX%\Library\local_setup.bat"
1111
@@set PYTHONHOME=
1212
@@set "ROS_OS_OVERRIDE=robostack:win64"
13-
13+
@@set "ROS_ETC_DIR=%CONDA_PREFIX%\Library\etc\ros"
14+
@@set "AMENT_PREFIX_PATH=%CONDA_PREFIX%\Library"

vinca/templates/activate.sh.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by vinca http://github.com/seanyen/vinca.
1+
# Generated by vinca http://github.com/RoboStack/vinca.
22
# DO NOT EDIT!
33
# if [ -z "${CONDA_PREFIX}" ]; then
44
# exit 0;
@@ -19,5 +19,8 @@ case "$OSTYPE" in
1919
linux*) export ROS_OS_OVERRIDE="robostack:linux";;
2020
esac
2121

22+
export ROS_ETC_DIR=$CONDA_PREFIX/etc/ros
23+
export AMENT_PREFIX_PATH=$CONDA_PREFIX
24+
2225
# Looks unnecessary for UNIX
2326
# unset PYTHONHOME=

0 commit comments

Comments
 (0)