-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
33 lines (24 loc) · 872 Bytes
/
Copy pathsetup.py
File metadata and controls
33 lines (24 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import subprocess
import sys
import pkg_resources
# Installs the specified package using pip
def install_package(package_name):
subprocess.check_call([sys.executable,
"-m", "pip", "install", package_name])
# Checks if the specified package is installed
def is_package_installed(package_name):
try:
pkg_resources.get_distribution(package_name)
return True
except pkg_resources.DistributionNotFound:
return False
# Installs packages listed in the specified file
def setup(file_path):
with open(file_path, 'r') as file:
for line in file:
package_name = line.strip()
if not is_package_installed(package_name):
install_package(package_name)
setup("./requirements/requirements.txt")
# setup("./requirements/requirements-dev.txt")
print("Setup finished.")