1 |
commit: c6b72853a6de8b71d1b5cd789a12aa934f7ce7c4 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Oct 6 07:05:21 2016 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Oct 6 15:37:59 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=c6b72853 |
7 |
|
8 |
setup.py: enable libc bindings optionally (bug 594744) |
9 |
|
10 |
The libc bindings are optional, since ctypes is used as a fallback when |
11 |
they are not available. The libc bindings do not support cross- |
12 |
compilation, therefore it is useful to be able to build them |
13 |
conditionally. This patch adds an option to enable them conditionally, |
14 |
which the ebuild can use by adding the following code to the |
15 |
python_prepare_all function: |
16 |
|
17 |
if use native-extensions; then |
18 |
printf "[build_ext]\nportage-ext-modules=true" >> \ |
19 |
setup.cfg || die |
20 |
fi |
21 |
|
22 |
X-Gentoo-Bug: 594744 |
23 |
X-Gentoo-Bug-URL: https://bugs.gentoo.org/594744 |
24 |
Acked-by: Alexander Berntsen <bernalex <AT> gentoo.org> |
25 |
|
26 |
.travis.yml | 1 + |
27 |
README | 19 +++++++++++++++++++ |
28 |
setup.py | 21 +++++++++++++++++++++ |
29 |
3 files changed, 41 insertions(+) |
30 |
|
31 |
diff --git a/.travis.yml b/.travis.yml |
32 |
index c098c4d..ded5893 100644 |
33 |
--- a/.travis.yml |
34 |
+++ b/.travis.yml |
35 |
@@ -10,6 +10,7 @@ python: |
36 |
install: "pip install lxml" |
37 |
|
38 |
script: |
39 |
+ - printf "[build_ext]\nportage-ext-modules=true" >> setup.cfg |
40 |
- ./setup.py test |
41 |
- ./setup.py install --root=/tmp/install-root |
42 |
# prevent repoman tests from trying to fetch metadata.xsd |
43 |
|
44 |
diff --git a/README b/README |
45 |
index 5e78842..311d036 100644 |
46 |
--- a/README |
47 |
+++ b/README |
48 |
@@ -13,6 +13,25 @@ Dependencies |
49 |
Python and Bash should be the only hard dependencies. Python 2.7 is the |
50 |
minimum supported version. |
51 |
|
52 |
+Native Extensions |
53 |
+================= |
54 |
+ |
55 |
+Portage includes some optional native extensions which can be built |
56 |
+in the source tree by running the following command: |
57 |
+ |
58 |
+ python setup.py build_ext --inplace --portage-ext-modules |
59 |
+ |
60 |
+The following setup.cfg settings can be used to enable building of |
61 |
+native extensions for all invocations of the build_ext command (the |
62 |
+build_ext command is invoked automatically by other build commands): |
63 |
+ |
64 |
+ [build_ext] |
65 |
+ portage-ext-modules=true |
66 |
+ |
67 |
+Currently, the native extensions only include libc bindings which are |
68 |
+used to validate LC_CTYPE and LC_COLLATE behavior for EAPI 6. If the |
69 |
+native extensions have not been built, then portage will use ctypes |
70 |
+instead. |
71 |
|
72 |
Licensing and Legalese |
73 |
======================= |
74 |
|
75 |
diff --git a/setup.py b/setup.py |
76 |
index e900aaa..eeabe70 100755 |
77 |
--- a/setup.py |
78 |
+++ b/setup.py |
79 |
@@ -6,6 +6,7 @@ from __future__ import print_function |
80 |
|
81 |
from distutils.core import setup, Command, Extension |
82 |
from distutils.command.build import build |
83 |
+from distutils.command.build_ext import build_ext as _build_ext |
84 |
from distutils.command.build_scripts import build_scripts |
85 |
from distutils.command.clean import clean |
86 |
from distutils.command.install import install |
87 |
@@ -624,6 +625,25 @@ def get_manpages(): |
88 |
yield [os.path.join('$mandir', topdir, 'man%s' % g), mans] |
89 |
|
90 |
|
91 |
+class build_ext(_build_ext): |
92 |
+ user_options = _build_ext.user_options + [ |
93 |
+ ('portage-ext-modules', None, |
94 |
+ "enable portage's C/C++ extensions (cross-compiling is not supported)"), |
95 |
+ ] |
96 |
+ |
97 |
+ boolean_options = _build_ext.boolean_options + [ |
98 |
+ 'portage-ext-modules', |
99 |
+ ] |
100 |
+ |
101 |
+ def initialize_options(self): |
102 |
+ _build_ext.initialize_options(self) |
103 |
+ self.portage_ext_modules = None |
104 |
+ |
105 |
+ def run(self): |
106 |
+ if self.portage_ext_modules: |
107 |
+ _build_ext.run(self) |
108 |
+ |
109 |
+ |
110 |
setup( |
111 |
name = 'portage', |
112 |
version = '2.3.1', |
113 |
@@ -651,6 +671,7 @@ setup( |
114 |
|
115 |
cmdclass = { |
116 |
'build': x_build, |
117 |
+ 'build_ext': build_ext, |
118 |
'build_man': build_man, |
119 |
'build_scripts': x_build_scripts, |
120 |
'build_scripts_bin': x_build_scripts_bin, |