From 02dc3ab7f53602e268d961a9aa6382ddf4391813 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Thu, 20 Apr 2017 11:31:35 +1000 Subject: [PATCH] Have stackviz output a usable python sdist It seems that on a CI node, we just want to have approximately "pip install stackviz" and have it "just work". This makes "npm run prod" produce a .tar.gz appropriate for this. Firstly, I have moved the gulp output to "gulp-build" rather than "build" because "build" is generic and can get distutils confused. Second, after building with gulp, we tack on a "setup.py sdist" call to generate the final package. Thirdly, the MANIFEST.in is updated to prune out unneeded files from the final distribution. pbr is putting everything in git into the manifest, but we can trim all all the nodejs source stuff. The generated files in gulp-build are added to the manifest (since they're generated, and not in git). Finally, these are added via data-files as "share/stackviz-html". This is essentially standalone and can be moved, or symlinked to as required. The end result is that the .tar.gz created is installable on nodes an contains everything required to run stackviz. Documentation is updated. Change-Id: I64cbc7e90bd2610733c9d5c6275cce99f2571883 Signed-off-by: Paul Belanger --- .gitignore | 1 + MANIFEST.in | 9 +++++++++ README.rst | 23 +++++++++++++++++------ gulp/config.js | 14 +++++++------- gulp/tasks/server.js | 4 ++-- package.json | 2 +- setup.cfg | 1 + 7 files changed, 38 insertions(+), 16 deletions(-) create mode 100644 MANIFEST.in diff --git a/.gitignore b/.gitignore index 157a3d6..66aab1d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .idea node_modules build +gulp-build app/js/templates.js app/data *.py[cod] diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..49c1f52 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,9 @@ +# ignore these; pbr is putting everything in git +# in the sdist, but we're a hybird package +prune test +prune gulp +prune app + +# The html/js to view results; created by npm run build +# installed in "html" via data-file in setup.cfg +recursive-include gulp-build * diff --git a/README.rst b/README.rst index 41e6ba6..3a4fba6 100644 --- a/README.rst +++ b/README.rst @@ -64,8 +64,21 @@ The production application can be build using:: gulp prod -The result will be written to :code:`./build` and should be appropriate for -distribution. Note that all files are not required: +This will automatically build portable html/javascript and python +utilities into ``dist/stackviz-VERSION.tar.gz``. + +You should probably install this into a ``virtualenv`` on the target +system:: + + virtualenv stackviz + ./virtualenv/bin/pip install /path/to/stackviz-VERSION.tar.gz + # to run stackviz export + ./virtualenv/bin/stackviz-export + +Note the required html will be placed in ``virtualenv/share/stackviz-html`` +as a data-file (or elsewhere, if installed as a system package; this +may vary on distributions). This can be moved as required. Note that +all files in there are not required: - Directory structure (:code:`js/`, :code:`css/`, :code:`fonts/`, :code:`images/`): required. @@ -77,10 +90,8 @@ distribution. Note that all files are not required: - Source maps (:code:`js/main.js.map`, :code:`js/main.js.map.gz`): only required for debugging purposes. -Data should be written to :code:`build/data/` using :code:`stackviz-export` like -above. Note that the static production code generated above is portable, and can -be generated anywhere and copied to another host to be combined with exported -data. +Data should be written to :code:`stackviz-html/data/` using +:code:`stackviz-export` like above. Testing ======= diff --git a/gulp/config.js b/gulp/config.js index 5976d1d..36f15ec 100644 --- a/gulp/config.js +++ b/gulp/config.js @@ -8,17 +8,17 @@ module.exports = { 'styles': { 'src' : 'app/styles/**/*.scss', - 'dest': 'build/css' + 'dest': 'gulp-build/css' }, 'scripts': { 'src' : 'app/js/**/*.js', - 'dest': 'build/js' + 'dest': 'gulp-build/js' }, 'fonts': { 'src' : ['app/fonts/**/*'], - 'dest': 'build/fonts' + 'dest': 'gulp-build/fonts' }, 'views': { @@ -31,14 +31,14 @@ module.exports = { }, 'gzip': { - 'src': 'build/**/*.{html,xml,json,css,js,js.map}', + 'src': 'gulp-build/**/*.{html,xml,json,css,js,js.map}', 'rewrite': '**/*.html', - 'dest': 'build/', + 'dest': 'gulp-build/', 'options': {} }, 'dist': { - 'root' : 'build' + 'root' : 'gulp-build' }, 'browserify': { @@ -54,7 +54,7 @@ module.exports = { 'data': { 'src' : ['app/data/**/*'], - 'dest': 'build/data' + 'dest': 'gulp-build/data' } }; diff --git a/gulp/tasks/server.js b/gulp/tasks/server.js index 08250c9..b69e385 100644 --- a/gulp/tasks/server.js +++ b/gulp/tasks/server.js @@ -17,7 +17,7 @@ gulp.task('server', function() { // Serve index.html for all routes to leave routing up to Angular server.all('/*', function(req, res) { - res.sendFile('index.html', { root: 'build' }); + res.sendFile('index.html', { root: 'gulp-build' }); }); // Start webserver if not already running @@ -33,4 +33,4 @@ gulp.task('server', function() { s.listen(config.serverPort); -}); \ No newline at end of file +}); diff --git a/package.json b/package.json index fb39216..3299b09 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,6 @@ "postinstall": "if [ ! -d .venv ]; then tox -epy27 --notest; fi", "test": "gulp unit", "lint": "eslint ./", - "prod": "gulp prod" + "prod": "gulp prod; python setup.py sdist" } } diff --git a/setup.cfg b/setup.cfg index 14f1bc2..5c62cbc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,6 +22,7 @@ classifier = [files] packages = stackviz +data-files = share/stackviz-html = gulp-build/* [entry_points] console_scripts =