Skip to content

Commit

Permalink
Move Python dependencies out of Grunt
Browse files Browse the repository at this point in the history
  • Loading branch information
localjo committed Jan 3, 2018
1 parent 1475722 commit 87a19f1
Show file tree
Hide file tree
Showing 6 changed files with 1,433 additions and 793 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/node_modules
/web/ext/node_modules/*
python
.node-virtualenv/
*.pyc
.project
.settings
Expand Down
26 changes: 0 additions & 26 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ var buildNumber = moment.utc().format('YYMMDDHHmmss');

module.exports = function(grunt) {
var pkg = require('./package.json');
var env = grunt.option('env') || 'release';

var hasCustomOptions = fs.existsSync('options');
var optionsPath = hasCustomOptions ? 'options' : 'node_modules/worldview-options-eosdis';
Expand All @@ -25,14 +24,6 @@ module.exports = function(grunt) {
findCmd = 'find build -type d -empty -delete';
}

// Platform specific location for Python
var pythonPath;
if (process.platform === 'win32') {
pythonPath = 'python/Scripts';
} else {
pythonPath = 'python/bin';
}

grunt.initConfig({

pkg: pkg,
Expand Down Expand Up @@ -232,9 +223,6 @@ module.exports = function(grunt) {
},

exec: {
config: {
command: 'bash -c "PATH=' + pythonPath + ':"${PATH}" bin/wv-options-build "' + env
},

// After removing JavaScript and CSS files that are no longer
// need in a release build, there are a lot of empty directories.
Expand All @@ -243,14 +231,6 @@ module.exports = function(grunt) {
command: findCmd
},

fetch: {
command: 'bash -c "PATH=' + pythonPath + ':"${PATH}" FETCH_GC=1 bin/wv-options-build "' + env
},

python_packages: {
command: 'virtualenv python && bash -c "PATH=' + pythonPath + ':${PATH} pip install xmltodict isodate"'
},

rpmbuild: {
command: 'rpmbuild --define "_topdir $PWD/build/rpmbuild" ' + '-ba build/rpmbuild/SPECS/worldview.spec'
},
Expand Down Expand Up @@ -483,7 +463,6 @@ module.exports = function(grunt) {
'remove:build_config',
'git-rev-parse:config',
'remove:config_src',
'exec:config',
'markdown',
'copy:config_src',
'copy:brand_info',
Expand All @@ -492,8 +471,6 @@ module.exports = function(grunt) {
'copy:dist_config_versioned'
]);

grunt.registerTask('fetch', ['exec:fetch']);

grunt.registerTask('site', [
'load_branding',
'remove:build_site',
Expand All @@ -518,13 +495,10 @@ module.exports = function(grunt) {
]);

grunt.registerTask('apache-config', ['load_branding', 'copy:apache', 'replace:apache']);
grunt.registerTask('update-packages', ['exec:python_packages']);
grunt.registerTask('clean', ['remove:build']);
grunt.registerTask('distclean', ['remove:build', 'remove:dist']);

grunt.registerTask('default', [
'update-packages',
'fetch',
'build',
'config',
'site'
Expand Down
17 changes: 9 additions & 8 deletions bin/wv-options-build
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ die() {
exit 1
}

ENV=$1

[ -d "$SRC_DIR" ] || die "Options directory does not exist"

# Activate virtual Python environment
PATH=.node-virtualenv/bin:.node-virtualenv/Scripts:${PATH}

if [ "$FETCH_GC" ] ; then
rm -rf "$OPT_DIR/$ENV/gc/*"
rm -rf "$OPT_DIR/$ENV/colormaps/gc/*"
"$BIN_DIR/wv-options-fetch" "$OPT_DIR/$ENV/config.json" "$OPT_DIR/$ENV/gc"
rm -rf "$OPT_DIR/release/gc/*"
rm -rf "$OPT_DIR/release/colormaps/gc/*"
"$BIN_DIR/wv-options-fetch" "$OPT_DIR/release/config.json" "$OPT_DIR/release/gc"
exit 0
fi

Expand All @@ -39,9 +40,9 @@ mkdir -p "$BUILD_DIR" "$DEST_DIR"
cp -r "$SRC_DIR"/common/* "$BUILD_DIR"

if hash rsync 2>/dev/null; then
rsync -a "$SRC_DIR/$ENV"/* "$BUILD_DIR"
rsync -a "$SRC_DIR/release"/* "$BUILD_DIR"
else
cp -r "$SRC_DIR/$ENV"/* "$BUILD_DIR"
cp -r "$SRC_DIR/release"/* "$BUILD_DIR"
fi

mkdir -p "$DEST_DIR/config"
Expand All @@ -60,7 +61,7 @@ if [ -e "$BUILD_DIR/colormaps" ] ; then
if [ -d "$BUILD_DIR"/gc/colormaps ] ; then
cp -r "$BUILD_DIR"/gc/colormaps "$BUILD_DIR"/colormaps/gc
fi
"$BIN_DIR/wv-options-colormap" "$OPT_DIR/$ENV/config.json" \
"$BIN_DIR/wv-options-colormap" "$OPT_DIR/release/config.json" \
"$BUILD_DIR/colormaps" \
"$BUILD_DIR/config/palettes"
fi
Expand Down
Loading

0 comments on commit 87a19f1

Please sign in to comment.