Skip to content

Commit

Permalink
cookiecutter 0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
MacHu-GWU committed Dec 3, 2020
1 parent 782ca4b commit c591649
Show file tree
Hide file tree
Showing 29 changed files with 132 additions and 40 deletions.
18 changes: 18 additions & 0 deletions bin/py/activate.sh
@@ -0,0 +1,18 @@
#!/bin/bash
# -*- coding: utf-8 -*-
#
# activate your virtualenv quickly if not using pyenv-virtualenv
#
# usage:
#
# - activate: ``$ source ./bin/py/activate.sh``
# - deactivate: ``$ deactivate``

if [ -n "${BASH_SOURCE}" ]
then
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
else
dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
fi
source ${dir_here}/python-env.sh
source ${bin_activate}
2 changes: 1 addition & 1 deletion bin/py/build-doc-only.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 -*-

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
2 changes: 1 addition & 1 deletion bin/py/build-doc.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 -*-

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
2 changes: 1 addition & 1 deletion bin/py/clean-doc.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 -*-

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
2 changes: 1 addition & 1 deletion bin/py/clean.sh
Expand Up @@ -3,7 +3,7 @@
#
# Clean up all temp dir and files (except virtualenv)

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
2 changes: 1 addition & 1 deletion bin/py/deploy-doc-to-latest.sh
Expand Up @@ -4,7 +4,7 @@
# Deploy html doc to s3://<s3-bucket-name>/<dir-prefix>/<package-name>/latest


dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
2 changes: 1 addition & 1 deletion bin/py/deploy-doc-to-version.sh
Expand Up @@ -4,7 +4,7 @@
# Deploy html doc to s3://<s3-bucket-name>/<dir-prefix>/<package-name>/<version>


dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
2 changes: 1 addition & 1 deletion bin/py/deploy-doc.sh
Expand Up @@ -5,7 +5,7 @@
# and s3://<s3-bucket-name>/<dir-prefix>/<package-name>/latest


dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
2 changes: 1 addition & 1 deletion bin/py/info.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 -*-

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
21 changes: 21 additions & 0 deletions bin/py/md5.py
@@ -0,0 +1,21 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
find md5 checksum of a file.
"""

import hashlib


def find_md5_sum(path):
md5 = hashlib.md5()
with open(path, "rb") as f:
md5.update(f.read())
return md5.hexdigest()


if __name__ == "__main__":
import sys

print(find_md5_sum(sys.argv[1]))
2 changes: 1 addition & 1 deletion bin/py/pip-dev-install.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 -*-

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
2 changes: 1 addition & 1 deletion bin/py/pip-install.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 -*-

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
2 changes: 1 addition & 1 deletion bin/py/pip-uninstall.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 -*-

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
2 changes: 1 addition & 1 deletion bin/py/publish-to-pypi.sh
Expand Up @@ -3,7 +3,7 @@
#
# Publish this Package to https://pypi.org/

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
23 changes: 16 additions & 7 deletions bin/py/python-env.sh
Expand Up @@ -5,16 +5,21 @@
#
# This script should be sourced to use.
#
# This file is generated by cookiecutter-pygitrepo 0.0.2: https://github.com/MacHu-GWU/cookiecutter-pygitrepo/tree/0.0.2
# This file is generated by cookiecutter-pygitrepo 0.0.5: https://github.com/MacHu-GWU/cookiecutter-pygitrepo/tree/0.0.5

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
if [ -n "${BASH_SOURCE}" ]
then
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
else
dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
fi
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

source ${dir_bin}/settings.sh
source ${dir_bin}/source/detect-os.sh
source ${dir_bin}/source/helpers.sh

source ${dir_bin}/aws/aws-env.sh

# Virtualenv Name
venv_name="${package_name}_venv"
Expand Down Expand Up @@ -166,12 +171,16 @@ then
else
resolve_mac_venv ${venv_name} ${py_version} ${py_version_major_and_minor}
fi

elif [ "${os_is_linux}" = "Y" ]
then
bin_global_python="python${py_ver_major}.${py_ver_minor}"
bin_global_python="$(which ${bin_global_python})"
resolve_linux_venv ${venv_name} ${py_version} ${py_version_major_and_minor}
if [ "${use_pyenv}" = "Y" ]
then
resolve_linux_pyenv ${venv_name} ${py_version} ${py_version_major_and_minor}
else
resolve_linux_venv ${venv_name} ${py_version} ${py_version_major_and_minor}
fi
fi


Expand All @@ -194,10 +203,10 @@ deploy_doc_to_s3() {
aws s3 rm ${tmp_s3_uri_doc} \
--recursive \
--only-show-errors \
--profile ${aws_profile_doc_host}
${aws_cli_profile_arg}

echo "upload doc to ${tmp_s3_uri_doc}"
aws s3 sync ${tmp_path_sphinx_doc_build_html} ${tmp_s3_uri_doc} \
--only-show-errors \
--profile ${aws_profile_doc_host}
${aws_cli_profile_arg}
}
2 changes: 1 addition & 1 deletion bin/py/reformat-python-code.sh
Expand Up @@ -5,7 +5,7 @@
# to source code and tests
# using https://pypi.org/project/autopep8

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
2 changes: 1 addition & 1 deletion bin/py/req-dev.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 -*-

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
2 changes: 1 addition & 1 deletion bin/py/req-doc.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 -*-

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
2 changes: 1 addition & 1 deletion bin/py/req-info.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 -*-

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
2 changes: 1 addition & 1 deletion bin/py/req-test.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 -*-

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
2 changes: 1 addition & 1 deletion bin/py/run-notebook.sh
Expand Up @@ -3,7 +3,7 @@
#
# Run Jupyter notebook

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
2 changes: 1 addition & 1 deletion bin/py/test-cov.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 -*-

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
2 changes: 1 addition & 1 deletion bin/py/test-tox.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 -*-

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
2 changes: 1 addition & 1 deletion bin/py/test.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 -*-

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
2 changes: 1 addition & 1 deletion bin/py/venv-remove.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 -*-

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
19 changes: 16 additions & 3 deletions bin/py/venv-up.sh
@@ -1,17 +1,30 @@
#!/bin/bash
# -*- coding: utf-8 -*-

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

source ${dir_bin}/py/python-env.sh

print_colored_line $color_cyan "[DOING] create virtualenv for ${venv_name} at ${dir_venv} ..."
if [ ${use_pyenv} == "Y" ]; then
pyenv virtualenv ${py_version} ${venv_name}

if [ ${os_is_windows} == "Y" ]; then
virtualenv -p ${bin_global_python} ${dir_venv}
${bin_pip} install --upgrade pip
else

if [ ${use_pyenv} == "Y" ]; then
if this_command_exists "pyenv"; then
pyenv virtualenv ${py_version} ${venv_name}
${bin_pip} install --upgrade pip
else
print_colored_line $color_red "pyenv not installe, either install it from https://github.com/pyenv/pyenv, or set use_pyenv=\"N\" in ./bin/settings.sh"
exit 1
fi
else
virtualenv -p ${bin_global_python} ${dir_venv}
${bin_pip} install --upgrade pip
fi

fi
2 changes: 1 addition & 1 deletion bin/py/view-doc.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# -*- coding: utf-8 -*-

dir_here="$( cd "$(dirname "$0")" ; pwd -P )"
dir_here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
dir_bin="$(dirname "${dir_here}")"
dir_project_root=$(dirname "${dir_bin}")

Expand Down
12 changes: 5 additions & 7 deletions bin/settings.sh
Expand Up @@ -13,14 +13,12 @@ github_repo_name="superjson-project"

# Python
package_name="superjson"
py_ver_major="2"
py_ver_minor="7"
py_ver_micro="13"
use_pyenv="Y" # "Y" or "N"
supported_py_versions="2.7.13 3.4.6 3.5.3 3.6.2" # e.g: "2.7.13 3.6.2"
py_ver_major="3"
py_ver_minor="6"
py_ver_micro="2"
use_pyenv="N" # "Y" or "N"
supported_py_versions="3.6.2 3.7.9 3.8.6" # e.g: "3.6.2 3.7.9 3.8.6"


#--- Doc Build
rtd_project_name="superjson"


33 changes: 33 additions & 0 deletions bin/source/detect-runtime.sh
@@ -0,0 +1,33 @@
#!/bin/bash
# -*- coding: utf-8 -*-

curl -s http://169.254.169.254/latest/dynamic/instance-identity/ -m 1 > /tmp/null # timeout 1 second
if [ $? -eq 0 ]; then # if has response
is_ec2="Y"
else
is_ec2="N"
fi

if [ -n "$CI" ]; then # if has value
is_ci="Y"
else
is_ci="N"
fi

if [ -n "$TRAVIS" ]; then # if has value
is_travisci="Y"
else
is_travisci="N"
fi

if [ -n "$CIRCLECI" ]; then # if has value
is_circleci="Y"
else
is_circleci="N"
fi

if [ -n "$CODEBUILD_BUILD_ID" ]; then # if has value
is_aws_codebuild="Y"
else
is_aws_codebuild="N"
fi

0 comments on commit c591649

Please sign in to comment.