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