Skip to content
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

makefile #121

Merged
merged 18 commits into from
Jan 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: python
jobs:
include:
- name: "docker smoke tests"
- name: "docker"
if: branch IN (master, dev)
services: docker
python: 3.6
Expand All @@ -10,7 +10,7 @@ jobs:
install:
- pip install -U pip
- pip install tox-travis
script: tox -e docker-run-tests
script: tox -e docker
after_success:
-
- name: "Python 3.5"
Expand Down
7 changes: 4 additions & 3 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

- Added docker support (Pull request [#107](https://github.com/sertansenturk/tomato/pull/107))
- Improved `tomato` setup (Pull request [#118](https://github.com/sertansenturk/tomato/pull/118))
- Dropped Python 2 support; users are encouraged to switch to `tomato` docker (Pull request [#110](https://github.com/sertansenturk/tomato/pull/110))
- Dropped Mac OSX support; users are encouraged to switch to `tomato` docker (Pull request [#108](https://github.com/sertansenturk/tomato/pull/108))
- Dropped Python 2 support; users must to switch to Python 3.5 to 3.7 (Pull request [#110](https://github.com/sertansenturk/tomato/pull/110))
- Stopped active Mac OSX support; users are encouraged to switch to `tomato` docker (Pull request [#108](https://github.com/sertansenturk/tomato/pull/108))
- Introduced code linting (Pull request [#117](https://github.com/sertansenturk/tomato/pull/117))
- Added dockerized smoke tests for completeanalyzer and scoreconverter classes (Pull request [#120](https://github.com/sertansenturk/tomato/pull/120))
- Introduced `Makefile` (Pull request [#121](https://github.com/sertansenturk/tomato/pull/121))
- Introduced dockerized tests for completeanalyzer and scoreconverter classes (Pull request [#120](https://github.com/sertansenturk/tomato/pull/120))
- Added Github issue templates (Pull request [#101](https://github.com/sertansenturk/tomato/pull/101))

## tomato v0.13.0
Expand Down
198 changes: 181 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,186 @@
clean-dir:
rm -rf env dist build tomato.egg-info tomato/bin/phraseSeg tomato/bin/extractTonicTempoTuning tomato/bin/alignAudioScore tomato/bin/MusikiToMusicXml
SHELL := /bin/bash
.DEFAULT_GOAL := default
.PHONY: \
help default all-editable
clean clean-all clean-bin clean-build clean-pyc clean-test clean-$(VENV_NAME) purge \
install install-all install-all-editable install-mcr install-tomato \
docker-build test test-docker lint flake8 pylint isort

create-virtualenv:
virtualenv -p python3.6 env
VENV_INTERP = python3.6
VENV_NAME ?= venv

pip-install-development:
pip install --upgrade pip
python -m pip install -e .[development] -v
PIP_INST_EXTRA =
PIP_INST_DEV = development
PIP_INST_DEMO = demo
PIP_INST_ALL = $(PIP_INST_DEV),$(PIP_INST_DEMO)
PIP_FLAG =
PIP_INST_FLAG =
PIP_INST_EDIT = -e

build-docker-image:
docker build . -t sertansenturk/tomato:latest
MCR_DOWN_URL = http://www.mathworks.com/supportfiles/downloads/R2015a/deployment_files/R2015a/installers/glnxa64/MCR_R2015a_glnxa64_installer.zip
MCR_DOWNLOAD_PATH = /tmp/mcr-install
MCR_INST_PATH = /usr/local/MATLAB/MATLAB_Runtime/
MCR_PATH = $(MCR_INST_PATH)v85

docker-test-import:
make build-docker-image && \
docker run sertansenturk/tomato python3 -c \
"import tomato.symbolic.symbtrconverter; import tomato.joint.completeanalyzer"
DOCKER_TAG = sertansenturk/tomato
DOCKER_VER = latest
DOCKER_FILE = Dockerfile

docker-run-tests:
make build-docker-image && \
docker build . -f docker/tests/Dockerfile.smoke -t sertansenturk/tomato-smoke:latest && \
docker run sertansenturk/tomato-smoke python3 -m pytest tests
HELP_PADDING = 28
bold := $(shell tput bold)
sgr0 := $(shell tput sgr0)
padded_str := %-$(HELP_PADDING)s
pretty_command := $(bold)$(padded_str)$(sgr0)

help:
@printf "======= General ======\n"
@printf "$(pretty_command): run \"default\" (see below)\n"
@printf "$(pretty_command): run \"clean-all\", \"$(VENV_NAME)\", and \"install\" sequentially\n" default
@printf "$(pretty_command): run \"clean-all\", \"$(VENV_NAME)\", and \"install-all-editable\" sequentially\n" all-editable
@printf "\n"
@printf "======= Cleanup ======\n"
@printf "$(pretty_command): remove all build, test, coverage and python artifacts\n" clean
@printf "$(pretty_command): remove all (see: above) plus virtualenv, and tomato binaries\n" clean-all
@printf "$(padded_str)VENV_NAME, virtualenv name (default: $(VENV_NAME))\n"
@printf "$(pretty_command): remove tomato binaries\n" clean-bin
@printf "$(pretty_command): remove build artifacts\n" clean-build
@printf "$(pretty_command): remove python file artifacts\n" clean-pyc
@printf "$(pretty_command): remove test artifacts\n" clean-test
@printf "$(pretty_command): remove python virtualenv folder\n" clean-$(VENV_NAME)
@printf "$(padded_str)VENV_NAME, virtualenv name (default: $(VENV_NAME))\n"
@printf "$(pretty_command): alias of \"clean-all\"\n" purge
@printf "\n"
@printf "======= Setup =======\n"
@printf "$(pretty_command): install tomato in a virtualenv, and install MCR\n" install
@printf "$(padded_str)VENV_NAME, virtualenv name to install (default: $(VENV_NAME))\n"
@printf "$(padded_str)MCR_INST_PATH, path to install MCR (default: $(MCR_INST_PATH))\n"
@printf "$(padded_str)PIP_FLAG, pip flags (default: $(PIP_FLAG))\n"
@printf "$(padded_str)PIP_INST_FLAG, pip install flags (default: $(PIP_INST_FLAG))\n"
@printf "$(pretty_command): install tomato in a virtualenv with all extra dependencies, and install MCR\n" install-all
@printf "$(padded_str)VENV_NAME, virtualenv name to install (default: $(VENV_NAME))\n"
@printf "$(padded_str)MCR_INST_PATH, path to install MCR (default: $(MCR_INST_PATH))\n"
@printf "$(padded_str)PIP_FLAG, pip flags (default: $(PIP_FLAG))\n"
@printf "$(padded_str)PIP_INST_FLAG, pip install flags (default: $(PIP_INST_FLAG))\n"
@printf "$(pretty_command): install tomato in editable mode and in a virtualenv with all extra dependencies, and install MCR\n" install-all-editable
@printf "$(padded_str)VENV_NAME, virtualenv name to install (default: $(VENV_NAME))\n"
@printf "$(padded_str)MCR_INST_PATH, path to install MCR (default: $(MCR_INST_PATH))\n"
@printf "$(padded_str)PIP_FLAG, pip flags (default: $(PIP_FLAG))\n"
@printf "$(pretty_command): install MATLAB Runtime Compiler (MCR)\n" install-mcr
@printf "$(padded_str)MCR_DOWNLOAD_PATH, temporary folder to download MCR into (default: $(MCR_DOWNLOAD_PATH))\n"
@printf "$(padded_str)MCR_INST_PATH, path to install MCR (default: $(MCR_INST_PATH))\n"
@printf "$(pretty_command): install tomato in a virtualenv\n" install-tomato
@printf "$(padded_str)VENV_NAME, virtualenv name to install (default: $(VENV_NAME))\n"
@printf "$(padded_str)PIP_FLAG, pip flags (default: $(PIP_FLAG))\n"
@printf "$(padded_str)PIP_INST_FLAG, pip install flags (default: $(PIP_INST_FLAG))\n"
@printf "$(padded_str)PIP_INST_EXTRA, install from extras_require (default: $(PIP_INST_EXTRA), possible values: $(PIP_INST_ALL))\n"
@printf "$(pretty_command): create a virtualenv\n" $(VENV_NAME)
@printf "$(padded_str)VENV_NAME, virtualenv name (default: $(VENV_NAME))\n"
@printf "$(padded_str)VENV_INTERP, python interpreter (default: $(VENV_INTERP))\n"
@printf "\n"
@printf "======= Docker =======\n"
@printf "$(pretty_command): build docker image\n" docker-build
@printf "$(padded_str)DOCKER_TAG, docker image tag (default: $(DOCKER_TAG))\n"
@printf "$(padded_str)DOCKER_VER, docker image version (default: $(DOCKER_VER))\n"
@printf "\n"
@printf "======= Test and linting =======\n"
@printf "$(pretty_command): run all test and linting automations using tox\n" test
@printf "$(pretty_command): run docker build and test automation using tox\n" test-docker
@printf "$(pretty_command): run all style checking and linting automation using tox \n" lint
@printf "$(pretty_command): run flake8 for style guide (PEP8) checking using tox\n" flake8
@printf "$(pretty_command): run pylint using tox\n" pylint
@printf "$(pretty_command): sorts python imports\n" isort

default: clean-all $(VENV_NAME) install
all-editable: clean-all $(VENV_NAME) install-all-editable

purge: clean-all

clean-all: clean-pyc clean-build clean-test clean-$(VENV_NAME) clean-bin

clean: clean-pyc clean-build clean-test

clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +

clean-bin:
rm -rf tomato/bin/phraseSeg tomato/bin/extractTonicTempoTuning tomato/bin/alignAudioScore tomato/bin/MusikiToMusicXml

clean-build: ## remove build artifacts
rm -rf build/
rm -rf dist/
rm -rf .eggs/
rm -rf .pytest_cache
find . -name '.eggs' -type d -exec rm -rf {} +
find . -name '*.egg-info' -exec rm -rf {} +
find . -name '*.egg' -exec rm -f {} +

clean-test:
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/

clean-$(VENV_NAME):
rm -rf $(VENV_NAME)

$(VENV_NAME):
python3 -m virtualenv -p $(VENV_INTERP) $(VENV_NAME)

install: install-tomato install-mcr

install-all: PIP_INST_EXTRA:=$(PIP_INST_ALL)
install-all: install-tomato install-mcr

install-all-editable: PIP_INST_FLAG:=$(PIP_INST_EDIT)
install-all-editable: install-all

install-tomato: $(VENV_NAME)
source $(VENV_NAME)/bin/activate ; \
pip install --upgrade pip ; \
if [ "$(PIP_INST_EXTRA)" = "" ]; then \
python -m pip $(PIP_FLAG) install $(PIP_INST_FLAG) .; \
else \
python -m pip $(PIP_FLAG) install $(PIP_INST_FLAG) .[$(PIP_INST_EXTRA)]; \
fi

install-mcr:
if [ -z "$$(ls -A $(MCR_PATH))" ]; then \
echo "Installing MCR to $(MCR_PATH)..."; \
mkdir $(MCR_DOWNLOAD_PATH) ; \
cd $(MCR_DOWNLOAD_PATH) ; \
wget --progress=bar:force $(MCR_DOWN_URL) ; \
unzip -q MCR_R2015a_glnxa64_installer.zip ; \
$(MCR_DOWNLOAD_PATH)/install \
-destinationFolder $(MCR_INST_PATH) \
-agreeToLicense yes \
-mode silent ; \
cd / ; \
rm -rf $(MCR_DOWNLOAD_PATH) ; \
else \
echo "MCR is already installed to $(MCR_PATH). Skipping..."; \
fi

docker-build:
docker build . \
-f $(DOCKER_FILE) \
-t $(DOCKER_TAG):$(DOCKER_VER)

test:
tox

test-docker:
tox -e docker

lint:
tox -e lint

flake8:
tox -e flake8

pylint:
tox -e pylint

isort:
isort --skip-glob=.tox --recursive .
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ sudo apt-get install python3 python3.5-dev python3-pip libxml2-dev libxslt1-dev
It is recommended to install `tomato` and its dependencies into a virtualenv. In the terminal, do the following:

```bash
virtualenv -p python3 env
virtualenv -p python3 venv
```

Activate the virtual environment:

```bash
source env/bin/activate
source venv/bin/activate
```

Then, change the current directory to the repository folder and install by:
Expand All @@ -117,7 +117,7 @@ python -m pip install -e .
If you want to run the demo Jupyter notebooks and/or make development, you may include the extras to the installation by:

```bash
python -m pip install -e .[demos,development]
python -m pip install -e .[demo,development]
```

The requirements are installed during the setup. If that step does not work for some reason, you can install the requirements by calling:
Expand Down
File renamed without changes.
Loading