Skip to content

Commit

Permalink
Merge pull request #1525 from finos/pym1
Browse files Browse the repository at this point in the history
Fix M1 (Apple Silicon) build for `perspective-python` and improve developer docs
  • Loading branch information
texodus authored Aug 31, 2021
2 parents 7cddd9e + ab7601b commit a36c702
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 38 deletions.
4 changes: 2 additions & 2 deletions cmake/modules/FindFlatbuffers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ if (WIN32)
else()
find_path(FLATBUFFERS_INCLUDE_DIR flatbuffers/flatbuffers.h
PATHS ${FLATBUFFERS_ROOT}/include
HINTS /usr/local /usr/local/flatbuffers /usr/local/Homebrew /usr ~/homebrew/ /usr/local/include /usr/local/flatbuffers/include /usr/include ~/homebrew/include
HINTS /usr/local /usr/local/flatbuffers /usr/local/Homebrew /usr ~/homebrew/ /usr/local/include /usr/local/flatbuffers/include /usr/include ~/homebrew/include /opt/homebrew/include
NO_CMAKE_SYSTEM_PATH
NO_SYSTEM_ENVIRONMENT_PATH)

find_program(FLATBUFFERS_COMPILER flatc
PATHS ${FLATBUFFERS_ROOT}/bin
HINTS /usr/local/bin /usr/bin /usr/local/Homebrew/bin ~/homebrew/bin
HINTS /usr/local/bin /usr/bin /usr/local/Homebrew/bin ~/homebrew/bin /opt/homebrew/bin
NO_CMAKE_SYSTEM_PATH
NO_SYSTEM_ENVIRONMENT_PATH)

Expand Down
66 changes: 32 additions & 34 deletions docs/md/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ To switch your development toolchain between the two, use `yarn setup`. Once the
setup script has been run, common commands like `yarn build` and `yarn test`
automatically call the correct build and test tools.

## Building
### System Dependencies

`Perspective.js` and `perspective-python` **require** the following system dependencies to be installed:

- [CMake](https://cmake.org/) (version 3.15.4 or higher)
- [Boost](https://www.boost.org/) (version 1.67 or higher, must be built - not header-only)
- [Flatbuffers](https://google.github.io/flatbuffers/flatbuffers_guide_building.html)
## Build

Make sure you have the system dependencies installed. For specifics depending on your OS, check the [system-specific instructions](#system-specific-instructions) below.

To run a build, use

Expand All @@ -44,21 +53,6 @@ packages, e.g. `examples/simple` like so:
yarn start simple
```

#### Docker

[Docker](https://docs.docker.com/install/) images with pre-built development
environments are provided for the Python libraries.

To build Perspective using Docker, select the option in `yarn setup`.

### System Dependencies

`Perspective.js` and `perspective-python` **require** the following system dependencies to be installed:

- [CMake](https://cmake.org/) (version 3.15.4 or higher)
- [Boost](https://www.boost.org/) (version 1.67 or higher, must be built - not header-only)
- [Flatbuffers](https://google.github.io/flatbuffers/flatbuffers_guide_building.html)

## `Perspective.js`

To build the JavaScript library, which includes WebAssembly compilation,
Expand Down Expand Up @@ -91,6 +85,8 @@ To install this specific version of Emscripten:
./emsdk install 2.0.6
```

---

### `perspective-jupyterlab`

To install the Jupyterlab plugin from your local working directory, give
Expand Down Expand Up @@ -119,22 +115,27 @@ when it looks for Perspective packages, instead of fetching them from NPM.
5. Whenever you run `jupyter lab clean`, you will need to run `yarn jlab_link`
again to re-register the symlinks.

---

## `perspective-python`

To build the Python library, first configure your project to Python via
To build the Python library, first configure your project to build Python via
`yarn setup`, then run:

```bash
yarn build
```

`perspective-python` supports Python 3.7 and upwards, as well as Python 2.7.17.
To build the Python 2 version of the library, use the `--python2` flag:
`perspective-python` supports Python 3.7 and upwards.

```bash
yarn build --python2
```
### Docker

[Docker](https://docs.docker.com/install/) images with pre-built development
environments are provided for the Python libraries.

To build Perspective using Docker, select the option in `yarn setup`.

---
## System-Specific Instructions

### MacOS/OSX
Expand All @@ -143,19 +144,12 @@ Install system dependencies through Homebrew:

```bash
brew install cmake
brew install boost@1.67
brew install boost
brew install flatbuffers
```

#### `perspective-python`

If you're building the Python 2 version of the library, make sure your version
of Python 2 is the latest version (`2.7.17`) supplied by Homebrew, and not the
earlier version that ships with MacOS. To install Python 2 using Homebrew:

```bash
brew install python2
```
On M1 (Apple Silicon) systems, make sure your brew-installed dependencies are in
`/opt/homebrew` (the default location), and that `/opt/homebrew/bin` is on the `PATH`.

### Windows 10

Expand Down Expand Up @@ -192,7 +186,9 @@ ln -s /usr/local/flatbuffers/flatc /usr/local/bin/flatc
chmod +x /usr/local/flatbuffers/flatc
```

## Testing
---

## Test

You can run the test suite simply with the standard NPM command, which will both
build the test suite for every package and run them.
Expand Down Expand Up @@ -289,7 +285,9 @@ correct this, run tests with the `TZ=UTC`, i.e.
TZ=UTC yarn test --verbose
```

## Benchmarking
---

## Benchmark

You can generate benchmarks specific to your machine's OS and CPU architecture
with Perspective's benchmark suite, which will generate a `report.html` file in
Expand Down
11 changes: 9 additions & 2 deletions scripts/lint_python.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ const {execute, docker, resolve, getarg, python_image} = require("./script_utils

const IS_DOCKER = process.env.PSP_DOCKER;
const IS_PY2 = getarg("--python2");
const PYTHON = IS_PY2 ? "python2" : getarg("--python38") ? "python3.8" : getarg("--python36") ? "python3.6" : "python3.7";

let PYTHON = IS_PY2 ? "python2" : getarg("--python38") ? "python3.8" : getarg("--python36") ? "python3.6" : "python3.7";
let IMAGE = "manylinux2014";

if (IS_DOCKER) {
Expand All @@ -26,6 +25,14 @@ if (IS_DOCKER) {

const IS_FIX = getarg("--fix");

// Check that the `PYTHON` command is valid, else default to `python`.
try {
execute_throw`${PYTHON} --version`;
} catch (e) {
console.warn(`\`${PYTHON}\` not found - using \`python\` instead.`);
PYTHON = "python";
}

try {
let cmd;
let lint_cmd = `${PYTHON} -m flake8 perspective bench setup.py`;
Expand Down
8 changes: 8 additions & 0 deletions scripts/test_python.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ try {
PYTHON = "python";
}

// Check that the `PYTHON` command is valid, else default to `python`.
try {
execute_throw`${PYTHON} --version`;
} catch (e) {
console.warn(`\`${PYTHON}\` not found - using \`python\` instead.`);
PYTHON = "python";
}

try {
execute(pytest_client_mode(IS_DOCKER));
execute(pytest(IS_DOCKER));
Expand Down

0 comments on commit a36c702

Please sign in to comment.