From 90efcd03ac0306fc6d7b165181099ce4f22a488a Mon Sep 17 00:00:00 2001
From: Guilhem Saurel <guilhem.saurel@laas.fr>
Date: Fri, 9 Oct 2020 14:02:42 +0200
Subject: [PATCH] manylinux: use TARGET instead of PACKAGE_NAME

---
 docker/manylinux2014/README.md                     | 3 +--
 docker/manylinux2014/all.sh                        | 3 +--
 docker/manylinux2014/config/eigenpy/config         | 3 +--
 docker/manylinux2014/config/hpp-fcl/config         | 3 +--
 docker/manylinux2014/config/pinocchio/config       | 5 ++---
 docker/manylinux2014/config/pinocchio/pre_build.sh | 2 +-
 docker/manylinux2014/scripts/build_wheels.sh       | 8 ++++----
 docker/manylinux2014/scripts/setup.py              | 4 ++--
 docker/manylinux2014/scripts/setup.sh              | 6 +++---
 docker/manylinux2014/test.sh                       | 3 +--
 10 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/docker/manylinux2014/README.md b/docker/manylinux2014/README.md
index 4020d53..b2bcc67 100644
--- a/docker/manylinux2014/README.md
+++ b/docker/manylinux2014/README.md
@@ -24,12 +24,11 @@ docker run --rm -it manylinux-test
 ## Upload the wheels on PyPi
 
 ```
-twine upload wheelhouse/*
+twine upload dist/*
 ```
 
 ## TODO
 
-- use TARGET instead of PACKAGE_NAME: hpp-fcl on PyPI
 - use robotpkg to build, instead of downloading the sources: could build all non-python stuff in the docker image
 - pyproject.toml in skbuild doc
 - lib/pythonX.Y/site-packages/foo.cpython\*.so links to libfoo.so and has RPATH: $ORIGIN/../../../foo.libs
diff --git a/docker/manylinux2014/all.sh b/docker/manylinux2014/all.sh
index 3ec2b36..139d41a 100755
--- a/docker/manylinux2014/all.sh
+++ b/docker/manylinux2014/all.sh
@@ -1,8 +1,7 @@
 #!/bin/bash -eux
 
-sudo touch dist wheelhouse
-sudo rm -rf dist wheelhouse
 docker build -t manylinux .
+docker run -v "$(pwd -P):/io" -t manylinux rm -rf /io/dist /io/wheelhouse
 docker run -v "$(pwd -P):/io" -t manylinux /scripts/setup.sh eigenpy
 docker run -v "$(pwd -P):/io" -t manylinux /scripts/setup.sh hpp-fcl
 docker run -v "$(pwd -P):/io" -t manylinux /scripts/setup.sh pinocchio
diff --git a/docker/manylinux2014/config/eigenpy/config b/docker/manylinux2014/config/eigenpy/config
index c7c1f47..a0136ab 100644
--- a/docker/manylinux2014/config/eigenpy/config
+++ b/docker/manylinux2014/config/eigenpy/config
@@ -1,5 +1,4 @@
-PACKAGE_NAME=eigenpy
-GITHUB_ORG=stack-of-tasks
+ORG=stack-of-tasks
 VERSION=2.5.0
 INSTALL_REQUIRES='["numpy"]'
 NPROC=8
diff --git a/docker/manylinux2014/config/hpp-fcl/config b/docker/manylinux2014/config/hpp-fcl/config
index dd2969d..5c77d6c 100644
--- a/docker/manylinux2014/config/hpp-fcl/config
+++ b/docker/manylinux2014/config/hpp-fcl/config
@@ -1,5 +1,4 @@
-PACKAGE_NAME=hppfcl
-GITHUB_ORG=humanoid-path-planner
+ORG=humanoid-path-planner
 VERSION=1.6.0
 INSTALL_REQUIRES='["eigenpy"]'
 NPROC=8
diff --git a/docker/manylinux2014/config/pinocchio/config b/docker/manylinux2014/config/pinocchio/config
index 78f44d8..ef0af2e 100644
--- a/docker/manylinux2014/config/pinocchio/config
+++ b/docker/manylinux2014/config/pinocchio/config
@@ -1,5 +1,4 @@
-PACKAGE_NAME=pinocchio
-GITHUB_ORG=stack-of-tasks
+ORG=stack-of-tasks
 VERSION=2.5.0
-INSTALL_REQUIRES='["hppfcl"]'
+INSTALL_REQUIRES='["hpp-fcl"]'
 NPROC=8
diff --git a/docker/manylinux2014/config/pinocchio/pre_build.sh b/docker/manylinux2014/config/pinocchio/pre_build.sh
index aeaca83..c579982 100755
--- a/docker/manylinux2014/config/pinocchio/pre_build.sh
+++ b/docker/manylinux2014/config/pinocchio/pre_build.sh
@@ -3,5 +3,5 @@
 source "/io/config/hpp-fcl/config"
 
 for PYBIN in /opt/python/*/bin; do
-  "$PYBIN/pip" install --find-links=/io/dist/ eigenpy hppfcl
+  "$PYBIN/pip" install --find-links=/io/dist/ eigenpy hpp-fcl
 done
diff --git a/docker/manylinux2014/scripts/build_wheels.sh b/docker/manylinux2014/scripts/build_wheels.sh
index da91bb2..a4a3079 100755
--- a/docker/manylinux2014/scripts/build_wheels.sh
+++ b/docker/manylinux2014/scripts/build_wheels.sh
@@ -62,8 +62,8 @@ done
 # Install packages and test
 for PYBIN in /opt/python/*/bin; do
     PYVERSION=$(find "$PYBIN" -type f -name 'python*.*' | head -1 | grep -Eo "[0-9]\.[0-9]")
-    "$PYBIN/pip" install "$PACKAGE_NAME" --no-index --find-links=/io/wheelhouse/
-    (cd "$HOME"; "$PYBIN/python" "/io/config/$TARGET/test.py") || touch "/io/wheelhouse/$PYVERSION-$PACKAGE_NAME"
+    "$PYBIN/pip" install "$TARGET" --no-index --find-links=/io/wheelhouse/
+    (cd "$HOME"; "$PYBIN/python" "/io/config/$TARGET/test.py") || touch "/io/wheelhouse/$PYVERSION-$TARGET"
 done
 
 # TODO: Fix generated .cmake files (need to be done after installing the wheels so we know where the shared libraries are installed)
@@ -72,7 +72,7 @@ for whl in /io/wheelhouse/*.whl; do
 
   WHEEL_DIR=$(find . -name *.so | head -1 | cut -d'/' -f2)
   PYVERSION=$(find "$WHEEL_DIR" -type d -name 'python*' | grep 'lib/python' | tail -c4)
-  MAIN_LIB=$(find / ! -path "*$WHEEL_DIR*" -path "*$PYVERSION*$PACKAGE_NAME*.libs/*" -name "*$PACKAGE_NAME*.so*")
+  MAIN_LIB=$(find / ! -path "*$WHEEL_DIR*" -path "*$PYVERSION*$TARGET*.libs/*" -name "*$TARGET*.so*")
   MAIN_LIB_NAME=$(basename "$MAIN_LIB") # libeigenpy-[hash].so
   MAIN_LIB_NAME_NO_HASH=$(echo $MAIN_LIB_NAME | sed 's/-.*\.so/\.so/') # libeigenpy.so
 
@@ -88,7 +88,7 @@ for whl in /io/wheelhouse/*.whl; do
   rm -rf "${WHEEL_DIR:?}"/
 done
 
-rm -rf "$PACKAGE_NAME".egg-info/ dist/
+rm -rf "$TARGET".egg-info/ dist/
 
 mkdir -p /io/dist
 mv /io/wheelhouse/* /io/dist/
diff --git a/docker/manylinux2014/scripts/setup.py b/docker/manylinux2014/scripts/setup.py
index 6d3a958..b2939af 100644
--- a/docker/manylinux2014/scripts/setup.py
+++ b/docker/manylinux2014/scripts/setup.py
@@ -7,12 +7,12 @@ except FileNotFoundError:
     long_description = ""
 
 setup(
-    name="PACKAGE_NAME",
+    name="TARGET",
     version="VERSION",
     description="DESCRIPTION",
     long_description=long_description,
     long_description_content_type="text/markdown",
-    url="https://github.com/GITHUB_ORG/TARGET",
+    url="https://github.com/ORG/TARGET",
     install_requires=INSTALL_REQUIRES,
     classifiers=[
         "Programming Language :: Python :: 2", "Programming Language :: Python :: 3",
diff --git a/docker/manylinux2014/scripts/setup.sh b/docker/manylinux2014/scripts/setup.sh
index 53f5f91..8a36c39 100755
--- a/docker/manylinux2014/scripts/setup.sh
+++ b/docker/manylinux2014/scripts/setup.sh
@@ -4,14 +4,14 @@ TARGET=${1:-eigenpy}
 
 # Verify that variables are set properly
 source "/io/config/$TARGET/config"
-for var in PACKAGE_NAME GITHUB_ORG VERSION NPROC; do
+for var in ORG VERSION NPROC; do
   [ -z "${!var}" ] && { echo "$var is not set."; exit; }
 done
 
 mkdir -p /io/wheelhouse
 [ "$(ls -A /io/wheelhouse)" ] && { echo "./wheelhouse should be empty before running this script."; exit; }
 
-curl -sSL "https://github.com/$GITHUB_ORG/$TARGET/releases/download/v$VERSION/$TARGET-$VERSION.tar.gz" \
+curl -sSL "https://github.com/$ORG/$TARGET/releases/download/v$VERSION/$TARGET-$VERSION.tar.gz" \
     | tar xz --strip-components=1 2> /dev/null
 
 cp /scripts/setup.py .
@@ -22,7 +22,7 @@ sed -i 's/REQUIRED COMPONENTS Interpreter Development/REQUIRED COMPONENTS Interp
 
 # Write setup.py
 DESCRIPTION=$(grep PROJECT_DESCRIPTION CMakeLists.txt | cut -d'"' -f2) # TODO: Not working on multiple lines
-for var in PACKAGE_NAME GITHUB_ORG TARGET VERSION DESCRIPTION; do
+for var in ORG TARGET VERSION DESCRIPTION; do
   sed -i "s~$var~${!var}~" setup.py
 done
 
diff --git a/docker/manylinux2014/test.sh b/docker/manylinux2014/test.sh
index cae4a40..e687a54 100755
--- a/docker/manylinux2014/test.sh
+++ b/docker/manylinux2014/test.sh
@@ -2,7 +2,6 @@
 
 while read tgt
 do  echo -e "\n================================ $tgt ===================================\n"
-    source "/$tgt/config"
-    pip install --find-links=/ "$PACKAGE_NAME"
+    pip install --find-links=/ "$tgt"
     python "/$tgt/test.py"
 done < targets
-- 
GitLab