Skip to content

Commit

Permalink
Remove ./configure script.
Browse files Browse the repository at this point in the history
This patch finally fixes a long-standing gripe that I have had with my
build toolchain with the requirement to run a ./configure script. By
removing the conditional TensorFlow GPU package, I finally feel ready
to let go of this configuration script and the generated
config.pbtxt. The last remaining piece of functionality ported over
from ./configure is the recording of the workspace source path, which
has been assimilated into build_info.pbtxt.

github.com/ChrisCummins/phd/issues/73

Signed-off-by: format 2020.01.16 <github.com/ChrisCummins/format>
  • Loading branch information
ChrisCummins committed Jan 24, 2020
1 parent 9a6084c commit 4ab9641
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 80 deletions.
24 changes: 24 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
#
# This script sets up the shell environment for this project.
#
# Usage:
# $ source .env

export PHD="$(realpath $(dirname "$0"))"

if [[ -f "$HOME/.cache/phd/tools/py/venv/phd/bin/activate" ]]; then
# If there is a virtualenv, use it. Note that even if it does exist, bazel
# will go ahead and ignore it, so we still need to rely on the system python
# being the required version.
. "$HOME/.cache/phd/tools/py/venv/phd/bin/activate"
fi

# Note(github.com/ChrisCummins/phd/issues/55): On macOS, custom LDFLAGS and
# CPPFLAGS are required to pip build MySQLdb:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"

# Increase the timeout on docker image pulls from the default 600s.
# See: https://github.com/bazelbuild/rules_docker
export PULLER_TIMEOUT=3600
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
/node_modules

# In-tree generated files.
/.env
/bootstrap.sh
/config.pbtxt
/learn/docker/clgen/*.tar.bz2
/experimental/deeplearning/clgen/docker_worker/*.tar.bz2
/experimental/deeplearning/clgen/docker_worker/cache
Expand Down
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ language:

env:
global:
# ./configure script symlinks python3 to ~/.local/bin/python, and macos
# image needs GNU tools in PATH, rather than BSD versions.
# MacOS needs GNU tools in PATH, rather than BSD versions.
- PATH="$HOME/.local/bin:/usr/local/opt/coreutils/libexec/gnubin/stat:/usr/local/opt/findutils/libexec/gnubin:/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
# Environment variables needed for zlib.
# See: https://github.com/pyenv/pyenv/issues/530
Expand Down Expand Up @@ -50,7 +49,6 @@ install:
# Swap out GCC for GCC-5 on linux to enable support for --std=c++14.
# See: https://gist.github.com/cotsog/3ce84675af0d74438d91
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then sudo unlink /usr/bin/gcc && sudo ln -s /usr/bin/gcc-5 /usr/bin/gcc; fi
- ./configure --noninteractive
# Symlink the system python2 in place so that we bypass the pyenv shim.
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then ln -s /usr/bin/python2 $HOME/.local/bin; fi

Expand Down
38 changes: 0 additions & 38 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ sh_binary(
srcs = ["make_build_info_pbtxt.sh"],
)

filegroup(
name = "config",
srcs = ["config.pbtxt"],
visibility = ["//visibility:public"],
)

proto_library(
name = "config_pb",
srcs = ["config.proto"],
Expand Down Expand Up @@ -103,38 +97,6 @@ py_library(
],
)

py_test(
name = "configure_test",
srcs = ["configure_test.py"],
data = [":configure_py"],
deps = [
"//labm8/py:app",
"//labm8/py:bazelutil",
"//labm8/py:test",
],
)

py_library(
name = "getconfig",
srcs = ["getconfig.py"],
visibility = ["//visibility:public"],
deps = [
"//:config_pb_py",
"//:config_pbtxt_py",
"//labm8/py:pbutil",
],
)

py_test(
name = "getconfig_test",
srcs = ["getconfig_test.py"],
deps = [
":getconfig",
"//labm8/py:app",
"//labm8/py:test",
],
)

# Golang.
# Gazelle directive:
# gazelle:prefix github.com/ChrisCummins/phd
Expand Down
33 changes: 3 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,43 +28,16 @@ programs it learns from.

## Getting Started

Configure the build and answer the yes/no questions. The default answers should
be fine:
Build CLgen using:

```sh
$ ./configure
```

Note that CUDA support requires CUDA to have been installed separately,
see the [TensorFlow build docs](https://www.tensorflow.org/install/) for
instructions. CUDA support has only been tested for Linux builds, not macOS or
Docker containers.

```sh
$ bazel build //deeplearning/clgen
```

The configure process generates a `bootstrap.sh` script which will install the
required dependent packages. Since installing these packages will affect the
global state of your system, and may requires root access, inspect this script
carefully. Once you're happy to proceed, run it using:

```sh
$ bash ./bootstrap.sh
```

Finally, we must set up the shell environment for running bazel. The file `.env`
is created by the configure process and must be sourced for every shell we want
to use bazel with:

```sh
$ source $PWD/.env
$ bazel build -c opt //deeplearning/clgen
```

Use our tiny example dataset to train and sample your first CLgen model:

```sh
$ bazel run //deeplearning/clgen -- \
$ bazel-bin/deeplearning/clgen -- \
--config $PWD/deeplearning/clgen/tests/data/tiny/config.pbtxt
```

Expand Down
9 changes: 6 additions & 3 deletions third_party/py/tensorflow/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ py_library(
name = "tensorflow",
srcs = [":tf.py"],
deps = [
requirement("tensorflow"),
# rules_pip fails for TensorFlow, causing an empty package to be
# downloaded. Because of this, we require the user to manually install
# the version of TensorFlow specified in requirements.txt:
# requirement("tensorflow"),
"//third_party/py/numpy",
"//third_party/py/protobuf",
],
Expand All @@ -37,10 +40,10 @@ py_test(
deps = [
":tensorflow",
"//labm8/py:app",
"//:getconfig",
"//labm8/py:test",
"//third_party/py/gputil",
"//third_party/py/numpy",
"//third_party/py/pytest",
"//labm8/py:test",
],
)

Expand Down
1 change: 0 additions & 1 deletion tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ sh_binary(
srcs = ["whoami.sh"],
data = [
"//:build_info_pbtxt",
"//:config",
],
)

Expand Down
1 change: 0 additions & 1 deletion tools/whoami.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env bash

cat config.pbtxt | grep -v '^#'
cat build_info.pbtxt | grep -v '^#'
5 changes: 3 additions & 2 deletions tools/workspace_status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ set -eu
echo "SECONDS_SINCE_EPOCH $(date +%s)"
echo "RANDOM_HASH $(cat /dev/urandom | head -c16 | md5sum 2>/dev/null | cut -f1 -d' ')"

# Stable keys.
# Stable keys. See the BuildInfo message schema in //:config.proto for a
# description of each fields.
echo "STABLE_UNSAFE_WORKSPACE" $(pwd)
echo "STABLE_HOST $(hostname)"
echo "STABLE_USER $(id -un)"
echo "STABLE_REPO_ROOT" $(pwd)
echo "STABLE_VERSION" $(cat version.txt)

echo "STABLE_GIT_COMMIT_HASH $(git rev-parse HEAD)"
Expand Down

0 comments on commit 4ab9641

Please sign in to comment.