add parameter to specify python interpreter and commands to create and test virtual environments
This commit is contained in:
parent
690241a8a9
commit
d13bc88ab0
|
@ -5,5 +5,6 @@
|
|||
"description": "A short description of the project.",
|
||||
"year": "2016",
|
||||
"open_source_license": ["MIT", "BSD", "Not open source"],
|
||||
"s3_bucket": "[OPTIONAL] your-bucket-for-syncing-data (do not include 's3://')"
|
||||
"s3_bucket": "[OPTIONAL] your-bucket-for-syncing-data (do not include 's3://')",
|
||||
"python_interpreter": ["python", "python3"]
|
||||
}
|
||||
|
|
|
@ -5,13 +5,15 @@
|
|||
#################################################################################
|
||||
|
||||
BUCKET = {{ cookiecutter.s3_bucket }}
|
||||
PROJECT_NAME = {{ cookiecutter.repo_name }}
|
||||
PYTHON_INTERPRETER = {{ cookiecutter.python_interpreter }}
|
||||
|
||||
#################################################################################
|
||||
# COMMANDS #
|
||||
#################################################################################
|
||||
|
||||
## Install Python Dependencies
|
||||
requirements:
|
||||
requirements: test_environment
|
||||
pip install -q -r requirements.txt
|
||||
|
||||
## Make Dataset
|
||||
|
@ -34,6 +36,15 @@ sync_data_to_s3:
|
|||
sync_data_from_s3:
|
||||
aws s3 sync s3://$(BUCKET)/data/ data/
|
||||
|
||||
## Set up python interpreter environment
|
||||
setup_environment:
|
||||
source /usr/local/bin/virtualenvwrapper.sh; mkvirtualenv $(PROJECT_NAME) --python=$(PYTHON_INTERPRETER)
|
||||
@echo ">>> Activate virtualenv with:\nworkon $(PROJECT_NAME)"
|
||||
|
||||
## Test python environment is setup correctly
|
||||
test_environment:
|
||||
python test_environment.py
|
||||
|
||||
#################################################################################
|
||||
# PROJECT RULES #
|
||||
#################################################################################
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
import sys
|
||||
|
||||
REQUIRED_PYTHON = "{{ cookiecutter.python_interpreter }}"
|
||||
|
||||
|
||||
def main():
|
||||
system_major = sys.version_info.major
|
||||
if REQUIRED_PYTHON == "python":
|
||||
required_major = 2
|
||||
elif REQUIRED_PYTHON == "python3":
|
||||
required_major = 3
|
||||
else:
|
||||
raise ValueError("Unrecognized python interpreter: {}".format(
|
||||
REQUIRED_PYTHON))
|
||||
|
||||
if system_major != required_major:
|
||||
raise TypeError("This project requires Python {}. Found: {}".format(
|
||||
required_major, sys.version))
|
||||
else:
|
||||
print(">>> Development environment passes all tests!")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue