File: installp.py

package info (click to toggle)
htmlgen 2.2.2-12.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,840 kB
  • ctags: 1,480
  • sloc: python: 4,518; makefile: 93
file content (46 lines) | stat: -rwxr-xr-x 1,324 bytes parent folder | download | duplicates (7)
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
#! /usr/bin/env python
"""Script to copy given files into Python's path.
"""
import sys, os, string, shutil, getopt

__version__ = '$Id: installp.py,v 1.2 1999/02/04 04:57:34 friedric Exp $'

def main():
    FORCE = 0
    try:
        opts, files = getopt.getopt(sys.argv[1:], 'f')
        if not files: raise getopt.error
    except getopt.error:
        print "Usage: %s [-f] pymodule [npymodule...]" % sys.argv[0]
        sys.exit(1)
    for opt in opts:
        if opt == '-f': FORCE = 1

    v = sys.version[:3]

    if string.atof(v) >= 1.5:
        sp = "%s/lib/python%s/site-packages" % (sys.prefix, v)
        if not os.path.exists(sp):
            os.mkdir(sp)
    else:
        print "looks like Python is older than 1.5"
        sp = "%s/lib/python%s" % (sys.prefix, v)

    if not FORCE:
        ans = raw_input("Install Python modules into %s? [y] " % sp)
        if ans in ('','y','Y','yes','Yes'):
            print 'COPYING FILES:',
            for file in files:
                shutil.copy2(file, sp)
                print file,
                sys.stdout.flush()
        print 'TO', sp
    else:
        print 'COPYING FILES:', 
        for file in files:
            shutil.copy2(file, sp)
            print file,
            sys.stdout.flush()
        print 'TO', sp

if __name__ == '__main__': main()