diff options
-rw-r--r-- | MANIFEST.in | 3 | ||||
-rw-r--r-- | requirements.txt | 1 | ||||
-rwxr-xr-x | run_install_nvm.sh | 34 | ||||
-rwxr-xr-x | run_tests.sh | 39 | ||||
-rw-r--r-- | setup.py | 6 |
5 files changed, 81 insertions, 2 deletions
diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..3c0f2df --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +include LICENSE +include README +recursive-include diplomacy * diff --git a/requirements.txt b/requirements.txt index 720e170..5e30692 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ bcrypt coloredlogs +numpy python-dateutil pytz tornado>=5.0 diff --git a/run_install_nvm.sh b/run_install_nvm.sh new file mode 100755 index 0000000..e2405c1 --- /dev/null +++ b/run_install_nvm.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# Setting env variables +if [ -z ${NVM_DIR+x} ]; then + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" +fi + +# Downloading and install NVM +if [ ! -d "$HOME/.nvm" ]; then + curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh -o install_nvm.sh + bash install_nvm.sh + rm -Rf install_nvm.sh + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" + nvm install v8.11.2 + echo "Done installing NVM v0.33.8 and NodeJS v8.11.2" +else + echo "NVM is already installed in ~/.nvm" +fi + +# Installing dependencies +if [ -d "$DIR/diplomacy/web/" ]; then + cd $DIR/diplomacy/web + rm -Rf node_modules + npm install . + npm install . --only=dev + cd - +else + echo "Folder $DIR/diplomacy/web does not exists. Cannot install package.json" +fi diff --git a/run_tests.sh b/run_tests.sh new file mode 100755 index 0000000..9606844 --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Syntax: ./run_tests -- Run tests in parallel across CPUs +# ./run_tests <nb_cores> -- Run tests in parallel across this number of CPUs +# ./run_tests 0 -- Only runs the pylint tests +export PYTHONIOENCODING=utf-8 +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +FAILED=0 + +# Running pytest +if [ "${1:-auto}" != "0" ]; then + pytest -v --forked -n "${1:-auto}" || FAILED=1 +fi + +# Running pylint +find diplomacy -name "*.py" ! -name 'zzz_*.py' ! -name '_*.py' -exec pylint '{}' + && \ + +# Running eslint +if [ -f "$DIR/diplomacy/web/node_modules/.bin/eslint" ]; then + if [ -z ${NVM_DIR+x} ]; then + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" + fi + cd $DIR/diplomacy/web/ + node_modules/.bin/eslint --ext js,jsx . || FAILED=1 + npm run build || FAILED=1 + cd - +else + echo "Skipping ESLint. Make sure NVM and NodeJS are installed first." +fi + +# Exiting +if [[ "$FAILED" -eq 1 ]]; then + echo "*** TESTS FAILED ***" + exit 1 +else + echo "All tests passed." + exit 0 +fi @@ -16,7 +16,7 @@ # ============================================================================== """ Package installer """ import sys -from setuptools import setup +from setuptools import setup, find_packages # Requiring python 3.4+. # To simplify code for Tornado coroutines return statements, we don't support Python 3.3 @@ -34,10 +34,12 @@ setup(name=PACKAGE_NAME, version=PACKAGE_VERSION, author='Philip Paquette', author_email='pcpaquette@gmail.com', - packages=[PACKAGE_NAME.replace('-', '_')], + packages=find_packages(), + include_package_data=True, install_requires=[ 'bcrypt', 'coloredlogs', + 'numpy', 'python-dateutil', 'pytz', 'tornado>=5.0', |