Created
June 19, 2019 09:46
-
-
Save duke79/7b6e8d10fe01f58ca5f0bb0ae65797fa to your computer and use it in GitHub Desktop.
python dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set PYTHONPATH=%~dp0..\.. | |
python %~dp0..\py\dependencies.py %* | |
REM cli dep %* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
from lib.py.paths import py_path | |
# try: | |
# import requests | |
# except ImportError: | |
# print("Trying to Install required module: requests\n") | |
# os.system('python -m pip install requests') | |
req_path = os.path.join(py_path, "requirements.txt") | |
class Dependencies: | |
def freeze(self): | |
os.system("python -m pip freeze > " + req_path) | |
os.system("notepad " + req_path) | |
def install(self): | |
os.system("python -m pip install -r " + req_path) | |
if __name__ == "__main__": | |
dep = Dependencies() | |
if sys.argv[1].lower() == "freeze": | |
dep.freeze() | |
if sys.argv[1].lower() == "install": | |
dep.install() | |
if sys.argv[1].lower() == "-h" or sys.argv[1].lower() == "--help": | |
help = ''' | |
Dependency manager. | |
Usage: [freeze] [install] [-h,--help] | |
freeze : The pip dependencies are dumped into requirements.txt | |
install : The pip dependencies are installed from requirements.txt | |
-h|--help : Displays the usage of the command and the help of a list of common options | |
''' | |
print(help) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment