Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

free-mujoco-py on PyPi with included binaries #1

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 24 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build

on: [push, pull_request]

jobs:
ci:
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9]
poetry-version: [1.1.11]
os: [ubuntu-18.04]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Run image
uses: abatilo/[email protected]
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Download mujoco
run: bash download_mujoco.sh
- name: Install ubuntu dependencies
run: |
sudo apt-get update -q \
&& DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \
curl \
git \
libgl1-mesa-dev \
libgl1-mesa-glx \
libglew-dev \
libosmesa6-dev \
software-properties-common \
net-tools \
vim \
virtualenv \
wget \
xpra \
xserver-xorg-dev
- name: Install poetry dependencies
run: poetry install
- name: Build wheels
run: poetry build
- uses: actions/upload-artifact@v2
with:
name: wheels
path: dist
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mujoco_py/binaries
mujoco-py-**
mjkey.txt
mujoco_py/generated/cymj*
Expand Down
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ RUN curl -o /usr/local/bin/patchelf https://s3-us-west-2.amazonaws.com/openai-sc

ENV LANG C.UTF-8

RUN mkdir -p /root/.mujoco \
&& wget https://mujoco.org/download/mujoco210-linux-x86_64.tar.gz -O mujoco.tar.gz \
&& tar -xf mujoco.tar.gz -C /root/.mujoco \
&& rm mujoco.tar.gz
# RUN mkdir -p /root/.mujoco \
# && wget https://mujoco.org/download/mujoco210-linux-x86_64.tar.gz -O mujoco.tar.gz \
# && tar -xf mujoco.tar.gz -C /root/.mujoco \
# && rm mujoco.tar.gz

ENV LD_LIBRARY_PATH /root/.mujoco/mujoco210/bin:${LD_LIBRARY_PATH}
# ENV LD_LIBRARY_PATH /root/.mujoco/mujoco210/bin:${LD_LIBRARY_PATH}
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib64:${LD_LIBRARY_PATH}

COPY vendor/Xdummy /usr/local/bin/Xdummy
Expand All @@ -51,6 +51,8 @@ RUN chmod +x /usr/local/bin/Xdummy
COPY ./vendor/10_nvidia.json /usr/share/glvnd/egl_vendor.d/10_nvidia.json

WORKDIR /mujoco_py
COPY download_mujoco.sh download_mujoco.sh
RUN bash download_mujoco.sh
# Copy over just requirements.txt at first. That way, the Docker cache doesn't
# expire until we actually change the requirements.
COPY ./requirements.txt /mujoco_py/
Expand Down
7 changes: 7 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os


def build(setup_kwargs):
os.environ['MUJOCO_PY_FORCE_REBUILD'] = 'True'
os.environ['MUJOCO_PY_SKIP_ACTIVATE'] = 'True'
import mujoco_py # noqa: force build
14 changes: 14 additions & 0 deletions download_mujoco.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
mkdir -p mujoco_py/binaries/linux \
&& wget https://mujoco.org/download/mujoco210-linux-x86_64.tar.gz -O mujoco.tar.gz \
&& tar -xf mujoco.tar.gz -C mujoco_py/binaries/linux \
&& rm mujoco.tar.gz

mkdir -p mujoco_py/binaries/windows \
&& wget https://mujoco.org/download/mujoco210-windows-x86_64.zip -O mujoco.zip \
&& unzip mujoco.zip -d mujoco_py/binaries/windows \
&& rm mujoco.zip

mkdir -p mujoco_py/binaries/macos \
&& wget https://mujoco.org/download/mujoco210-macos-x86_64.tar.gz -O mujoco.tar.gz \
&& tar -xf mujoco.tar.gz -C mujoco_py/binaries/macos \
&& rm mujoco.tar.gz
13 changes: 13 additions & 0 deletions mujoco_py/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
import os
from sys import platform
import mujoco_py
if platform == "linux" or platform == "linux2":
os.environ["MUJOCO_PY_MUJOCO_PATH"] = os.path.join(mujoco_py.__path__[0], "binaries", "linux", "mujoco210")
os.environ["LD_LIBRARY_PATH"] = os.path.join(mujoco_py.__path__[0], "binaries", "linux", "mujoco210", "bin")
elif platform == "darwin":
os.environ["MUJOCO_PY_MUJOCO_PATH"] = os.path.join(mujoco_py.__path__[0], "binaries", "macos", "mujoco210")
os.environ["LD_LIBRARY_PATH"] = os.path.join(mujoco_py.__path__[0], "binaries", "macos", "mujoco210", "bin")
elif platform == "win32":
os.environ["MUJOCO_PY_MUJOCO_PATH"] = os.path.join(mujoco_py.__path__[0], "binaries", "windows", "mujoco210")
os.environ["LD_LIBRARY_PATH"] = os.path.join(mujoco_py.__path__[0], "binaries", "windows", "mujoco210", "bin")

#!/usr/bin/env python
from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
from mujoco_py.generated import const
Expand Down
12 changes: 6 additions & 6 deletions mujoco_py/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ def __init__(self, mujoco_path):
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, 'libmujoco210.so', 'libmujoco210.so')
fix_shared_library(so_file_path, 'libglewosmesa.so', 'libglewosmesa.so')
fix_shared_library(so_file_path, 'libmujoco210.so', f'{os.environ["LD_LIBRARY_PATH"]}/libmujoco210.so')
fix_shared_library(so_file_path, 'libglewosmesa.so', f'{os.environ["LD_LIBRARY_PATH"]}/libglewosmesa.so')
return so_file_path


Expand All @@ -289,10 +289,10 @@ def __init__(self, mujoco_path):

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, 'libmujoco210.so', 'libmujoco210.so')
fix_shared_library(so_file_path, 'libglewegl.so', 'libglewegl.so')
fix_shared_library(so_file_path, 'libOpenGL.so', f'{os.environ["LD_LIBRARY_PATH"]}/libOpenGL.so.0')
fix_shared_library(so_file_path, 'libEGL.so', f'{os.environ["LD_LIBRARY_PATH"]}/libEGL.so.1')
fix_shared_library(so_file_path, 'libmujoco210.so', f'{os.environ["LD_LIBRARY_PATH"]}/libmujoco210.so')
fix_shared_library(so_file_path, 'libglewegl.so', f'{os.environ["LD_LIBRARY_PATH"]}/libglewegl.so')
return so_file_path


Expand Down
Loading