Merge lp:~ted/snapcraft/cmdline-exec into lp:~snappy-dev/snapcraft/core

Proposed by Ted Gould
Status: Merged
Approved by: Sergio Schvezov
Approved revision: 174
Merged at revision: 183
Proposed branch: lp:~ted/snapcraft/cmdline-exec
Merge into: lp:~snappy-dev/snapcraft/core
Diff against target: 82 lines (+36/-2)
2 files modified
snapcraft/plugins/python2_project.py (+18/-1)
snapcraft/plugins/python3_project.py (+18/-1)
To merge this branch: bzr merge lp:~ted/snapcraft/cmdline-exec
Reviewer Review Type Date Requested Status
Sergio Schvezov Approve
Ted Gould Pending
Review via email: mp+271698@code.launchpad.net

This proposal supersedes 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

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

works like a charm, I'll follow up with a 'config' update branch.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'snapcraft/plugins/python2_project.py'
--- snapcraft/plugins/python2_project.py 2015-09-17 15:03:38 +0000
+++ snapcraft/plugins/python2_project.py 2015-09-18 18:06:30 +0000
@@ -15,6 +15,7 @@
15# along with this program. If not, see <http://www.gnu.org/licenses/>.15# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
17import os17import os
18import tempfile
1819
19import snapcraft20import snapcraft
2021
@@ -33,12 +34,28 @@
33 # and be in the PYTHONPATH. It's harmless if setuptools isn't34 # and be in the PYTHONPATH. It's harmless if setuptools isn't
34 # used.35 # used.
35 os.makedirs(self.dist_packages_dir, exist_ok=True)36 os.makedirs(self.dist_packages_dir, exist_ok=True)
37 setuptemp = self.copy_setup()
3638
37 return self.run(39 return self.run(
38 ['python2', 'setup.py', 'install', '--install-layout=deb',40 ['python2', setuptemp.name, 'install', '--install-layout=deb',
39 '--prefix={}/usr'.format(self.installdir)])41 '--prefix={}/usr'.format(self.installdir)])
4042
41 @property43 @property
42 def dist_packages_dir(self):44 def dist_packages_dir(self):
43 return os.path.join(45 return os.path.join(
44 self.installdir, 'usr', 'lib', 'python2.7', 'dist-packages')46 self.installdir, 'usr', 'lib', 'python2.7', 'dist-packages')
47
48 # Takes the setup.py file and puts a couple little gems on the
49 # front to make things work better.
50 def copy_setup(self):
51 setupout = tempfile.NamedTemporaryFile(mode='w+')
52
53 setupout.write('import sys\n')
54 setupout.write('sys.executable = "usr/bin/python2"\n\n')
55
56 with open('setup.py', 'r') as f:
57 for line in f:
58 setupout.write(line)
59
60 setupout.flush()
61 return setupout
4562
=== modified file 'snapcraft/plugins/python3_project.py'
--- snapcraft/plugins/python3_project.py 2015-09-18 03:23:38 +0000
+++ snapcraft/plugins/python3_project.py 2015-09-18 18:06:30 +0000
@@ -15,6 +15,7 @@
15# along with this program. If not, see <http://www.gnu.org/licenses/>.15# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
17import os17import os
18import tempfile
1819
19import snapcraft20import snapcraft
2021
@@ -37,11 +38,27 @@
37 # and be in the PYTHONPATH. It's harmless if setuptools isn't38 # and be in the PYTHONPATH. It's harmless if setuptools isn't
38 # used.39 # used.
39 os.makedirs(self.dist_packages_dir, exist_ok=True)40 os.makedirs(self.dist_packages_dir, exist_ok=True)
41 setuptemp = self.copy_setup()
40 return self.run(42 return self.run(
41 ['python3', 'setup.py', 'install', '--install-layout=deb',43 ['python3', setuptemp.name, 'install', '--install-layout=deb',
42 '--prefix=%s/usr' % self.installdir])44 '--prefix=%s/usr' % self.installdir])
4345
44 @property46 @property
45 def dist_packages_dir(self):47 def dist_packages_dir(self):
46 return os.path.join(48 return os.path.join(
47 self.installdir, 'usr', 'lib', 'python3', 'dist-packages')49 self.installdir, 'usr', 'lib', 'python3', 'dist-packages')
50
51 # Takes the setup.py file and puts a couple little gems on the
52 # front to make things work better.
53 def copy_setup(self):
54 setupout = tempfile.NamedTemporaryFile(mode='w+')
55
56 setupout.write('import sys\n')
57 setupout.write('sys.executable = "usr/bin/python3"\n\n')
58
59 with open('setup.py', 'r') as f:
60 for line in f:
61 setupout.write(line)
62
63 setupout.flush()
64 return setupout

Subscribers

People subscribed via source and target branches

to all changes: