diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..874816c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea/ +/.venv diff --git a/manage.py b/manage.py index 8f13096..70ea14b 100755 --- a/manage.py +++ b/manage.py @@ -1,6 +1,19 @@ import os import sys import venv +import logging + +# logging root configuration +logging.basicConfig(level=logging.INFO, + format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') + + +def set_debug_mode(debug_mode): + if debug_mode: + logging.getLogger().setLevel(logging.DEBUG) + else: + logging.getLogger().setLevel(logging.INFO) + def distribute(): """Create new version on PyPI @@ -13,7 +26,7 @@ def distribute(): You need: PyPI username and password. You need to type in the PyPI password rather than copy-pasting. """ - + create_venv() install() os.system(activate() + ' && ' + 'pip install --upgrade build') @@ -21,6 +34,14 @@ def distribute(): os.system(activate() + ' && ' + 'pip install --upgrade twine') os.system(activate() + ' && ' + 'twine upload dist/*') +def create_venv(): + venv_dir = os.path.join(os.getcwd(), ".venv") + if not os.path.exists(venv_dir): + logging.info("Creating virtual environment...") + os.system('py -3 -m venv .venv') + else: + logging.info("Virtual environment already exists.") + def activate(): """Active virtual environment""" @@ -36,15 +57,12 @@ def activate(): def install(): """Install requirements to a virtual environment""" - print('Creating virtual environment..') - os.system('py -3 -m venv .venv') - - print('Installing requirements..') + logging.info("Installing requirements...") os.system(activate() + ' && ' + 'py -m pip install -r requirements.txt') - if __name__ == '__main__': #install() + set_debug_mode(debug_mode=True) distribute() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 4a2a08b..bacf74b 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ numpy scipy -matplotlib \ No newline at end of file +matplotlib +logging