Merge lp:~bjornt/snapcraft/setuptools into lp:~snappy-dev/snapcraft/core

Proposed by Björn Tillenius on 2015-09-10
Status: Merged
Approved by: Ted Gould on 2015-09-14
Approved revision: 140
Merged at revision: 158
Proposed branch: lp:~bjornt/snapcraft/setuptools
Merge into: lp:~snappy-dev/snapcraft/core
Diff against target: 94 lines (+37/-4)
4 files modified
snapcraft/plugins/python2.py (+1/-0)
snapcraft/plugins/python2_project.py (+18/-2)
snapcraft/plugins/python3.py (+1/-0)
snapcraft/plugins/python3_project.py (+17/-2)
To merge this branch: bzr merge lp:~bjornt/snapcraft/setuptools
Reviewer Review Type Date Requested Status
Sergio Schvezov 2015-09-10 Approve on 2015-09-14
Ted Gould (community) 2015-09-11 Approve on 2015-09-14
Review via email: mp+270733@code.launchpad.net

Commit Message

Add support for setuptools based python projects.

Description of the Change

Add support for setuptools based Python project.

I initially did it for Python3 only, but then I saw lp:~sergiusens/snapcraft/setuptools for Python 2. I merged in that branch and made the implementations consistent.

To post a comment you must log in.
lp:~bjornt/snapcraft/setuptools updated on 2015-09-11
138. By Björn Tillenius on 2015-09-11

Merge trunk, resolve conflicts.

139. By Björn Tillenius on 2015-09-11

Lint.

Sergio Schvezov (sergiusens) wrote :

this looks good.

I would prefer os.path.join instead of self.installdir + '/... though

lp:~bjornt/snapcraft/setuptools updated on 2015-09-11
140. By Björn Tillenius on 2015-09-11

Use os.path.join()

Use single quotes instead of double quotes.

Björn Tillenius (bjornt) wrote :

On Fri, Sep 11, 2015 at 06:05:35PM -0000, Sergio Schvezov wrote:
> this looks good.
>
> I would prefer os.path.join instead of self.installdir + '/... though

Sure. I've changed it to use os.path.join()

I also changed all the strings to use single quotes, since you seem to
prefer that.

--
Björn Tillenius | https://launchpad.net/~bjornt

Ted Gould (ted) wrote :

So, what I don't love about this branch is that it pulls in setuptools everytime, even if you're not using it to build the package. All Python users are getting setup tools installed into their snap. Now, this isn't your fault. There isn't currently a way to fix this. Sergio is brainstorming a solution, but my thought is that if there's nothing easy we can take this as is with a TODO to fix that eventually.

Ted Gould (ted) wrote :

Talking on IRC about this, we don't have a solution for the packages yet, but we don't think this branch should block because of that.

review: Approve
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'snapcraft/plugins/python2.py'
2--- snapcraft/plugins/python2.py 2015-09-07 19:25:14 +0000
3+++ snapcraft/plugins/python2.py 2015-09-11 19:54:09 +0000
4@@ -21,6 +21,7 @@
5
6 _PLUGIN_STAGE_PACKAGES = [
7 'python-dev',
8+ 'python-setuptools',
9 ]
10
11 # note that we don't need to set PYTHONHOME here,
12
13=== modified file 'snapcraft/plugins/python2_project.py'
14--- snapcraft/plugins/python2_project.py 2015-08-03 18:21:58 +0000
15+++ snapcraft/plugins/python2_project.py 2015-09-11 19:54:09 +0000
16@@ -14,6 +14,8 @@
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20+import os
21+
22 import snapcraft
23
24
25@@ -26,6 +28,20 @@
26 return self.handle_source_options()
27
28 def build(self):
29+ # If setuptools is used, it tries to create files in the
30+ # dist-packages dir and import from there, so it needs to exist
31+ # and be in the PYTHONPATH. It's harmless if setuptools isn't
32+ # used.
33+ os.makedirs(self.dist_packages_dir, exist_ok=True)
34+ env = os.environ.copy()
35+ env['PYTHONPATH'] = self.dist_packages_dir
36+
37 return self.run(
38- ["python2", "setup.py", "install", "--install-layout=deb",
39- "--prefix={}/usr".format(self.installdir)])
40+ ['python2', 'setup.py', 'install', '--install-layout=deb',
41+ '--prefix={}/usr'.format(self.installdir)],
42+ env=env)
43+
44+ @property
45+ def dist_packages_dir(self):
46+ return os.path.join(
47+ self.installdir, 'usr', 'lib', 'python2.7', 'dist-packages')
48
49=== modified file 'snapcraft/plugins/python3.py'
50--- snapcraft/plugins/python3.py 2015-09-07 19:25:14 +0000
51+++ snapcraft/plugins/python3.py 2015-09-11 19:54:09 +0000
52@@ -21,6 +21,7 @@
53
54 _PLUGIN_STAGE_PACKAGES = [
55 'python3-dev',
56+ 'python3-setuptools',
57 ]
58
59 # note that we don't need to set PYTHONHOME here,
60
61=== modified file 'snapcraft/plugins/python3_project.py'
62--- snapcraft/plugins/python3_project.py 2015-07-22 18:23:16 +0000
63+++ snapcraft/plugins/python3_project.py 2015-09-11 19:54:09 +0000
64@@ -14,6 +14,8 @@
65 # You should have received a copy of the GNU General Public License
66 # along with this program. If not, see <http://www.gnu.org/licenses/>.
67
68+import os
69+
70 import snapcraft
71
72
73@@ -26,6 +28,19 @@
74 return self.handle_source_options()
75
76 def build(self):
77+ # If setuptools is used, it tries to create files in the
78+ # dist-packages dir and import from there, so it needs to exist
79+ # and be in the PYTHONPATH. It's harmless if setuptools isn't
80+ # used.
81+ os.makedirs(self.dist_packages_dir, exist_ok=True)
82+ env = os.environ.copy()
83+ env['PYTHONPATH'] = self.dist_packages_dir
84 return self.run(
85- ["python3", "setup.py", "install", "--install-layout=deb",
86- "--prefix=%s/usr" % self.installdir])
87+ ['python3', 'setup.py', 'install', '--install-layout=deb',
88+ '--prefix=%s/usr' % self.installdir],
89+ env=env)
90+
91+ @property
92+ def dist_packages_dir(self):
93+ return os.path.join(
94+ self.installdir, 'usr', 'lib', 'python3', 'dist-packages')

Subscribers

People subscribed via source and target branches