-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 80e231e
Showing
12 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
|
||
def ensure_installed(): | ||
pass |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
;;; Do not run pip install -r on this file, let the installer handle it. | ||
;;; Every line will be executed like [package package package];[args];[condition];[comment]. | ||
;;; If there's no condition, always install. | ||
torch torchvision torchaudio;--index-url https://download.pytorch.org/whl/cu117;windows | ||
torch torchvision torchaudio;;not windows |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from logging import info | ||
from install import ensure_installed | ||
|
||
info('Checking installs and venv') | ||
|
||
ensure_installed() # Installs missing packages |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@echo off | ||
where py -V > nul 2> nul | ||
if %errorlevel%==0 ( | ||
call run_py.bat | ||
) else ( | ||
call run_python.bat | ||
) | ||
pause |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
python main.py | ||
read -n1 -r -p "Press any key to exit..." key |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@echo off | ||
py main.py | ||
pause |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@echo off | ||
python main.py | ||
pause |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def run_command(command, args=''): | ||
pass |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import os | ||
|
||
|
||
def is_windows(): | ||
return os.name == 'nt' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from .os import is_windows | ||
|
||
|
||
def parse_requirements(req_file='install_requirements.txt'): | ||
|
||
# Some stuff for the install_requirements | ||
windows = is_windows() | ||
|
||
requirements_parsed = [] | ||
with open(req_file, 'r') as file: | ||
for line in file.readlines(): | ||
line = line.strip() | ||
|
||
# Make sure it can be unpacked | ||
semis = line.count(';') | ||
add_semis = (2 - semis) * ';' | ||
line = line + add_semis | ||
|
||
packages, args, condition = line.split(';')[:3] | ||
# if eval(condition): | ||
if condition: | ||
if eval(condition): | ||
for package in packages.split(' '): | ||
package = package.strip() | ||
if package: | ||
requirements_parsed.append(f'{package} {args}') | ||
return requirements_parsed |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import sys | ||
from .os import is_windows | ||
import os | ||
|
||
venv_name = 'venv' | ||
venv_activate_path = f'{venv_name}/' + 'Scripts/activate.bat' if is_windows() else 'bin/activate' | ||
|
||
|
||
def get_base_prefix_compat(): | ||
"""Get base/real prefix, or sys.prefix if there is none.""" | ||
return getattr(sys, "base_prefix", None) or getattr(sys, "real_prefix", None) or sys.prefix | ||
|
||
|
||
def in_venv(): | ||
return get_base_prefix_compat() != sys.prefix | ||
|
||
|
||
def activate_venv(): | ||
if not os.path.isdir(venv_name): | ||
pass | ||
# Launch the main.py with the venv | ||
exit() # Exit after the venv'ed version exits | ||
|
||
|
||
def ensure_venv(): | ||
if not in_venv(): | ||
print('activating venv') | ||
activate_venv() | ||
else: | ||
print('in venv') | ||
print('after venv in venv:', in_venv()) |