Skip to content

Commit 0c9dac6

Browse files
committed
[WORKSPACE, docs] Add hermetic dependency on Lua 5.1.
With this change, Lua is no longer a system prerequisite, but instead it will be downloaded and built from source.
1 parent 6e1c055 commit 0c9dac6

File tree

7 files changed

+47
-47
lines changed

7 files changed

+47
-47
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ language: c++
1010
addons:
1111
apt:
1212
packages:
13-
- lua5.1
14-
- liblua5.1-0-dev
1513
- libffi-dev
1614
- gettext
1715
- freeglut3-dev

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ software libraries, which we ship in several different ways:
148148
* Several additional libraries are required but are not shipped in any form;
149149
they must be present on your system:
150150
* SDL 2
151-
* Lua 5.1 (later versions might work, too)
152151
* gettext (required by `glib`)
153152
* OpenGL: A hardware driver and library are needed for hardware-accelerated
154153
human play. The headless library that machine learning agents will want to

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
log messages are emitted via the setting 'logLevel'.
1313
4. Update the ioq3 upstream code to the [latest
1414
state](https://github.com/ioquake/ioq3/tree/29db64070aa0bae49953bddbedbed5e317af48ba).
15+
5. Lua 5.1 is now downloaded and built from source, and is thus no longer a
16+
required local dependency.
1517

1618
### Bug Fixes:
1719

WORKSPACE

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,18 @@ new_http_archive(
8686
],
8787
)
8888

89-
# TODO: Replace with hermetic build
90-
new_local_repository(
91-
name = "lua_system",
89+
new_http_archive(
90+
name = "lua_archive",
9291
build_file = "lua.BUILD",
93-
path = "/usr",
92+
sha256 = "2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333",
93+
strip_prefix = "lua-5.1.5/src",
94+
urls = [
95+
"https://mirror.bazel.build/www.lua.org/ftp/lua-5.1.5.tar.gz",
96+
"https://www.lua.org/ftp/lua-5.1.5.tar.gz",
97+
],
9498
)
9599

100+
# TODO: Replace with hermetic build
96101
new_local_repository(
97102
name = "sdl_system",
98103
build_file = "sdl.BUILD",

deepmind/lua/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ licenses(["restricted"]) # GPLv2
55

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

8-
LUA_VERSION = "@lua_system//:lua"
8+
LUA_VERSION = "@lua_archive//:lua"
99

1010
cc_library(
1111
name = "lua",

docs/users/build.md

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ modern compiler. GCC 4.8 should suffice.
1616
Instructions for installing Bazel can be found in the [Bazel install
1717
guide](https://docs.bazel.build/versions/master/install.html).
1818

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

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

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

3332
```shell
34-
$ sudo apt-get install lua5.1 liblua5.1-0-dev libffi-dev gettext \
35-
freeglut3-dev libsdl2-dev libosmesa6-dev python-dev python-numpy \
36-
python-pil realpath
33+
$ sudo apt-get install libffi-dev gettext freeglut3-dev libsdl2-dev \
34+
libosmesa6-dev python-dev python-numpy python-pil realpath
3735
```
3836

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

4442
```shell
45-
sudo yum -y install unzip java-1.8.0-openjdk lua lua-devel libffi-devel \
46-
java-1.8.0-openjdk-devel gcc gcc-c++ freeglut-devel SDL2 SDL2-devel \
47-
mesa-libOSMesa-devel python-devel python-imaging zip numpy
43+
sudo yum -y install unzip java-1.8.0-openjdk libffi-devel gcc gcc-c++ \
44+
java-1.8.0-openjdk-devel freeglut-devel python-devel python-imaging \
45+
SDL2 SDL2-devel mesa-libOSMesa-devel zip numpy
4846
```
4947

5048
* On SUSE Linux:
5149

5250
Tested on SUSE Linux Enterprise Server 12.
5351

5452
```shell
55-
sudo zypper --non-interactive install gcc gcc-c++ lua java-1_8_0-openjdk \
56-
java-1_8_0-openjdk-devel lua-devel python-devel python-numpy-devel \
57-
python-imaging libSDL-devel libOSMesa-devel freeglut-devel
53+
sudo zypper --non-interactive install gcc gcc-c++ java-1_8_0-openjdk \
54+
java-1_8_0-openjdk-devel libOSMesa-devel freeglut-devel libSDL-devel \
55+
python-devel python-numpy-devel python-imaging
5856
```
5957

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

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

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

87-
## Lua and Python dependencies
85+
## Python dependencies
8886

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

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

100-
Lua, for example, is installed directly in `/usr/include` on some systems like
101-
Red Hat and SUSE Linux. Therefore you need to edit `lua.BUILD` to reflect that
102-
location (or rather, the absence of a special location):
103-
104-
```python
105-
cc_library(
106-
name = "lua",
107-
linkopts = ["-llua"],
108-
visibility = ["//visibility:public"],
109-
)
110-
```
111-
The output of `pkg-config lua --libs --cflags` might be helpful to find the
112-
right include directories and linker options.
113-
11497
Python requires two separate dependencies: The CPython extension API, and NumPy.
11598
If, say, NumPy is installed in a custom location, like it is on SUSE Linux, you
11699
need to add the files from that location and set an include search path

lua.BUILD

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
# Description:
22
# Build rule for Lua 5.1.
3-
# Compiler and linker flags found with `pkg-config --cflags --libs lua5.1`.
4-
# The package name and the resulting flags may vary from platform to platform,
5-
# cf. 'How to build DeepMind Lab' in build.md.
63

74
cc_library(
85
name = "lua",
9-
hdrs = glob(["include/lua5.1/*.h"]),
10-
includes = ["include/lua5.1"],
11-
linkopts = ["-llua5.1"],
6+
srcs = glob(
7+
include = [
8+
"*.c",
9+
"*.h",
10+
],
11+
exclude = [
12+
"lauxlib.h",
13+
"lua.c",
14+
"lua.h",
15+
"luac.c",
16+
"lualib.h",
17+
"print.c",
18+
],
19+
),
20+
hdrs = [
21+
"lauxlib.h",
22+
"lua.h",
23+
"lualib.h",
24+
],
1225
visibility = ["//visibility:public"],
1326
)

0 commit comments

Comments
 (0)