Skip to content

Conda package #113

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

Merged
merged 25 commits into from
Aug 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f450564
Add conda recipe and initial updates to travis (OS X) build
jonmmease Aug 2, 2018
f0f735e
Initial AppVeyor build
jonmmease Aug 2, 2018
1a0dfcd
Initial attempt at CircleCI build
jonmmease Aug 2, 2018
cec5e63
Fixed OS X miniconda URL for travis
jonmmease Aug 2, 2018
27a5a21
Fixed OS X miniconda URL for circle and added extra logging
jonmmease Aug 2, 2018
24f3a64
Use full path to conda executable on Travis and Circle
jonmmease Aug 2, 2018
d9f13dc
Bump version to 1.0.1-alpha.1
jonmmease Aug 2, 2018
f728d18
Bump version to 1.0.1-rc.1
jonmmease Aug 2, 2018
5e5da81
Change cersion back to 1.0.0
jonmmease Aug 2, 2018
d9513d5
Add conda build README
jonmmease Aug 2, 2018
a1a7ca3
First attempt to add conda packages as build artifacts
jonmmease Aug 2, 2018
a0338b1
Take 2 on conda build artifact paths.
jonmmease Aug 2, 2018
ab82b98
Take 2 on conda build artifact paths.
jonmmease Aug 2, 2018
c5c1160
Take 4 on conda build artifact paths.
jonmmease Aug 2, 2018
b978394
Added conda package publication instructions to CONTRIBUTING.md
jonmmease Aug 2, 2018
4cf83b2
globs not allowed in artifact paths: Try parent directory
jonmmease Aug 2, 2018
b3f3234
zip win64 directory directly from conda-bld location.
jonmmease Aug 2, 2018
5db9330
zip win64 directory itself, not contents
jonmmease Aug 2, 2018
586af58
zip Linux/OS X build directories as artifacts too.
jonmmease Aug 2, 2018
5cd5be6
Guess I need to make the artifacts directory
jonmmease Aug 2, 2018
d03da3e
Get consistent directory structure in zipped package artifacts
jonmmease Aug 2, 2018
474d02f
Update CONTRIBUTING conda instruction with consistent zip file structure
jonmmease Aug 2, 2018
62f706f
Added conda installation instructions to README
jonmmease Aug 2, 2018
d6f9c1e
Launch orca process with `exec` from wrapper bash scripts
jonmmease Aug 8, 2018
a5ea04c
Revert the new installation updates in the README
jonmmease Aug 9, 2018
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
35 changes: 35 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ workflows:
requires:
- test-node-v6
- test-node-v8
- conda-build-package:
requires:
- test-node-v6
- test-node-v8

version: 2
jobs:
Expand Down Expand Up @@ -156,3 +160,34 @@ jobs:
- run: mv release/orca* artifacts
- store_artifacts:
path: artifacts

conda-build-package:
docker:
- image: circleci/node:8.11.1-browsers
steps:
- restore_cache:
key: v1-source-{{ .Branch }}-{{ .Revision }}
keys:
- v1-source-{{ .Branch }}-
- v1-source-
- checkout
- save_cache:
key: v1-source-{{ .Branch }}-{{ .Revision }}
paths:
- ".git"
- restore_cache:
key: v3-npm-{{ checksum "package-lock.json" }}
keys:
- v3-npm-

- run: wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- run: chmod +x miniconda.sh
- run: ./miniconda.sh -b -p $HOME/miniconda
- run: $HOME/miniconda/bin/conda install --yes conda-build
- run: $HOME/miniconda/bin/conda build recipe/
- run: ls $HOME/miniconda/conda-bld/linux-64
- run: mkdir artifacts
- run: cp -r $HOME/miniconda/conda-bld/linux-64 ./linux-64
- run: zip -r artifacts/conda-linux-64.zip ./linux-64
- store_artifacts:
path: artifacts
19 changes: 18 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,36 @@ cache:
- $HOME/.cache/electron
- $HOME/.cache/electron-builder

before_install:
# Conda config based on
# https://github.com/astrofrog/example-travis-conda/blob/master/.travis.yml
#
# Here we just install Miniconda, which you shouldn't have to change.
- wget http://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh
- chmod +x miniconda.sh
- ./miniconda.sh -b -p $HOME/miniconda
- $HOME/miniconda/bin/conda install --yes conda-build

install:
- npm install

script:
- npm run pack
- ls release/
- zip mac-release.zip release/orca* --junk-paths
- $HOME/miniconda/bin/conda build recipe/
- ls $HOME/miniconda/conda-bld/osx-64
- cp -r $HOME/miniconda/conda-bld/osx-64 ./osx-64
- zip -r conda-osx-64.zip ./osx-64

before_cache:
- rm -rf $HOME/.cache/electron-builder/wine

addons:
artifacts:
s3_region: us-east-1
paths: mac-release.zip
paths:
- mac-release.zip
- conda-osx-64.zip

debug: true
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,19 @@ automate this process somehow.
+ Grab the Mac build automatically pushed to [Amazon S3](https://s3.console.aws.amazon.com/s3/buckets/image-exporter-travis-artifacts/plotly/orca/?region=us-east-1&tab=overview) from Travis.
**N.B.** Select the latest build (largest number *note:* the folders are not necessarily sequential) -> release.zip
- Run `npm publish`
- Publish conda packages:
+ Download the following artifacts as above:
- `conda-linux-64.zip` (CircleCI)
- `conda-win-64.zip` (AppVeyor)
- `conda-osx-64.zip` (Travis)
+ Unzip each artifact
+ `conda-linux-64.zip` becomes `linux-64/plotly-orca-*.tar.bz2`
+ `conda-win-64.zip` becomes `win-64/plotly-orca-*.tar.bz2`
+ `conda-osx-64.zip` becomes `osx-64/plotly-orca-*.tar.bz2`
+ From a conda environment with the `anaconda-client` package installed run `anaconda login`
+ Enter the credentials for the plotly anaconda channel
+ For each of the three `plotly-orca-*.tar.bz2` files listed above, run `anaconda upload /path/to/XX-64/plotly-orca-*.tar.bz2`
+ Run `anaconda logout`
- :beers:

## Overview
Expand Down
8 changes: 8 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ version: 0.1.{build}
environment:
matrix:
- nodejs_version: 8
MINICONDA: C:\Miniconda36-x64

platform:
- x64
Expand All @@ -16,19 +17,26 @@ cache:

init:
- git config --global core.autocrlf input
- "set PATH=%MINICONDA%;%MINICONDA%\\Scripts;%MINICONDA%\\Library\\bin;%PATH%"
- conda install -y conda-build

install:
- ps: Install-Product node $env:nodejs_version $env:platform
- npm i
- conda build recipe\
- dir C:\Miniconda36-x64\conda-bld\win-64

build_script:
- npm run pack

after_build:
- 7z a release.zip release/latest.yml release/*.exe
- 7z a conda-win-64.zip C:\Miniconda36-x64\conda-bld\win-64\

artifacts:
- path: release.zip
name: release
- path: conda-win-64.zip
name: conda_package

test: off
2 changes: 1 addition & 1 deletion bin/orca.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
"/Applications/orca.app/Contents/MacOS/orca" "$@"
exec "/Applications/orca.app/Contents/MacOS/orca" "$@"
83 changes: 83 additions & 0 deletions recipe/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
Building the conda package
==========================
This directory contains the configuration files that are needed to build
orca into a standalone conda package.

To build the conda package, first install
[Anaconda](https://www.anaconda.com/download/#macos) or
[Miniconda](https://conda.io/miniconda.html).

Next, use `conda` to install the `conda-build` package:

```bash
$ conda install conda-build
```

Finally, build the package from the root project directory:

```bash
$ conda build recipe/
```

The resulting package will be named `plotly-orca-*.tar.bz2`, and the build
command will display the full path of the output location.

How it works
------------
Here's a quick tour of the build configuration. For more information see the
official conda docs for
[building packags](https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html).

### `meta.yaml` ###
The `meta.yaml` file in this directory is the top-level configuration file for
the conda package. Here we specify the package name (`package.name`) and
version (`package.version`, more on the version logic below), along with the
relative path to the orca source directory (`source.path`).

The build number (`build.number`) parameter should always start at 1 for
each new version of orca. It should be incremented if it becomes necessary to
publish multiple conda builds that correspond to the same orca version.

By default, conda-build does a lot of work to
[make binary packages relocatable](https://conda.io/docs/user-guide/tasks/build-packages/make-relocatable.html).
On Linux, this logic results in a gconf settings warning being raised each
time orca is used, and it doens't seem to be necessary, so it has been
disabled by setting the `build.binary_relocation` property to `False`.

Finally, the `requirements.build` section is used to specify that we need
`nodejs` available during the package build process (but not at runtime).

## `build.sh` and `bld.bat`
The `build.sh` and `bld.bat` files are scripts with special names that are
recognized by conda-build. On Linux and OS X the `build.sh` script will be
executed in a fresh conda environment that contains only the packages
specified in the `requirements.build` section of `meta.yaml`
(just `nodejs` in our case). Likewise, on Windows the `bld.bat` script is
executed under the same conditions.

These build scripts all start off by running `npm install` and `npm run pack`
to create the electron build of orca in the `release/` directory.

Then, for each OS, the directory of extracted build files is moved to a
directory under the root of the environment
(conda populates the `PREFIX` environment variable with this location).

Finally, an entry-point script named `orca` (`orca.cmd` on Windows) is placed
somewhere in the environment that will end up on the user's `PATH`
(`$PREFIX/bin` for Linux and OS X, and just `$PREFIX` for Windows). This
script is responsible for passing command line arguments through to the `orca`
executable that lives somewhere inside the directory of build files that was
moved in the previous step.

## Package version and `load_setup_py_data()`
The canonical version string for `orca` resides in `package.json`. In order to
avoid having a separate copy of this string in `meta.yaml` we use the following
approach:

conda build provides a built-in function called `load_setup_py_data` that can
be used inside a `jinja2` template expression in `meta.yaml` to load all of
the metadata associated with the project's `setup.py` file. Orca is not a
Python library, but it order to take advantage of this function,
a `setup.py` script has been added to the root project directory. The
`setup.py` script is responsible for dynamically loading the version string
from the `package.json` file.
8 changes: 8 additions & 0 deletions recipe/bin/orca
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
exec /opt/anaconda1anaconda2anaconda3/lib/orca.app/Contents/MacOS/orca "$@"
else
# Assume linux
exec /opt/anaconda1anaconda2anaconda3/lib/orca_app/orca "$@"
fi
2 changes: 2 additions & 0 deletions recipe/bin/orca.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
"/opt/anaconda1anaconda2anaconda3\orca_app\orca.exe" %*
4 changes: 4 additions & 0 deletions recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
call npm install
call npm run pack
move release\win-unpacked "%PREFIX%\orca_app"
copy "%RECIPE_DIR%\bin\orca.cmd" "%PREFIX%\"
17 changes: 17 additions & 0 deletions recipe/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh
npm install
npm run pack
mkdir -p $PREFIX/lib

if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
mv release/mac/orca.app $PREFIX/lib
else
# Assume Linux
mv release/linux-unpacked/ $PREFIX/lib/orca_app
fi

mkdir -p $PREFIX/bin
ORCA_ENTRY=$PREFIX/bin/orca
cp $RECIPE_DIR/bin/orca $ORCA_ENTRY
chmod +x $ORCA_ENTRY
16 changes: 16 additions & 0 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% set data = load_setup_py_data() %}

package:
name: plotly-orca
version: {{ data.get('version') }}

source:
path: ../

build:
number: 1
binary_relocation: False

requirements:
build:
- nodejs =8
20 changes: 20 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from distutils.core import setup
import json

# Rational
# --------
# This file only exists to help give conda-build access to the version in our
# package.json file. conda-build has built-in support for loading meta-data
# from setup.py through the load_setup_py_data() function. See
# https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#

with open('package.json') as f:
package_json=json.load(f)

# Convert NPM-compatible semantic version (e.g. "1.0.1-rc.1")
# to setup tools compatible version string (e.g. "1.0.1rc1")
npm_version = package_json['version']
ver_split = npm_version.split('-')
py_version = ver_split[0] + ''.join(ver_split[1:]).replace('.', '')

setup(version=py_version)