diff options
| author | Mac Mollison <mollison@cs.unc.edu> | 2010-03-13 12:54:44 -0500 |
|---|---|---|
| committer | Mac Mollison <mollison@cs.unc.edu> | 2010-03-13 12:54:44 -0500 |
| commit | 0431c82c03666e4fbdd2cce9ce96a65ee94df517 (patch) | |
| tree | d068c681ba4740697e7b38b6ce4aeae917c82677 /install.py | |
| parent | 122f457226f54ad23b7cd138512502e430e704dc (diff) | |
Created installer
Diffstat (limited to 'install.py')
| -rwxr-xr-x | install.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/install.py b/install.py new file mode 100755 index 0000000..720a1ab --- /dev/null +++ b/install.py | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | #!/usr/bin/env python | ||
| 2 | |||
| 3 | ################################################################################ | ||
| 4 | # Description | ||
| 5 | ################################################################################ | ||
| 6 | |||
| 7 | # This script installes (or re-installs) the unit_trace Python module, so that | ||
| 8 | # the unit_trace library can be imported with `import unit_trace` by a Python | ||
| 9 | # script, from anywhere on the system. | ||
| 10 | |||
| 11 | # The installation merely consists of copying the unit_trace directory to | ||
| 12 | # the default site_packages directory (which is the appropriate place to | ||
| 13 | # install Python packages). | ||
| 14 | |||
| 15 | # We do not use the Distutils system, provided by Python, because that | ||
| 16 | # is less convenient :-) | ||
| 17 | |||
| 18 | |||
| 19 | ################################################################################ | ||
| 20 | # Imports | ||
| 21 | ################################################################################ | ||
| 22 | |||
| 23 | import sys | ||
| 24 | import shutil | ||
| 25 | import os | ||
| 26 | |||
| 27 | |||
| 28 | ################################################################################ | ||
| 29 | # Do the install | ||
| 30 | ################################################################################ | ||
| 31 | |||
| 32 | # Determine destination directory for unit_trace module | ||
| 33 | dst = os.path.join(sys.prefix,'lib/python2.6/site-packages/unit_trace') | ||
| 34 | |||
| 35 | try: | ||
| 36 | # If the destination exists | ||
| 37 | if os.path.exists(dst): | ||
| 38 | # Delete it | ||
| 39 | shutil.rmtree(dst) | ||
| 40 | # Copy source to destination | ||
| 41 | shutil.copytree('unit_trace', dst) | ||
| 42 | except: | ||
| 43 | print("Error occurred. Make sure you run the script as root/with sudo.") | ||
| 44 | exit() | ||
| 45 | |||
| 46 | |||
| 47 | |||
