Skip to content

Commit

Permalink
Reimplement the python machinery to get the model location in pure py…
Browse files Browse the repository at this point in the history
…thon

- Remove the pybind11 dependency
- Implement setup.py and setup.cfg to install the icub_models package
  • Loading branch information
GiulioRomualdi committed Mar 28, 2022
1 parent fcdcc24 commit a8d5d01
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 133 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ string(REPLACE ";" "," INSTALLED_URDF_MODELS "${INSTALLED_URDF_MODELS}")
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/iCub DESTINATION share)

add_subdirectory(cpp)
add_subdirectory(bindings)


include(InstallBasicPackageFiles)
install_basic_package_files(${PROJECT_NAME}
Expand Down
72 changes: 0 additions & 72 deletions bindings/CMakeLists.txt

This file was deleted.

27 changes: 0 additions & 27 deletions bindings/python/CMakeLists.txt

This file was deleted.

32 changes: 0 additions & 32 deletions bindings/python/icub_models.cpp

This file was deleted.

18 changes: 18 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (C) 2022 Istituto Italiano di Tecnologia (IIT). All rights reserved.
# This software may be modified and distributed under the terms of the
# Released under the terms of the BSD 3-Clause License

[build-system]
build-backend = "setuptools.build_meta"
requires = [
"wheel",
"setuptools>=45",
"setuptools_scm[toml]>=6.0",
]

[tool.black]
line-length = 88

[tool.isort]
profile = "black"
multi_line_output = 3
1 change: 1 addition & 0 deletions python/icub_models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .icub_models import get_model_file, get_robot_names, get_models_path
23 changes: 23 additions & 0 deletions python/icub_models/icub_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# @file icub_models.py
# @authors Giulio Romualdi
# @copyright 2022 Istituto Italiano di Tecnologia Released under the terms of the Creative Commons Attribution Share Alike 4.0 International

from os import listdir
from os.path import dirname, join, isdir, exists
from typing import List


def get_models_path() -> str:
root = dirname(dirname(dirname(dirname(dirname(__file__)))))
return join(root, 'share', 'icub_models', 'iCub', 'robots')

def get_robot_names() -> List[str]:
return listdir(get_models_path())

def get_model_file(robot_name: str) -> str:
model_file = join(get_models_path(), robot_name, 'model.urdf')

if exists(model_file):
return model_file
else:
return ''
32 changes: 32 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (C) 2022 Istituto Italiano di Tecnologia (IIT). All rights reserved.
# This software may be modified and distributed under the terms of the
# Released under the terms of the BSD 3-Clause License

[metadata]
name = icub_models
description = Visualizer for robot logger
author = 'Giulio Romualdi'
author_email = 'giulio.romualdi@iit.it'
license = Creative Commons Attribution Share Alike 4.0 International
license_file = LICENSE
url = /~https://github.com/robotolgy/icub-models
version = 1.23.0
platforms = any

keywords =
robotics
gazebo
urdf
ros
icub
gazebo-models
gazebo-simulators

[options]
packages = find:
python_requires = >=3.8
package_dir =
= python

[options.packages.find]
where = python
17 changes: 17 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (C) 2022 Istituto Italiano di Tecnologia (IIT). All rights reserved.
# This software may be modified and distributed under the terms of the
# Released under the terms of the BSD 3-Clause License

from setuptools import setup
from glob import glob
import os


if __name__ == '__main__':

all_files = glob('./iCub/**/*.*', recursive=True)
data_files = [(os.path.join('share', 'icub_models', os.path.split(path)[0]),
[os.path.join(os.path.split(path)[0], os.path.split(path)[1])])
for path in all_files]

setup(data_files = data_files)

0 comments on commit a8d5d01

Please sign in to comment.