~raharper/curtin/trunk.fix-lp1722322

« back to all changes in this revision

Viewing changes to setup.py

setup.py: fix to allow installation into a virtualenv

This just makes '/usr' not be a full path.  It does not fix usage
of things that are are expected to be in /usr/ (the helpers).

The 'in_virtualenv' is the same method we employ for this function
in cloud-init.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from distutils.core import setup
2
2
from glob import glob
3
3
import os
 
4
import sys
4
5
 
5
6
import curtin
6
7
 
8
9
def is_f(p):
9
10
    return os.path.isfile(p)
10
11
 
 
12
 
 
13
def in_virtualenv():
 
14
    try:
 
15
        if sys.real_prefix == sys.prefix:
 
16
            return False
 
17
        else:
 
18
            return True
 
19
    except AttributeError:
 
20
        return False
 
21
 
 
22
 
 
23
USR = "usr" if in_virtualenv() else "/usr"
 
24
 
11
25
setup(
12
26
    name="curtin",
13
27
    description='The curtin installer',
27
41
    ],
28
42
    scripts=glob('bin/*'),
29
43
    data_files=[
30
 
        ('/usr/share/doc/curtin',
 
44
        (USR + '/share/doc/curtin',
31
45
         [f for f in glob('doc/*') if is_f(f)]),
32
 
        ('/usr/lib/curtin/helpers',
 
46
        (USR + '/lib/curtin/helpers',
33
47
         [f for f in glob('helpers/*') if is_f(f)])
34
48
    ]
35
49
)