Merge lp:~ted/snapcraft/cmdline-exec into lp:~ted/snapcraft/python-pip

Proposed by Ted Gould
Status: Superseded
Proposed branch: lp:~ted/snapcraft/cmdline-exec
Merge into: lp:~ted/snapcraft/python-pip
Diff against target: 89 lines (+39/-2)
3 files modified
snapcraft/plugins/python2_project.py (+17/-1)
snapcraft/plugins/python3_project.py (+18/-1)
snapcraft/yaml.py (+4/-0)
To merge this branch: bzr merge lp:~ted/snapcraft/cmdline-exec
Reviewer Review Type Date Requested Status
Ted Gould Pending
Review via email: mp+271697@code.launchpad.net

This proposal has been superseded by a proposal from 2015-09-18.

Commit message

Wrap setup.py calls to configure the shebang writer

To post a comment you must log in.
lp:~ted/snapcraft/cmdline-exec updated
173. By Ted Gould

Merge trunk

174. By Ted Gould

Import tempfile

Unmerged revisions

174. By Ted Gould

Import tempfile

173. By Ted Gould

Merge trunk

172. By Ted Gould

Port over to the python2 project

171. By Ted Gould

Have a temporary setup.py to set the executable

170. By Ted Gould

Update to trunk and python-pip

169. By Ted Gould

We want some PIP!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'snapcraft/plugins/python2_project.py'
2--- snapcraft/plugins/python2_project.py 2015-09-17 15:03:38 +0000
3+++ snapcraft/plugins/python2_project.py 2015-09-18 18:02:22 +0000
4@@ -33,12 +33,28 @@
5 # and be in the PYTHONPATH. It's harmless if setuptools isn't
6 # used.
7 os.makedirs(self.dist_packages_dir, exist_ok=True)
8+ setuptemp = self.copy_setup()
9
10 return self.run(
11- ['python2', 'setup.py', 'install', '--install-layout=deb',
12+ ['python2', setuptemp.name, 'install', '--install-layout=deb',
13 '--prefix={}/usr'.format(self.installdir)])
14
15 @property
16 def dist_packages_dir(self):
17 return os.path.join(
18 self.installdir, 'usr', 'lib', 'python2.7', 'dist-packages')
19+
20+ # Takes the setup.py file and puts a couple little gems on the
21+ # front to make things work better.
22+ def copy_setup(self):
23+ setupout = tempfile.NamedTemporaryFile(mode='w+')
24+
25+ setupout.write('import sys\n')
26+ setupout.write('sys.executable = "usr/bin/python2"\n\n')
27+
28+ with open('setup.py', 'r') as f:
29+ for line in f:
30+ setupout.write(line)
31+
32+ setupout.flush()
33+ return setupout
34
35=== modified file 'snapcraft/plugins/python3_project.py'
36--- snapcraft/plugins/python3_project.py 2015-09-18 03:23:38 +0000
37+++ snapcraft/plugins/python3_project.py 2015-09-18 18:02:22 +0000
38@@ -15,6 +15,7 @@
39 # along with this program. If not, see <http://www.gnu.org/licenses/>.
40
41 import os
42+import tempfile
43
44 import snapcraft
45
46@@ -37,11 +38,27 @@
47 # and be in the PYTHONPATH. It's harmless if setuptools isn't
48 # used.
49 os.makedirs(self.dist_packages_dir, exist_ok=True)
50+ setuptemp = self.copy_setup()
51 return self.run(
52- ['python3', 'setup.py', 'install', '--install-layout=deb',
53+ ['python3', setuptemp.name, 'install', '--install-layout=deb',
54 '--prefix=%s/usr' % self.installdir])
55
56 @property
57 def dist_packages_dir(self):
58 return os.path.join(
59 self.installdir, 'usr', 'lib', 'python3', 'dist-packages')
60+
61+ # Takes the setup.py file and puts a couple little gems on the
62+ # front to make things work better.
63+ def copy_setup(self):
64+ setupout = tempfile.NamedTemporaryFile(mode='w+')
65+
66+ setupout.write('import sys\n')
67+ setupout.write('sys.executable = "usr/bin/python3"\n\n')
68+
69+ with open('setup.py', 'r') as f:
70+ for line in f:
71+ setupout.write(line)
72+
73+ setupout.flush()
74+ return setupout
75
76=== modified file 'snapcraft/yaml.py'
77--- snapcraft/yaml.py 2015-09-18 03:23:38 +0000
78+++ snapcraft/yaml.py 2015-09-18 18:02:22 +0000
79@@ -181,6 +181,10 @@
80
81 env = []
82
83+ env += part.env(part.installdir)
84+ env += self.runtime_env(part.installdir)
85+ env += self.build_env(part.installdir)
86+
87 for dep in part.deps:
88 root = dep.installdir
89 env += dep.env(root)

Subscribers

People subscribed via source and target branches

to all changes: