|
10 | 10 | SPDX-License-Identifier: GPL-3
|
11 | 11 | '''
|
12 | 12 |
|
| 13 | +import shutil |
13 | 14 | import os
|
14 |
| -import subprocess |
| 15 | + |
15 | 16 | from setuptools import setup
|
16 | 17 | from setuptools import find_packages
|
17 | 18 |
|
|
54 | 55 | f"{PRJ_URL}/raw/master/images/App_screenshot1.png")
|
55 | 56 |
|
56 | 57 | # 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 | + |
57 | 64 | 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}") |
62 | 73 |
|
63 | 74 | setup(
|
64 | 75 | name='MethodicConfigurator',
|
|
126 | 137 | )
|
127 | 138 |
|
128 | 139 | # 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