From 073ec99cbd10ffd574d77a3af3cea4a3de78a668 Mon Sep 17 00:00:00 2001 From: Diego Ferigo Date: Wed, 20 Oct 2021 11:18:49 +0200 Subject: [PATCH] Check that the python packages versions match the conda version --- recipes/gym-ignition/build_gym_ignition.sh | 5 +++++ recipes/gym-ignition/build_scenariopy.sh | 7 ++++++- recipes/gym-ignition/meta.yaml | 2 ++ recipes/gym-ignition/sed.py | 17 +++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100755 recipes/gym-ignition/sed.py diff --git a/recipes/gym-ignition/build_gym_ignition.sh b/recipes/gym-ignition/build_gym_ignition.sh index 9fba6d07aba86..ccf6ef6086b9c 100644 --- a/recipes/gym-ignition/build_gym_ignition.sh +++ b/recipes/gym-ignition/build_gym_ignition.sh @@ -1 +1,6 @@ +# Fix Python package version +$PYTHON ${RECIPE_DIR}/sed.py -f setup.cfg --pre "name=gym-ignition" --post "name=gym-ignition\nversion=$PKG_VERSION" +$PYTHON ${RECIPE_DIR}/sed.py -f pyproject.toml --pre "[tool.setuptools_scm]" --post "" +$PYTHON ${RECIPE_DIR}/sed.py -f pyproject.toml --pre 'local_scheme = "dirty-tag"' --post "" + pip install --no-build-isolation --no-deps . diff --git a/recipes/gym-ignition/build_scenariopy.sh b/recipes/gym-ignition/build_scenariopy.sh index 4961b5b74d5f3..177b124f8a520 100644 --- a/recipes/gym-ignition/build_scenariopy.sh +++ b/recipes/gym-ignition/build_scenariopy.sh @@ -1,4 +1,9 @@ -python \ +# Fix Python package version +$PYTHON ${RECIPE_DIR}/sed.py -f setup.cfg --pre "name=scenario" --post "name=scenario\nversion=$PKG_VERSION" +$PYTHON ${RECIPE_DIR}/sed.py -f pyproject.toml --pre "[tool.setuptools_scm]" --post "" +$PYTHON ${RECIPE_DIR}/sed.py -f pyproject.toml --pre 'local_scheme = "dirty-tag"' --post "" + +$PYTHON \ -m build \ --wheel \ --outdir dist \ diff --git a/recipes/gym-ignition/meta.yaml b/recipes/gym-ignition/meta.yaml index 7ce5c3fd85dc6..fa72e9b2b43eb 100644 --- a/recipes/gym-ignition/meta.yaml +++ b/recipes/gym-ignition/meta.yaml @@ -90,6 +90,7 @@ outputs: - scenario commands: - pip check + - test $(pip list | grep scenario | tr -s " " | grep $PKG_VERSION | wc -l) -eq 1 # [unix] requires: - pip @@ -139,6 +140,7 @@ outputs: - gym_ignition commands: # - pip check (needs idyntree installed with pip during conda build) + - 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 requires: diff --git a/recipes/gym-ignition/sed.py b/recipes/gym-ignition/sed.py new file mode 100755 index 0000000000000..013ded7708c1c --- /dev/null +++ b/recipes/gym-ignition/sed.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +import argparse +import fileinput + +if __name__ == "__main__": + + parser = argparse.ArgumentParser() + parser.add_argument("-f", "--file", type=str) + parser.add_argument("--pre", type=str) + parser.add_argument("--post", type=str) + + args = parser.parse_args() + + # This context redirects stdout to the file changing it in place + with fileinput.FileInput(args.file, inplace=True, backup='.bak') as file: + for line in file: + print(line.replace(args.pre, args.post), end='')