Skip to content

Commit ea80bc2

Browse files
committed
IMPROVEMENT: Use a OS agnostic method for packaging the vehicle_template files
1 parent 31e6824 commit ea80bc2

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

setup.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
SPDX-License-Identifier: GPL-3
1111
'''
1212

13+
import shutil
1314
import os
14-
import subprocess
15+
1516
from setuptools import setup
1617
from setuptools import find_packages
1718

@@ -54,11 +55,21 @@
5455
f"{PRJ_URL}/raw/master/images/App_screenshot1.png")
5556

5657
# So that the vehicle_templates directory contents get correctly read by the MANIFEST.in file
58+
source_dir = 'vehicle_templates'
59+
dest_dir = 'MethodicConfigurator/vehicle_templates'
60+
61+
if os.path.exists(dest_dir):
62+
shutil.rmtree(dest_dir)
63+
5764
try:
58-
subprocess.check_call(['ln', '-sf', 'vehicle_templates', 'MethodicConfigurator/vehicle_templates'])
59-
print("Symbolic link created successfully.")
60-
except subprocess.CalledProcessError as e:
61-
print(f"Failed to create symbolic link: {e}")
65+
shutil.copytree(source_dir, dest_dir)
66+
print("Directory tree copied successfully.")
67+
except FileExistsError as e:
68+
print(f"The destination directory '{dest_dir}' already exists and cannot be overwritten.")
69+
except PermissionError as e:
70+
print(f"Permission denied when trying to copy '{source_dir}' to '{dest_dir}'. Please check your permissions.")
71+
except Exception as e: # pylint: disable=broad-except
72+
print(f"An unexpected error occurred while copying the directory tree: {e}")
6273

6374
setup(
6475
name='MethodicConfigurator',
@@ -126,8 +137,5 @@
126137
)
127138

128139
# Remove the symbolic link now that the setup is done
129-
try:
130-
os.unlink('MethodicConfigurator/vehicle_templates')
131-
print("Symbolic link removed successfully.")
132-
except FileNotFoundError:
133-
print("No symbolic link found to remove.")
140+
if os.path.exists(dest_dir):
141+
shutil.rmtree(dest_dir)

0 commit comments

Comments
 (0)