Merge lp:~smoser/curtin/trunk.1703755-install-in-virtualenv into lp:~curtin-dev/curtin/trunk

Proposed by Scott Moser
Status: Merged
Merged at revision: 530
Proposed branch: lp:~smoser/curtin/trunk.1703755-install-in-virtualenv
Merge into: lp:~curtin-dev/curtin/trunk
Diff against target: 43 lines (+16/-2)
1 file modified
setup.py (+16/-2)
To merge this branch: bzr merge lp:~smoser/curtin/trunk.1703755-install-in-virtualenv
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Ryan Harper (community) Approve
Review via email: mp+331675@code.launchpad.net

Commit message

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.

Description of the change

To Test:

$ mydir=$(mktemp -d)
$ virtualenv $mydir

$ . $mydir/bin/activate

$ bzr branch lp:~smoser/curtin/trunk.1703755-install-in-virtualenv
$ pip install ./trunk.1703755-install-in-virtualenv
Processing ./trunk.1703755-install-in-virtualenv
Installing collected packages: curtin
  Running setup.py install for curtin ... done
Successfully installed curtin-0.1.0

$ find $mydir/usr -type f
/tmp/tmp.tlpxXpa2ex/usr/share/doc/curtin/Makefile
/tmp/tmp.tlpxXpa2ex/usr/share/doc/curtin/index.rst
/tmp/tmp.tlpxXpa2ex/usr/share/doc/curtin/conf.py
/tmp/tmp.tlpxXpa2ex/usr/lib/curtin/helpers/shell-archive
/tmp/tmp.tlpxXpa2ex/usr/lib/curtin/helpers/smtar
/tmp/tmp.tlpxXpa2ex/usr/lib/curtin/helpers/partition
/tmp/tmp.tlpxXpa2ex/usr/lib/curtin/helpers/install-grub
/tmp/tmp.tlpxXpa2ex/usr/lib/curtin/helpers/common
/tmp/tmp.tlpxXpa2ex/usr/lib/curtin/helpers/list-flash-kernel-packages

To post a comment you must log in.
Revision history for this message
Ryan Harper (raharper) wrote :

Nicely done. Thanks!

review: Approve
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'setup.py'
2--- setup.py 2016-05-20 15:42:08 +0000
3+++ setup.py 2017-10-02 20:57:15 +0000
4@@ -1,6 +1,7 @@
5 from distutils.core import setup
6 from glob import glob
7 import os
8+import sys
9
10 import curtin
11
12@@ -8,6 +9,19 @@
13 def is_f(p):
14 return os.path.isfile(p)
15
16+
17+def in_virtualenv():
18+ try:
19+ if sys.real_prefix == sys.prefix:
20+ return False
21+ else:
22+ return True
23+ except AttributeError:
24+ return False
25+
26+
27+USR = "usr" if in_virtualenv() else "/usr"
28+
29 setup(
30 name="curtin",
31 description='The curtin installer',
32@@ -27,9 +41,9 @@
33 ],
34 scripts=glob('bin/*'),
35 data_files=[
36- ('/usr/share/doc/curtin',
37+ (USR + '/share/doc/curtin',
38 [f for f in glob('doc/*') if is_f(f)]),
39- ('/usr/lib/curtin/helpers',
40+ (USR + '/lib/curtin/helpers',
41 [f for f in glob('helpers/*') if is_f(f)])
42 ]
43 )

Subscribers

People subscribed via source and target branches