diff --git a/recipes/gym-ignition/activate.sh b/recipes/gym-ignition/activate.sh new file mode 100644 index 0000000000000..595856d26d5e5 --- /dev/null +++ b/recipes/gym-ignition/activate.sh @@ -0,0 +1 @@ +export IGN_GAZEBO_SYSTEM_PLUGIN_PATH="${IGN_GAZEBO_SYSTEM_PLUGIN_PATH}:${CONDA_PREFIX}/lib/scenario/plugins" diff --git a/recipes/gym-ignition/build_gym_ignition.bat b/recipes/gym-ignition/build_gym_ignition.bat new file mode 100644 index 0000000000000..f7ae1893253a1 --- /dev/null +++ b/recipes/gym-ignition/build_gym_ignition.bat @@ -0,0 +1,40 @@ +set section=##[section] + +echo. +echo %section%===================== +echo %section%Building gym-ignition +echo %section%===================== +echo. + +:: Print the CI environment +echo ##[group] Environment +set +echo ##[endgroup] +echo. + +:: Fix Python package version +sed -i.orig 's|name = gym_ignition|name = gym_ignition\'$'\nversion =|g' setup.cfg +sed -i.tmp "s|version =|version = $PKG_VERSION|g" setup.cfg +diff -u setup.cfg.orig setup.cfg + +:: Disable setuptools_scm +sed -i.orig "s|\[tool.setuptools_scm\]||g" pyproject.toml +sed -i.tmp 's|local_scheme = "dirty-tag"||g' pyproject.toml +diff -u pyproject.toml.orig pyproject.toml + +:: Delete wheel folder +rmdir /s /q _dist_conda + +:: Install Python package +%PYTHON% -m pip install ^ + --no-build-isolation --no-deps ^ + . +if errorlevel 1 exit 1 + +:: Restore original files +move /y setup.cfg.orig setup.cfg +if errorlevel 1 exit 1 +move /y pyproject.toml.orig pyproject.toml +if errorlevel 1 exit 1 + +echo "${section}Finishing: building gym-ignition" diff --git a/recipes/gym-ignition/build_gym_ignition.sh b/recipes/gym-ignition/build_gym_ignition.sh new file mode 100644 index 0000000000000..a4970b4084bbc --- /dev/null +++ b/recipes/gym-ignition/build_gym_ignition.sh @@ -0,0 +1,32 @@ +test "$CI" = "azure" && section="##[section]" || section="" + +echo +echo "${section}=============================" +echo "${section}Building gym-ignition (py$PY_VER)" +echo "${section}=============================" +echo + +# Print the CI environment +echo "##[group] Environment" +env +echo "##[endgroup]" +echo + +# Fix Python package version +sed -i.orig 's|name = gym_ignition|name = gym_ignition\'$'\nversion =|g' setup.cfg +sed -i.tmp "s|version =|version = $PKG_VERSION|g" setup.cfg +diff -u setup.cfg{.orig,} || true + +# Disable setuptools_scm +sed -i.orig "s|\[tool.setuptools_scm\]||g" pyproject.toml +sed -i.tmp 's|local_scheme = "dirty-tag"||g' pyproject.toml +diff -u pyproject.toml{.orig,} || true + +# Install Python package +pip install --no-build-isolation --no-deps . + +# Restore original files +mv setup.cfg{.orig,} +mv pyproject.toml{.orig,} + +echo "${section}Finishing: building gym-ignition" diff --git a/recipes/gym-ignition/build_libscenario.bat b/recipes/gym-ignition/build_libscenario.bat new file mode 100644 index 0000000000000..cbfbdcbb65b69 --- /dev/null +++ b/recipes/gym-ignition/build_libscenario.bat @@ -0,0 +1,36 @@ +set section=##[section] + +echo. +echo %section%==================== +echo %section%Building libscenario +echo %section%==================== +echo. + +:: Print the CI environment +echo ##[group] Environment +set +echo ##[endgroup] +echo. + +:: Configure the CMake project +cmake ^ + -S .\scenario\ ^ + -B build\ ^ + -GNinja ^ + -DCMAKE_BUILD_TYPE=Release ^ + -DCMAKE_INSTALL_PREFIX:PATH=%LIBRARY_PREFIX% ^ + -DSCENARIO_USE_IGNITION:BOOL=ON ^ + -DSCENARIO_ENABLE_BINDINGS:BOOL=OFF +if errorlevel 1 exit 1 + +:: Compile the CMake project +cmake --build build\ +if errorlevel 1 exit 1 + +:: Install the CMake project +cmake --install build\ +if errorlevel 1 exit 1 + +:: TODO: activate / deactivate + +echo %section%Finishing: building libscenario diff --git a/recipes/gym-ignition/build_libscenario.sh b/recipes/gym-ignition/build_libscenario.sh new file mode 100644 index 0000000000000..eeb176b764c38 --- /dev/null +++ b/recipes/gym-ignition/build_libscenario.sh @@ -0,0 +1,42 @@ +test "$CI" = "azure" && section="##[section]" || section="" + +echo +echo "${section}====================" +echo "${section}Building libscenario" +echo "${section}====================" +echo + +# Print the CI environment +echo "##[group] Environment" +env +echo "##[endgroup]" +echo + +# Create a temp build folder +build_folder=$(mktemp -d) + +# Configure the CMake project +cmake \ + -S ./scenario/ \ + -B ${build_folder}/ \ + -GNinja \ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX \ + -DSCENARIO_USE_IGNITION:BOOL=ON \ + -DSCENARIO_ENABLE_BINDINGS:BOOL=OFF + +# Compile the CMake project +cmake --build ${build_folder}/ + +# Install the CMake project +cmake --install ${build_folder}/ + +# Copy the [de]activate scripts to $PREFIX/etc/conda/[de]activate.d. +# This will allow them to be run on environment activation. +for CHANGE in "activate" "deactivate" ; do + mkdir -p "${PREFIX}/etc/conda/${CHANGE}.d" + cp "${RECIPE_DIR}/${CHANGE}.sh" "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.sh" +done + +echo "${section}Finishing: building libscenario" diff --git a/recipes/gym-ignition/build_scenario.bat b/recipes/gym-ignition/build_scenario.bat new file mode 100644 index 0000000000000..c351e96aa2a3a --- /dev/null +++ b/recipes/gym-ignition/build_scenario.bat @@ -0,0 +1,7 @@ +set section=##[section] + +echo. +echo %section%================= +echo %section%Building scenario +echo %section%================= +echo. diff --git a/recipes/gym-ignition/build_scenario.sh b/recipes/gym-ignition/build_scenario.sh new file mode 100644 index 0000000000000..fa0175dccbc7d --- /dev/null +++ b/recipes/gym-ignition/build_scenario.sh @@ -0,0 +1,7 @@ +test "$CI" = "azure" && section="##[section]" || section="" + +echo +echo "${section}=================" +echo "${section}Building scenario" +echo "${section}=================" +echo diff --git a/recipes/gym-ignition/build_scenariopy.bat b/recipes/gym-ignition/build_scenariopy.bat new file mode 100644 index 0000000000000..f024db6d6ae53 --- /dev/null +++ b/recipes/gym-ignition/build_scenariopy.bat @@ -0,0 +1,62 @@ +set section=##[section] + +echo. +echo %section%=================== +echo %section%Building scenariopy +echo %section%=================== +echo. + +:: Print the CI environment +echo ##[group] Environment +set +echo ##[endgroup] +echo. + +:: Fix Python package version +sed -i.orig "s|name = scenario|name = scenario\nversion =|g" scenario\setup.cfg +sed -i.tmp "s|version =|version = %PKG_VERSION%|g" scenario\setup.cfg +diff -u scenario\setup.cfg.orig scenario\setup.cfg + +:: Disable setuptools_scm +sed -i.orig "s|\[tool.setuptools_scm\]||g" scenario\pyproject.toml +sed -i.tmp "s|root = ""../""||g" scenario\pyproject.toml +sed -i.tmp "s|local_scheme = ""dirty-tag""||g" scenario\pyproject.toml +diff -u scenario\pyproject.toml.orig scenario\pyproject.toml + +:: Delete wheel folder +rmdir /s /q _dist_conda + +:: Generate the wheel +%PYTHON% ^ + -m build ^ + --wheel ^ + --outdir _dist_conda\ ^ + --no-isolation ^ + --skip-dependency-check ^ + "-C--global-option=build_ext" ^ + "-C--global-option=-DSCENARIO_BUILD_SHARED_LIBRARY:BOOL=ON" ^ + "-C--global-option=--component=python" ^ + .\scenario\ +if errorlevel 1 exit 1 + +:: Delete the build folder +rmdir /s /q build/ + +:: Install Python package +%PYTHON% -m pip install ^ + --no-index --find-links=.\_dist_conda\ ^ + --no-build-isolation --no-deps ^ + scenario +if errorlevel 1 exit 1 + +:: Delete wheel folder +rmdir /s /q _dist_conda\ +if errorlevel 1 exit 1 + +:: Restore original files +move /y scenario\setup.cfg.orig scenario\setup.cfg +if errorlevel 1 exit 1 +move /y scenario\pyproject.toml.orig scenario\pyproject.toml +if errorlevel 1 exit 1 + +echo %section%Finishing: building scenariopy diff --git a/recipes/gym-ignition/build_scenariopy.sh b/recipes/gym-ignition/build_scenariopy.sh new file mode 100644 index 0000000000000..3fb5f66448ecc --- /dev/null +++ b/recipes/gym-ignition/build_scenariopy.sh @@ -0,0 +1,57 @@ +test "$CI" = "azure" && section="##[section]" || section="" + +echo +echo "${section}===========================" +echo "${section}Building scenariopy (py$PY_VER)" +echo "${section}===========================" +echo + +# Print the CI environment +echo "##[group] Environment" +env +echo "##[endgroup]" +echo + +# Fix Python package version +sed -i.orig 's|name = scenario|name = scenario\'$'\nversion =|g' scenario/setup.cfg +sed -i.tmp "s|version =|version = $PKG_VERSION|g" scenario/setup.cfg +diff -u scenario/setup.cfg{.orig,} || true + +# Disable setuptools_scm +sed -i.orig "s|\[tool.setuptools_scm\]||g" scenario/pyproject.toml +sed -i.tmp 's|root = "../"||g' scenario/pyproject.toml +sed -i.tmp 's|local_scheme = "dirty-tag"||g' scenario/pyproject.toml +diff -u scenario/pyproject.toml{.orig,} || true + +# Create a temp dist folder +dist_folder=$(mktemp -d) + +# Delete the build folder +rm -rf build/ + +# Generate the wheel +$PYTHON \ + -m build \ + --wheel \ + --outdir ${dist_folder}/ \ + --no-isolation \ + --skip-dependency-check \ + "-C--global-option=build_ext" \ + "-C--global-option=-DSCENARIO_BUILD_SHARED_LIBRARY:BOOL=ON" \ + "-C--global-option=--component=python" \ + ./scenario/ + +# Delete the build folder +rm -rf build/ + +# Install Python package +pip install \ + --no-index --find-links=${dist_folder}/ \ + --no-build-isolation --no-deps \ + scenario + +# Restore original files +mv scenario/setup.cfg{.orig,} +mv scenario/pyproject.toml{.orig,} + +echo "${section}Finishing: building scenariopy" \ No newline at end of file diff --git a/recipes/gym-ignition/conda_build_config.yaml b/recipes/gym-ignition/conda_build_config.yaml new file mode 100644 index 0000000000000..68950115fa205 --- /dev/null +++ b/recipes/gym-ignition/conda_build_config.yaml @@ -0,0 +1,8 @@ +MACOSX_DEPLOYMENT_TARGET: # [osx and x86_64] + - "10.13" # [osx and x86_64] +MACOSX_SDK_VERSION: # [osx and x86_64] + - "10.13" # [osx and x86_64] +c_compiler: # [win] + - vs2019 # [win] +cxx_compiler: # [win] + - vs2019 # [win] diff --git a/recipes/gym-ignition/deactivate.sh b/recipes/gym-ignition/deactivate.sh new file mode 100644 index 0000000000000..4b62852ce4c3a --- /dev/null +++ b/recipes/gym-ignition/deactivate.sh @@ -0,0 +1 @@ +export IGN_GAZEBO_SYSTEM_PLUGIN_PATH="$(echo $IGN_GAZEBO_SYSTEM_PLUGIN_PATH | tr ':' '\n' | grep -v "$CONDA_PREFIX/lib/scenario/plugins" | grep -v '^$' | tr '\n' ':')" diff --git a/recipes/gym-ignition/meta.yaml b/recipes/gym-ignition/meta.yaml new file mode 100644 index 0000000000000..211d2e8ea17e6 --- /dev/null +++ b/recipes/gym-ignition/meta.yaml @@ -0,0 +1,218 @@ +{% set name = "gym-ignition" %} +{% set version = "1.3.1" %} + +package: + name: {{ name|lower }} + version: {{ version }} + +source: + url: https://github.com/robotology/gym-ignition/archive/refs/tags/v{{ version }}.tar.gz + sha256: ec6f49a584ce6b0aaba2c89f9f628abbc7cdcd750e0bbdf1106f3527abd7f38f + +build: + number: 0 + skip: true # [win or osx] + +outputs: + + - name: libscenario + script: build_libscenario.sh # [unix] + script: build_libscenario.bat # [win] + build: + skip: true # [win or osx] + # Note: run_exports does not work in the subpackages of the same recipe + # https://github.com/conda/conda-build/issues/3478 + run_exports: + - {{ pin_subpackage("libscenario", max_pin="x.x") }} + requirements: + build: + - cmake + - ninja + - pkg-config + - clang # [win] + - vs2019_win-32 # [win32] + - vs2019_win-64 # [win64] + - {{ compiler("c") }} + - {{ compiler("cxx") }} + - {{ cdt("mesa-libgl-devel") }} # [linux] + - sed # [unix] + - m2-sed # [win] + - diffutils # [unix] + - m2-diffutils # [win] + host: + - eigen + - idyntree + - libignition-gazebo6 + run: + - __osx >={{ MACOSX_DEPLOYMENT_TARGET|default("10.9") }} # [osx and x86_64] + # Require idyntree x.x since idyntree-feedstock just requires x + - {{ pin_compatible('idyntree', max_pin="x.x") }} + # These should be exported by libignition-gazebo6 + - {{ pin_compatible('libignition-common4') }} + - {{ pin_compatible('libignition-fuel-tools7') }} + - {{ pin_compatible('libignition-math6') }} + - {{ pin_compatible('libignition-msgs8') }} + - {{ pin_compatible('libignition-physics5') }} + - {{ pin_compatible('libignition-plugin1') }} + - {{ pin_compatible('libignition-transport11') }} + - {{ pin_compatible('libsdformat12') }} + # Not sure why conda render just pins x instead of x.x like libprotobuf-feedstock. + # Maybe because there's no explicit protobuf in host. + - {{ pin_compatible('libprotobuf', max_pin="x.x") }} + test: + commands: + # Inspect activate scripts + - env | grep IGN_GAZEBO_SYSTEM_PLUGIN_PATH # [unix] + - set IGN_GAZEBO_SYSTEM_PLUGIN_PATH # [win] + # Check existence of ScenarIO Gazebo library + - test -f ${PREFIX}/lib/libGazeboSimulator.so # [linux] + - test -f ${PREFIX}/lib/libGazeboSimulator.dylib # [osx] + - if not exist %PREFIX%\\Library\\lib\\GazeboSimulator.lib exit 1 # [win] + # Check existence of ScenarIO and ScenarIO Gazebo CMake targets + - test -f ${PREFIX}/lib/cmake/Scenario/ScenarioConfig.cmake # [unix] + - test -f ${PREFIX}/lib/cmake/ScenarioGazebo/ScenarioGazeboConfig.cmake # [unix] + - if not exist %PREFIX%\\Library\\lib\\cmake\\Scenario\\ScenarioConfig.cmake exit 1 # [win] + - if not exist %PREFIX%\\Library\\lib\\cmake\\ScenarioGazebo\\ScenarioGazeboConfig.cmake exit 1 # [win] + + - name: scenariopy + script: build_scenariopy.sh # [unix] + script: build_scenariopy.bat # [win] + build: + skip: true # [win or osx or py<38] + requirements: + build: + - clang # [win] + - vs2019_win-32 # [win32] + - vs2019_win-64 # [win64] + - cmake + - {{ compiler("c") }} + - {{ compiler("cxx") }} + - ninja + - pkg-config + - swig + - sed # [unix] + - m2-sed # [win] + - diffutils # [unix] + - m2-diffutils # [win] + # https://conda-forge.org/docs/maintainer/knowledge_base.html#libgl + # Should these be handled by the Ignition Gazebo recipe? + # Without them, CMake fails with: Failed to find "GL/gl.h". + - {{ cdt('mesa-libgl-devel') }} # [linux] + - {{ cdt('mesa-dri-drivers') }} # [linux] + - {{ cdt('libselinux') }} # [linux] + - {{ cdt('libxdamage') }} # [linux] + - {{ cdt('libxxf86vm') }} # [linux] + - {{ cdt('libxext') }} # [linux] + host: + - build + - cmake-build-extension + - idyntree + - libignition-gazebo6 + - pip + - python + # https://conda-forge.org/docs/maintainer/knowledge_base.html#libgl + - xorg-libxfixes # [linux] + # Here just to make DSO happy, it is a run-only requirement + - {{ pin_subpackage("libscenario", exact=True) }} + run: + # Require idyntree x.x since idyntree-feedstock just requires x + - {{ pin_compatible('idyntree', max_pin="x.x") }} + # Manually specify the run_exports of libscenario since they are not + # applied to subpackages of the same recipe + # https://github.com/conda/conda-build/issues/3478 + # Here we also need to pin an exact version and not just a compatible one + - {{ pin_subpackage("libscenario", exact=True) }} + - packaging + - python + test: + imports: + - scenario + commands: + - pip check + - test $(pip list | grep scenario | tr -s " " | grep $PKG_VERSION | wc -l) -eq 1 # [unix] + requires: + - pip + + - name: scenario + script: build_scenario.sh # [unix] + script: build_scenario.bat # [win] + build: + skip: true # [win or osx or py<38] + requirements: + run: + - {{ pin_subpackage("libscenario", exact=True) }} + - {{ pin_subpackage("scenariopy", exact=True) }} + test: + imports: + - scenario + commands: + - pip check + # Inspect activate scripts + - env | grep IGN_GAZEBO_SYSTEM_PLUGIN_PATH # [unix] + - set IGN_GAZEBO_SYSTEM_PLUGIN_PATH # [win] + # Check existence of ScenarIO Gazebo library + - test -f ${PREFIX}/lib/libGazeboSimulator.so # [linux] + - test -f ${PREFIX}/lib/libGazeboSimulator.dylib # [osx] + - if not exist %PREFIX%\\Library\\lib\\GazeboSimulator.lib exit 1 # [win] + # Check existence of ScenarIO and ScenarIO Gazebo CMake targets + - test -f ${PREFIX}/lib/cmake/Scenario/ScenarioConfig.cmake # [unix] + - test -f ${PREFIX}/lib/cmake/ScenarioGazebo/ScenarioGazeboConfig.cmake # [unix] + - if not exist %PREFIX%\\Library\\lib\\cmake\\Scenario\\ScenarioConfig.cmake exit 1 # [win] + - if not exist %PREFIX%\\Library\\lib\\cmake\\ScenarioGazebo\\ScenarioGazeboConfig.cmake exit 1 # [win] + requires: + - pip + +# Disabled due to https://github.com/conda-forge/staged-recipes/pull/16582#issuecomment-951088666 +# +# - name: gym-ignition +# script: build_gym_ignition.sh # [unix] +# script: build_gym_ignition.bat # [win] +# build: +# skip: true # [win or osx or py<38] +# noarch: python +# requirements: +# build: +# - sed # [unix] +# - m2-sed # [win] +# - diffutils # [unix] +# - m2-diffutils # [win] +# host: +# - pip +# - python +# run: +# - gym +# - gym-ignition-models +# - idyntree +# - lxml +# - numpy +# - python +# - {{ pin_subpackage("scenariopy", max_pin="x.x") }} +# - scipy +# test: +# source_files: +# - tests +# - setup.cfg +# imports: +# - gym_ignition +# commands: +# # - pip check (requires https://github.com/conda-forge/idyntree-feedstock/pull/8) +# - test $(pip list | grep gym-ignition | tr -s " " | grep $PKG_VERSION | wc -l) -eq 1 # [unix] +# - sed -i "s|def test_angular_acceleration|def _test_angular_acceleration|g" tests/test_scenario/test_link_velocities.py +# - pytest # [linux] +# requires: +# - pip +# - pytest +# - pytest-icdiff +# - sed # [unix] +# - m2-sed # [win] + +about: + home: https://github.com/robotology/gym-ignition + summary: A toolkit for developing OpenAI Gym environments simulated with Ignition Gazebo. + dev_url: https://github.com/robotology/gym-ignition + license: LGPL-2.1-or-later + license_file: LICENSE + +extra: + recipe-maintainers: + - diegoferigo diff --git a/recipes/gym-ignition/yum_requirements.txt b/recipes/gym-ignition/yum_requirements.txt new file mode 100644 index 0000000000000..651811b765d80 --- /dev/null +++ b/recipes/gym-ignition/yum_requirements.txt @@ -0,0 +1,6 @@ +mesa-libGL +mesa-dri-drivers +libselinux +libXdamage +libXxf86vm +libXext