Skip to content

Commit

Permalink
Merge pull request #3 in VISI/thelper from make-install to master
Browse files Browse the repository at this point in the history
* commit '3d01b1476d9b476449f1f1756ca0c58069699027':
  Update changelog & reqs for initial release
  Update license and authors for init release
  Fixup initial version bump release
  fix make docs
  bump version makefile
  makefiles utils
  requirements install linux
  • Loading branch information
plstcharles committed Oct 3, 2018
2 parents 2e56e97 + 3d01b14 commit 5663782
Show file tree
Hide file tree
Showing 24 changed files with 454 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.0.0
current_version = 0.0.1
commit = True
tag = True

Expand All @@ -11,7 +11,7 @@ replace = version="{new_version}"
search = v{current_version}.
replace = v{new_version}.

[bumpversion:file:docs/conf.py]
[bumpversion:file:docs/source/conf.py]
search = version = release = "{current_version}"
replace = version = release = "{new_version}"

Expand Down
4 changes: 3 additions & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
Authors
=======

* Pierre-Luc St-Charles - pierreluc.stcharles<at>gmail.com
* Pierre-Luc St-Charles - stcharpl<at>crim.ca
* Francis Charette Migneault - francis.charette-migneault<at>crim.ca
* Mario Beaulieu - mario.beaulieu<at>crim.ca
4 changes: 2 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Changelog
=========

0.1.0 (Summer 2018)
0.0.1 (2018/10/03)
-------------------

* Initial WiP release.
* Initial release (work in progress).
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Apache Software License 2.0

Copyright (c) 2018, Pierre-Luc St-Charles
Copyright (c) 2018, Centre de Recherche Informatique de Montreal (CRIM)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -12,4 +12,4 @@ Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
184 changes: 184 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
define BROWSER_PYSCRIPT
import os, webbrowser, sys
try:
from urllib import pathname2url
except:
from urllib.request import pathname2url

webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
endef
export BROWSER_PYSCRIPT
BROWSER := python -c "$$BROWSER_PYSCRIPT"

CUR_DIR := $(abspath $(lastword $(MAKEFILE_LIST))/..)
APP_ROOT := $(CURDIR)
APP_NAME := $(shell basename $(APP_ROOT))

# Anaconda
ANACONDA_HOME ?= $(HOME)/anaconda
CONDA_ENV ?= $(APP_NAME)
CONDA_ENVS_DIR ?= $(HOME)/.conda/envs
CONDA_ENV_PATH := $(CONDA_ENVS_DIR)/$(CONDA_ENV)
DOWNLOAD_CACHE := $(APP_ROOT)/downloads
PYTHON_VERSION := 3.6

# choose anaconda installer depending on your OS
ANACONDA_URL = https://repo.continuum.io/miniconda
OS_NAME := $(shell uname -s 2>/dev/null || echo "unknown")
ifeq "$(OS_NAME)" "Linux"
FN := Miniconda3-latest-Linux-x86_64.sh
else ifeq "$(OS_NAME)" "Darwin"
FN := Miniconda3-latest-MacOSX-x86_64.sh
else
FN := unknown
endif


.DEFAULT_GOAL := help

.PHONY: all
all: help

.PHONY: help
help:
@echo "bump bump version using version specified as user input"
@echo "bump-dry bump version using version specified as user input (dry-run)"
@echo "bump-tag bump version using version specified as user input, tags it and commits the change in git"
@echo "clean remove all build, test, coverage and Python artifacts"
@echo "clean-build remove build artifacts"
@echo "clean-env remove package environment"
@echo "clean-pyc remove Python file artifacts"
@echo "clean-test remove test and coverage artifacts"
@echo "lint check style with flake8"
@echo "test run tests quickly with the default Python"
@echo "test-all run tests on every Python version with tox"
@echo "coverage check code coverage quickly with the default Python"
@echo "docs generate Sphinx HTML documentation, including API docs"
@echo "release package and upload a release"
@echo "dist package"
@echo "install install the package to the active Python's site-packages"
@echo "install-docs install docs related components"
@echo "update same as 'install' but without conda packages installation"

.PHONY: bump
bump: conda_env
$(shell bash -c 'read -p "Version: " VERSION_PART; \
source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV); \
$(CONDA_ENV_PATH)/bin/bumpversion --config-file $(CUR_DIR)/.bumpversion.cfg \
--verbose --allow-dirty --no-tag --new-version $$VERSION_PART patch;')

.PHONY: bump-dry
bump-dry: conda_env
$(shell bash -c 'read -p "Version: " VERSION_PART; \
source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV); \
$(CONDA_ENV_PATH)/bin/bumpversion --config-file $(CUR_DIR)/.bumpversion.cfg \
--verbose --allow-dirty --dry-run --tag --tag-name "{new_version}" --new-version $$VERSION_PART patch;')

.PHONY: bump-tag
bump-tag: conda_env
$(shell bash -c 'read -p "Version: " VERSION_PART; \
source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV); \
$(CONDA_ENV_PATH)/bin/bumpversion --config-file $(CUR_DIR)/.bumpversion.cfg \
--verbose --allow-dirty --tag --tag-name "{new_version}" --new-version $$VERSION_PART patch;')

.PHONY: clean
clean: clean-build clean-pyc clean-test

.PHONY: clean-build
clean-build:
rm -fr $(CUR_DIR)/build/
rm -fr $(CUR_DIR)/dist/
rm -fr $(CUR_DIR)/.eggs/
find . -type f -name '*.egg-info' -exec rm -fr {} +
find . -type f -name '*.egg' -exec rm -f {} +

.PHONY: clean-env
clean-test:
@-test -d $(CONDA_ENV_PATH) && "$(ANACONDA_HOME)/bin/conda" remove -n $(CONDA_ENV) --yes --all

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

.PHONY: clean-test
clean-test:
rm -fr $(CUR_DIR)/.tox/
rm -f $(CUR_DIR)/.coverage
rm -fr $(CUR_DIR)/coverage/

.PHONY: lint
lint:
flake8 api tests

.PHONY: test
test:
python $(CUR_DIR)/setup.py test

.PHONY: test-all
test-all:
tox

.PHONY: coverage
coverage:
coverage run --source src/thelper setup.py test
coverage report -m
coverage html -d coverage
$(BROWSER) coverage/index.html

.PHONY: docs
docs: install-docs
echo $(CUR_DIR)
# generate module docs from code
$(CUR_DIR)/docs/sphinx "apidoc" -o $(CUR_DIR)/docs/source $(CUR_DIR)/src
# generate documentation from generated code docs and other metadata
$(MAKE) -C $(CUR_DIR)/docs clean
$(MAKE) -C $(CUR_DIR)/docs html
$(BROWSER) $(CUR_DIR)/docs/build/html/index.html

.PHONY: install-docs
install-docs: clean conda_env
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV); pip install -r $(CUR_DIR)/docs/requirements.txt"

.PHONY: install
install: clean conda_env
# install packages that fail with pip using conda instead
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV); $(ANACONDA_HOME)/bin/conda install -y gdal pyproj"
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV); pip install -r $(CUR_DIR)/requirements.txt"
# enforce pip install using cloned repo
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV); pip install $(CUR_DIR)/src/thelper --no-deps"
$(MAKE) clean

.PHONY: update
update: clean
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV); pip install $(CUR_DIR)"

# Anaconda targets

.PHONY: anaconda
anaconda:
@echo "Installing Anaconda ..."
@test -d $(ANACONDA_HOME) || curl $(ANACONDA_URL)/$(FN) --silent --insecure --output "$(DOWNLOAD_CACHE)/$(FN)"
@test -d $(ANACONDA_HOME) || bash "$(DOWNLOAD_CACHE)/$(FN)" -b -p $(ANACONDA_HOME)
@echo "Add '$(ANACONDA_HOME)/bin' to your PATH variable in '.bashrc'."

.PHONY: conda_config
conda_config: anaconda
@echo "Update ~/.condarc"
@"$(ANACONDA_HOME)/bin/conda" config --add envs_dirs $(CONDA_ENVS_DIR)
@"$(ANACONDA_HOME)/bin/conda" config --set ssl_verify true
@"$(ANACONDA_HOME)/bin/conda" config --set use_pip true
@"$(ANACONDA_HOME)/bin/conda" config --set channel_priority true
@"$(ANACONDA_HOME)/bin/conda" config --set auto_update_conda false
@"$(ANACONDA_HOME)/bin/conda" config --add channels defaults
@"$(ANACONDA_HOME)/bin/conda" config --append channels birdhouse
@"$(ANACONDA_HOME)/bin/conda" config --append channels conda-forge

.PHONY: conda_env
conda_env: anaconda conda_config
@echo "Update conda environment $(CONDA_ENV) using $(ANACONDA_HOME) ..."
@test -d $(CONDA_ENV_PATH) || "$(ANACONDA_HOME)/bin/conda" create -y -n $(CONDA_ENV) python=$(PYTHON_VERSION)
"$(ANACONDA_HOME)/bin/conda" install -y -n $(CONDA_ENV) setuptools=$(SETUPTOOLS_VERSION)
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV); pip install --upgrade pip"
36 changes: 20 additions & 16 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Overview

.. |commits-since| image:: https://img.shields.io/github/commits-since/plstcharles/thelper/latest.svg
:alt: Commits since latest release
:target: https://github.com/plstcharles/thelper/compare/v0.0.0...master
:target: https://github.com/plstcharles/thelper/compare/v0.0.1...master

.. not ready for live version (WiP)
Expand Down Expand Up @@ -58,38 +58,38 @@ This library provides training help & tools for PyTorch-based machine learning p
Installation
============
::
pip install thelper
Documentation
=============
https://thelper.readthedocs.io/
Development
===========
To run the all tests run::
tox
Note, to combine the coverage data from all the tox environments run:
.. list-table::
:widths: 10 90
:stub-columns: 1
- - Windows
- ::
set PYTEST_ADDOPTS=--cov-append
tox
- - Other
- ::
PYTEST_ADDOPTS=--cov-append tox
=====
Expand All @@ -102,10 +102,14 @@ To install locally, use ``pip install -e <PATH_TO_THIS_DIR>``, or ``pip install

Current dependencies:
- augmentor>=0.2.2
- matplotlib>=2.2.2
- numpy>=1.14.0
- matplotlib
- numpy
- opencv-python>=3.3.0
- torch>=0.4.0
- torchvision>=0.2.1
- tensorflow (for tensorboard only)
- tensorboardX==1.2
- bumpversion
- scikit-learn

The project's structure was originally generated by `cookiecutter <https://github.com/audreyr/cookiecutter>`_ via `ionelmc's template <https://github.com/ionelmc/cookiecutter-pylibrary>`_.
Loading

0 comments on commit 5663782

Please sign in to comment.