summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Langlois2020-04-07 22:17:44 -0400
committerEric Langlois2020-04-07 22:18:13 -0400
commit92fd424c4f979013a7eacd72389056f57a0b091d (patch)
tree9564be9a094278b4e10cb5b5c0dea2770bf3ccbf
downloadaur-92fd424c4f979013a7eacd72389056f57a0b091d.tar.gz
Initial commit of python-mujoco-py PKGBUILD
-rw-r--r--.SRCINFO30
-rw-r--r--.gitignore5
-rw-r--r--PKGBUILD54
-rw-r--r--mujoco-py-2.0.2.9.patch119
4 files changed, 208 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..a8a391f22a42
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,30 @@
+pkgbase = python-mujoco-py
+ pkgdesc = Python interface to the MuJoCo physics engine
+ pkgver = 2.0.2.9
+ pkgrel = 1
+ url = https://github.com/openai/mujoco-py
+ arch = x86_64
+ license = MIT
+ license = custom
+ makedepends = python-setuptools
+ depends = cython
+ depends = glew
+ depends = libglvnd
+ depends = mesa-libgl
+ depends = mujoco
+ depends = python
+ depends = python-cffi
+ depends = python-fasteners
+ depends = python-glfw
+ depends = python-imageio
+ depends = python-numpy
+ options = !strip
+ source = https://files.pythonhosted.org/packages/source/m/mujoco-py/mujoco-py-2.0.2.9.tar.gz
+ source = mujoco-py-2.0.2.9-LICENSE.md::https://raw.githubusercontent.com/openai/mujoco-py/d73ce6e91d096b74da2a2fcb0a4164e10db5f641/LICENSE.md
+ source = mujoco-py-2.0.2.9.patch
+ sha256sums = 6ae20ca9509203758f5e30a7a4019cb2d581b6d40dc2c2669dbe3229cfdf05e8
+ sha256sums = fb896a8cbad505b0fe1f324e7d4f02032e56885c6544b7644180258d6077a71a
+ sha256sums = 5ac81282141cf7c5700b9967f85c4e9a3339a35a1bbdd3c383b877774525d660
+
+pkgname = python-mujoco-py
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000000..5d5bf80c0f73
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+src/
+pkg/
+*.tar.gz
+*.tar.xz
+mujoco-py-*-LICENSE.md
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..ea9280bbca18
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,54 @@
+# Maintainer: Eric Langlois <eric@langlois.xyz>
+pkgname=python-mujoco-py
+_name=${pkgname#python-}
+pkgver=2.0.2.9
+pkgrel=1
+pkgdesc="Python interface to the MuJoCo physics engine"
+arch=('x86_64')
+url="https://github.com/openai/mujoco-py"
+license=('MIT' 'custom')
+depends=(
+ 'cython'
+ 'glew'
+ 'libgl'
+ 'mesa'
+ 'mujoco'
+ 'python'
+ 'python-cffi'
+ 'python-fasteners'
+ 'python-glfw'
+ 'python-imageio'
+ 'python-numpy'
+)
+makedepends=('python-setuptools')
+optdepends=()
+# Stripping breaks the generated cymj_*.so file
+options=(!strip)
+# There is no license file included in the pip package
+# Get it from the mujoco-py github repo instead.
+# Also, there is no release marked for the recent pip package version,
+# so use the lastest commit (at the time of writing).
+source=("https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz"
+ "$_name-$pkgver-LICENSE.md::https://raw.githubusercontent.com/openai/mujoco-py/d73ce6e91d096b74da2a2fcb0a4164e10db5f641/LICENSE.md"
+ "$_name-$pkgver.patch")
+sha256sums=('6ae20ca9509203758f5e30a7a4019cb2d581b6d40dc2c2669dbe3229cfdf05e8'
+ 'fb896a8cbad505b0fe1f324e7d4f02032e56885c6544b7644180258d6077a71a'
+ '5ac81282141cf7c5700b9967f85c4e9a3339a35a1bbdd3c383b877774525d660')
+
+prepare() {
+ cd "$_name-$pkgver"
+ patch -p1 -i "$srcdir/$_name-$pkgver.patch"
+}
+
+build() {
+ cd "$_name-$pkgver"
+ python setup.py build
+}
+
+package() {
+ cd "$_name-$pkgver"
+ python setup.py install --root="$pkgdir" --optimize=1 --skip-build
+
+ install -Dm644 "$srcdir/$_name-$pkgver-LICENSE.md" \
+ "$pkgdir/usr/share/licenses/$pkgname/LICENSE.md"
+}
diff --git a/mujoco-py-2.0.2.9.patch b/mujoco-py-2.0.2.9.patch
new file mode 100644
index 000000000000..8fcbc136fb0b
--- /dev/null
+++ b/mujoco-py-2.0.2.9.patch
@@ -0,0 +1,119 @@
+diff --unified --recursive --text mujoco-py-2.0.2.9.orig/mujoco_py/builder.py mujoco-py-2.0.2.9.new/mujoco_py/builder.py
+--- mujoco-py-2.0.2.9.orig/mujoco_py/builder.py 2020-04-07 21:40:53.528385933 -0400
++++ mujoco-py-2.0.2.9.new/mujoco_py/builder.py 2020-04-07 21:39:20.261717094 -0400
+@@ -31,7 +31,7 @@
+ docker_path = '/usr/local/nvidia/lib64'
+ if exists(docker_path):
+ return docker_path
+- paths = glob.glob('/usr/lib/nvidia-[0-9][0-9][0-9]')
++ paths = glob.glob('/usr/lib/nvidia')
+ paths = sorted(paths)
+ if len(paths) == 0:
+ return None
+@@ -66,9 +66,7 @@
+ if sys.platform == 'darwin':
+ Builder = MacExtensionBuilder
+ elif sys.platform == 'linux':
+- _ensure_set_env_var("LD_LIBRARY_PATH", lib_path)
+ if os.getenv('MUJOCO_PY_FORCE_CPU') is None and get_nvidia_lib_dir() is not None:
+- _ensure_set_env_var("LD_LIBRARY_PATH", get_nvidia_lib_dir())
+ Builder = LinuxGPUExtensionBuilder
+ else:
+ Builder = LinuxCPUExtensionBuilder
+@@ -84,6 +82,13 @@
+ builder = Builder(mujoco_path)
+ cext_so_path = builder.get_so_file_path()
+
++ # Check if we have write access to the cext_so_path.
++ # If not, it's probably because mujoco-py has been installed and everything is
++ # read-only. Returning here is necessary because the lock creation will fail.
++ # It might be better to try-catch the lock but this minimizes the diff complexity.
++ if not os.access(os.path.dirname(cext_so_path), os.W_OK):
++ return load_dynamic_ext('cymj', cext_so_path)
++
+ lockpath = os.path.join(os.path.dirname(cext_so_path), 'mujocopy-buildlock')
+
+ with fasteners.InterProcessLock(lockpath):
+@@ -205,11 +210,10 @@
+ sources=[join(self.CYMJ_DIR_PATH, "cymj.pyx")],
+ include_dirs=[
+ self.CYMJ_DIR_PATH,
+- join(mujoco_path, 'include'),
++ "/usr/include/mujoco",
+ np.get_include(),
+ ],
+ libraries=['mujoco200'],
+- library_dirs=[join(mujoco_path, 'bin')],
+ extra_compile_args=[
+ '-fopenmp', # needed for OpenMP
+ '-w', # suppress numpy compilation warnings
+@@ -266,14 +270,13 @@
+
+ self.extension.sources.append(
+ join(self.CYMJ_DIR_PATH, "gl", "osmesashim.c"))
+- self.extension.libraries.extend(['glewosmesa', 'OSMesa', 'GL'])
+- self.extension.runtime_library_dirs = [join(mujoco_path, 'bin')]
++ self.extension.libraries.extend(['GLEW', 'OSMesa', 'GL'])
+
+ def _build_impl(self):
+ so_file_path = super()._build_impl()
+ # Removes absolute paths to libraries. Allows for dynamic loading.
+ fix_shared_library(so_file_path, 'libmujoco200.so', 'libmujoco200.so')
+- fix_shared_library(so_file_path, 'libglewosmesa.so', 'libglewosmesa.so')
++ fix_shared_library(so_file_path, 'libGLEW.so', 'libGLEW.so')
+ return so_file_path
+
+
+@@ -284,15 +287,14 @@
+
+ self.extension.sources.append(self.CYMJ_DIR_PATH + "/gl/eglshim.c")
+ self.extension.include_dirs.append(self.CYMJ_DIR_PATH + '/vendor/egl')
+- self.extension.libraries.extend(['glewegl'])
+- self.extension.runtime_library_dirs = [join(mujoco_path, 'bin')]
++ self.extension.libraries.extend(['GLEW'])
+
+ def _build_impl(self):
+ so_file_path = super()._build_impl()
+ fix_shared_library(so_file_path, 'libOpenGL.so', 'libOpenGL.so.0')
+ fix_shared_library(so_file_path, 'libEGL.so', 'libEGL.so.1')
+ fix_shared_library(so_file_path, 'libmujoco200.so', 'libmujoco200.so')
+- fix_shared_library(so_file_path, 'libglewegl.so', 'libglewegl.so')
++ fix_shared_library(so_file_path, 'libGLEW.so', 'libGLEW.so')
+ return so_file_path
+
+
+@@ -476,8 +478,7 @@
+ source_string += '\nuintptr_t __fun = (uintptr_t) fun;'
+ # Link against mujoco so we can call mujoco functions from within callback
+ ffibuilder.set_source(name, source_string,
+- include_dirs=[join(mujoco_path, 'include')],
+- library_dirs=[join(mujoco_path, 'bin')],
++ include_dirs=["/usr/include/mujoco"],
+ libraries=['mujoco200'])
+ # Catch compilation exceptions so we can cleanup partial files in that case
+ try:
+diff --unified --recursive --text mujoco-py-2.0.2.9.orig/mujoco_py/utils.py mujoco-py-2.0.2.9.new/mujoco_py/utils.py
+--- mujoco-py-2.0.2.9.orig/mujoco_py/utils.py 2020-04-07 21:40:53.548385935 -0400
++++ mujoco-py-2.0.2.9.new/mujoco_py/utils.py 2020-04-06 22:17:43.277818305 -0400
+@@ -72,7 +72,6 @@
+ def discover_mujoco():
+ """
+ Discovers where MuJoCo is located in the file system.
+- Currently assumes path is in ~/.mujoco
+
+ Returns:
+ - mujoco_path (str): Path to MuJoCo 2.0 directory.
+@@ -81,9 +80,13 @@
+ key_path = os.getenv('MUJOCO_PY_MJKEY_PATH')
+ if not key_path:
+ key_path = join(expanduser('~'), '.mujoco', 'mjkey.txt')
++ if not exists(key_path):
++ key_path = "/usr/share/licenses/mujoco/mjkey.txt"
+ mujoco_path = os.getenv('MUJOCO_PY_MUJOCO_PATH')
+ if not mujoco_path:
+ mujoco_path = join(expanduser('~'), '.mujoco', 'mujoco200')
++ if not exists(mujoco_path):
++ mujoco_path = "/opt/mujoco/mujoco200"
+
+ # We get lots of github issues that seem to be missing these
+ # so check that mujoco is really there and raise errors if not.