Skip to content

Commit

Permalink
[WORKSPACE, docs] Add hermetic dependency on Lua 5.1.
Browse files Browse the repository at this point in the history
With this change, Lua is no longer a system prerequisite, but instead
it will be downloaded and built from source.
  • Loading branch information
tkoeppe committed Oct 16, 2018
1 parent 6e1c055 commit 0c9dac6
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 47 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ language: c++
addons:
apt:
packages:
- lua5.1
- liblua5.1-0-dev
- libffi-dev
- gettext
- freeglut3-dev
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ software libraries, which we ship in several different ways:
* Several additional libraries are required but are not shipped in any form;
they must be present on your system:
* SDL 2
* Lua 5.1 (later versions might work, too)
* gettext (required by `glib`)
* OpenGL: A hardware driver and library are needed for hardware-accelerated
human play. The headless library that machine learning agents will want to
Expand Down
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
log messages are emitted via the setting 'logLevel'.
4. Update the ioq3 upstream code to the [latest
state](https://github.com/ioquake/ioq3/tree/29db64070aa0bae49953bddbedbed5e317af48ba).
5. Lua 5.1 is now downloaded and built from source, and is thus no longer a
required local dependency.

### Bug Fixes:

Expand Down
13 changes: 9 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,18 @@ new_http_archive(
],
)

# TODO: Replace with hermetic build
new_local_repository(
name = "lua_system",
new_http_archive(
name = "lua_archive",
build_file = "lua.BUILD",
path = "/usr",
sha256 = "2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333",
strip_prefix = "lua-5.1.5/src",
urls = [
"https://mirror.bazel.build/www.lua.org/ftp/lua-5.1.5.tar.gz",
"https://www.lua.org/ftp/lua-5.1.5.tar.gz",
],
)

# TODO: Replace with hermetic build
new_local_repository(
name = "sdl_system",
build_file = "sdl.BUILD",
Expand Down
2 changes: 1 addition & 1 deletion deepmind/lua/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ licenses(["restricted"]) # GPLv2

package(default_visibility = ["//visibility:public"])

LUA_VERSION = "@lua_system//:lua"
LUA_VERSION = "@lua_archive//:lua"

cc_library(
name = "lua",
Expand Down
49 changes: 16 additions & 33 deletions docs/users/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ modern compiler. GCC 4.8 should suffice.
Instructions for installing Bazel can be found in the [Bazel install
guide](https://docs.bazel.build/versions/master/install.html).

You may need to deal with some details concerning Lua and Python dependencies.
Those are documented in a [separate section](#lua-and-python-dependencies)
below.
You may need to deal with some details concerning Python dependencies. Those
are documented in a [separate section](#python-dependencies) below.

## Step-by-step instructions for building and running

Expand All @@ -31,9 +30,8 @@ below.
Tested on Debian 8.6 (Jessie) and Ubuntu 14.04 (Trusty) and newer.

```shell
$ sudo apt-get install lua5.1 liblua5.1-0-dev libffi-dev gettext \
freeglut3-dev libsdl2-dev libosmesa6-dev python-dev python-numpy \
python-pil realpath
$ sudo apt-get install libffi-dev gettext freeglut3-dev libsdl2-dev \
libosmesa6-dev python-dev python-numpy python-pil realpath
```

* On Red Hat Enterprise Linux Server:
Expand All @@ -42,25 +40,25 @@ below.
some modifications of the package installation commands on Centos 6.

```shell
sudo yum -y install unzip java-1.8.0-openjdk lua lua-devel libffi-devel \
java-1.8.0-openjdk-devel gcc gcc-c++ freeglut-devel SDL2 SDL2-devel \
mesa-libOSMesa-devel python-devel python-imaging zip numpy
sudo yum -y install unzip java-1.8.0-openjdk libffi-devel gcc gcc-c++ \
java-1.8.0-openjdk-devel freeglut-devel python-devel python-imaging \
SDL2 SDL2-devel mesa-libOSMesa-devel zip numpy
```

* On SUSE Linux:

Tested on SUSE Linux Enterprise Server 12.

```shell
sudo zypper --non-interactive install gcc gcc-c++ lua java-1_8_0-openjdk \
java-1_8_0-openjdk-devel lua-devel python-devel python-numpy-devel \
python-imaging libSDL-devel libOSMesa-devel freeglut-devel
sudo zypper --non-interactive install gcc gcc-c++ java-1_8_0-openjdk \
java-1_8_0-openjdk-devel libOSMesa-devel freeglut-devel libSDL-devel \
python-devel python-numpy-devel python-imaging
```

3. [Clone or download *DeepMind Lab*](https://github.com/deepmind/lab).

4. If necessary, edit `lua.BUILD` and `python.BUILD` according to the [Lua and
Python instructions](#lua-and-python-dependencies) below.
4. If necessary, edit `python.BUILD` according to the [Python
instructions](#python-dependencies) below.

5. Build *DeepMind Lab* and run a random agent. (Use the `-c opt` flag to enable
optimizations.)
Expand All @@ -84,33 +82,18 @@ with *DeepMind Lab*.
The random agent target `:python_random_agent` has a number of optional command line
arguments. Run `bazel run :random_agent -- --help` to see those.

## Lua and Python dependencies
## Python dependencies

*DeepMind Lab* does not include every dependency hermetically. In particular,
Lua and Python are not included, but instead must already be installed on your
system. This means that depending on the details of where those libraries are
Python is not included, but instead must already be installed on your
system. This means that depending on the details of where that library is
installed, you may need to adjust the Bazel build rules in
[`lua.BUILD`](../../lua.BUILD) and [`python.BUILD`](../../python.BUILD) to
locate them correctly.
[`python.BUILD`](../../python.BUILD) to locate it correctly.

The default build rules should work for Debian and Ubuntu. Note that paths in
the build rules are relative to the root path specified in the
[`WORKSPACE`](../../WORKSPACE) file (which is `"/usr"` by default).

Lua, for example, is installed directly in `/usr/include` on some systems like
Red Hat and SUSE Linux. Therefore you need to edit `lua.BUILD` to reflect that
location (or rather, the absence of a special location):

```python
cc_library(
name = "lua",
linkopts = ["-llua"],
visibility = ["//visibility:public"],
)
```
The output of `pkg-config lua --libs --cflags` might be helpful to find the
right include directories and linker options.

Python requires two separate dependencies: The CPython extension API, and NumPy.
If, say, NumPy is installed in a custom location, like it is on SUSE Linux, you
need to add the files from that location and set an include search path
Expand Down
25 changes: 19 additions & 6 deletions lua.BUILD
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
# Description:
# Build rule for Lua 5.1.
# Compiler and linker flags found with `pkg-config --cflags --libs lua5.1`.
# The package name and the resulting flags may vary from platform to platform,
# cf. 'How to build DeepMind Lab' in build.md.

cc_library(
name = "lua",
hdrs = glob(["include/lua5.1/*.h"]),
includes = ["include/lua5.1"],
linkopts = ["-llua5.1"],
srcs = glob(
include = [
"*.c",
"*.h",
],
exclude = [
"lauxlib.h",
"lua.c",
"lua.h",
"luac.c",
"lualib.h",
"print.c",
],
),
hdrs = [
"lauxlib.h",
"lua.h",
"lualib.h",
],
visibility = ["//visibility:public"],
)

0 comments on commit 0c9dac6

Please sign in to comment.