-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto_update.py
More file actions
61 lines (48 loc) · 1.92 KB
/
Copy pathauto_update.py
File metadata and controls
61 lines (48 loc) · 1.92 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import os
import glob
import subprocess
import sys
def run_command(command):
"""Run a shell command and print its output."""
try:
result = subprocess.run(command, shell=True, check=True, text=True)
print(f"Command '{command}' executed successfully.")
except subprocess.CalledProcessError as e:
print(f"Error while executing '{command}': {e}")
sys.exit(1)
def clean_dist_folder():
"""Remove all files in the dist/ directory."""
dist_folder = "dist"
if os.path.exists(dist_folder):
print("Cleaning up dist/ folder...")
files = glob.glob(os.path.join(dist_folder, "*"))
for file in files:
os.remove(file)
print(f"Removed {file}")
else:
print("dist/ folder does not exist. Skipping cleanup.")
def verify_installation(package_name):
"""Verify if the package is installed."""
try:
result = subprocess.run(f"pip show {package_name}", shell=True, check=True, text=True, capture_output=True)
print(f"Package '{package_name}' installed successfully:\n{result.stdout}")
except subprocess.CalledProcessError:
print(f"Failed to verify installation of package '{package_name}'.")
# Verify the installation
# verify_installation("pepper")
def main():
# Step 1: Clean up dist/ folder
clean_dist_folder()
# Step 2: Uninstall the existing package
print("Uninstalling the existing package (if installed)...")
run_command("pip uninstall IRSTD -y")
# Step 3: Build the package
print("Building the package...")
run_command("python setup.py sdist bdist_wheel")
# Step 4: Install the newly built package
print("Installing the newly built package...")
run_command("pip install dist/*.whl")
print("Package installation completed successfully.")
verify_installation("IRSTD")
if __name__ == "__main__":
main()