VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/python/doc/configure.html@ 22502

最後變更 在這個檔案從22502是 11746,由 vboxsync 提交於 16 年 前

export python lib to OSE

  • 屬性 svn:eol-style 設為 native
檔案大小: 10.4 KB
 
1<html>
2<!-- ***** BEGIN LICENSE BLOCK *****
3 - Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 -
5 - The contents of this file are subject to the Mozilla Public License Version
6 - 1.1 (the "License"); you may not use this file except in compliance with
7 - the License. You may obtain a copy of the License at
8 - http://www.mozilla.org/MPL/
9 -
10 - Software distributed under the License is distributed on an "AS IS" basis,
11 - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 - for the specific language governing rights and limitations under the
13 - License.
14 -
15 - The Original Code is PyXPCOM.
16 -
17 - The Initial Developer of the Original Code is
18 - ActiveState Tool Corporation.
19 - Portions created by the Initial Developer are Copyright (C) 2000-2001
20 - the Initial Developer. All Rights Reserved.
21 -
22 - Contributor(s):
23 -
24 - Alternatively, the contents of this file may be used under the terms of
25 - either the GNU General Public License Version 2 or later (the "GPL"), or
26 - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 - in which case the provisions of the GPL or the LGPL are applicable instead
28 - of those above. If you wish to allow use of your version of this file only
29 - under the terms of either the GPL or the LGPL, and not to allow others to
30 - use your version of this file under the terms of the MPL, indicate your
31 - decision by deleting the provisions above and replace them with the notice
32 - and other provisions required by the LGPL or the GPL. If you do not delete
33 - the provisions above, a recipient may use your version of this file under
34 - the terms of any one of the MPL, the GPL or the LGPL.
35 -
36 - ***** END LICENSE BLOCK ***** -->
37
38<head>
39<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
40<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
41<meta name="ProgId" content="FrontPage.Editor.Document">
42<title>Configuring your Environment</title>
43</head>
44
45<body>
46
47<h1>Building, Configuring and Testing Python XPCOM Package</h1>
48<p>This document attempts to explain how to build, configure and test the
49Python XPCOM Package. This document assumes you have already successfully
50built
51Mozilla from source and your environment is currently set up for such a build -
52see the <a href="http://www.mozilla.org/build/">Mozilla build documentation</a>
53for more information.</p>
54<p>PyXPCOM can be built on Windows using either the <i>nmake makefile.win</i>
55process, or the <i>configure; gmake</i> process used by Linux.</p>
56<h2>configure; gmake Instructions</h2>
57<h3>Preparing for the build</h3>
58<ul>
59 <li>Apply the patch in <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=129216">bugzilla
60 bug 129216</a>. (If this bug is marked as &quot;FIXED&quot;, it probably
61 means there is no need to apply the patch and that these docs are out of
62 date)</li>
63 <li>On Linux, you must have Python built for dynamic linking.&nbsp; <a href="http://aspn.activestate.com/ASPN/Python">ActivePython</a>
64 2.1 is one such build.</li>
65 <li>On Windows, you must have a Python source tree installed and built.&nbsp;
66 Patches gratefully accepted that allow an installed Python to be used (it
67 should not be hard!)</li>
68 <li>Ensure the Python interpreter you wish to use is on your path, such that
69 &quot;python&quot; will execute it correctly.&nbsp; The configure process
70 uses this to locate the Python support files.</li>
71</ul>
72<h3>Building</h3>
73<ul>
74 <li>From the top-level Mozilla directory, execute <i>./configure
75 --enable-extensions=python/xpcom</i>. As per the Mozilla build
76 instructions, you may add this option to your <i>.mozconfig</i> file.&nbsp;
77 If you wish to enable debugging, just enable it as you would normally for
78 Mozilla; PyXPCOM will pick up the same settings.<br>
79 (On Windows you will need to execute <i>sh ./configure ...</i> if running
80 from a Command Prompt.&nbsp; See the <a href="http://www.mozilla.org/build/win32.html#ss2.2b">Mozilla
81 win32 specific gmake build instructions</a> for more details.</li>
82 <li>Build the Mozilla tree as normal; PyXPCOM will automatically be
83 built.&nbsp; Alternatively, change to the top-level PyXPCOM directory and
84 execute <i>gmake</i> in that directory.</li>
85</ul>
86<h2>PyXPCOM outside Mozilla</h2>
87<p>When you are using PyXPCOM from inside mozilla, no additional configuration
88options should be necessary.&nbsp; However, if you wish to use PyXPCOM from
89stand-alone Python (ie, so you can write simple Python scripts that can be
90executed normally and use XPCOM), then additional environment variables must be
91setup.</p>
92<ul>
93 <li><a name="PYTHONPATH"><b>PYTHONPATH</b></a> - <tt>PYTHONPATH</tt> needs to
94 be set appropriately.&nbsp;You must manually ensure that the <i>mozilla/dist/bin/python</i>
95 directory (which is where PyXPCOM was installed during the build process) is
96 listed.&nbsp; Note that when PyXPCOM is used from within Mozilla (or any
97 other xpcom process), this path will automatically be added to sys.path.&nbsp;
98 It is only when Python directly uses xpcom that this step is necessary.<br>
99 If anything is wrong here you should get a normal <tt>ImportError</tt>.</li>
100</ul>
101<blockquote>
102 <p>Note that on Windows, the PYTHONPATH is generally maintained in the
103 Registry; however, you can set this variable at a DOS prompt, and it will still be
104added to the core PYTHONPATH.
105</blockquote>
106<ul>
107 <li><b><a name="PATH">PATH</a>, LD_LIBRARY_PATH, etc</b> - On Windows, you
108 must ensure that the Mozilla bin directory is listed on your PATH, or that
109 you execute your scripts with the Mozilla bin directory as the current
110 directory.<br>
111 On Linux, you must set your PATH and LD_LIBRARY_PATH variables
112 appropriately.&nbsp; However, you may find it simpler and easier to use the <i>run-mozilla.sh</i>
113 script in the Mozilla bin directory.&nbsp; For example, changing to the
114 Mozilla bin directory and executing:<br>
115 <i>./run-mozilla.sh python ~/src/mozilla/extensions/python/xpcom/test/regrtest.py</i><br>
116 should setup a correct environment and execute the PyXPCOM test suite.</li>
117</ul>
118<h2><a name="RunningTheTests">Testing your Setup</a></h2>
119<p>The Python XPCOM Package has a complete test suite.</p>
120<p>In the rest of this section, we walk through some simpler tests a step at a time,
121to help diagnose any problems.</p>
122<p><b>Note:</b> We recommend you do all your testing outside of <i> mozilla.exe</i>; it is far simpler to test all of
123this using the PyXPCOM package stand-alone.</p>
124<p><b>Note:</b> On Windows, if you use a debug build of Mozilla (i.e., in <i>dist\WIN32_D.OBJ\bin)</i>,
125 you <b>must</b> use <i>python_d.exe</i>; if you use a release build (i.e., in
126 a <i>dist\WIN32_O.OBJ\bin</i> directory), you must use <i>python.exe</i>.&nbsp;
127<i>makefile.stupid.win</i> handles this automatically.</p>
128<p>To test your setup:</p>
129<ol>
130 <li>Start Python, and check<br>
131 &gt;&gt;&gt; <i>import xpcom</i><br>
132 works. If not, <a href="#PYTHONPATH">check your PYTHONPATH</a> - the
133 main PyXPCOM package can not be located.&nbsp; Also check your <a href="#PATH">PATH</a>,
134 and if you are on Linux, remember that executing ./run-mozilla.sh python is
135 the easiest way.</li>
136 <li>Check<i><br>
137 &gt;&gt;&gt; import xpcom._xpcom</i><br>
138
139works. If not, then most likely your <a href="#PATH">Mozilla
140 directory is not on your path</a>, or something is wrong with <i>_xpcom(_d).pyd/_xpcommodule.so</i>.</li>
141
142 <li>Next run a simple test: <i>test/test_misc.py</i>.&nbsp;With a Windows debug build, the command may look like:<br>
143 <i>C:\Anywhere&gt; python_d \src\python\xpcom\test\test_misc.py<br>
144 </i>or on Linux<br>
145 <i>/home/user/src/mozilla/dist/bin$ python /home/user/src/python/xpcom/test/test_misc.py</i></li>
146</ol>
147<p>If you can't get this going, you won't get much further! (You may see a few
148errors - that is OK, as long as it appears something worked!).&nbsp; If
149everything looks OK, the
150next step is to register our test component and run our full test suite.</p>
151<h2><a name="Registration">Registering the Loader and Test Component</a></h2>
152<p>First register the generic Python loader. For instructions, see the <a href="file:///F:/src/as/Komodo/src/pyxpcom/xpcom/doc/architecture.html">architecture
153document</a>.&nbsp;Do this only once, regardless of how many
154Python components you have.&nbsp; Then install the test component itself, and
155finally you can test it!</p>
156<h3>Registering the Python Loader and Component</h3>
157<p>To register the Python Loader and Component:</p>
158<ol>
159 <li>Ensure the build process has put <i>pyloader.dll </i>(or <i>modpyloader.so</i>
160 for Unix), and the files <i> py_test_component.py </i> and <i> py_test_component.idl</i> into
161 the Mozilla <i>bin/components</i> directory.&nbsp; If not, copy the files
162 there manually.</li>
163 <li>Run <i>regxpcom </i>(or .<i>/run-mozilla.sh ./regxpcom</i> if appropriate).&nbsp;<i>regxpcom</i> is a standard Mozilla
164 executable, found in the <i>bin</i> directory, that detects the new DLL and
165 .py
166 files and registers them accordingly.&nbsp; You should
167 see a few messages that include the following:</li>
168</ol>
169<blockquote>
170 <pre>Registering: PythonComponentLoader
171Registered 1 Python components in pyloader.dll
172nsNativeComponentLoader: autoregistering succeeded
173Auto-registering all Python components in F:\src\mozilla\dist\WIN32_D.OBJ\bin\components
174Registering: PythonTestComponent
175Registered 1 Python components in py_test_component.py</pre>
176</blockquote>
177<p>If so (or you see no message at all), you are ready to run the test suite.</p>
178<p><b>Note</b>: If you execute this same step a second time, you will not
179see any of the above mentioned messages.&nbsp;XPCOM knows that nothing has
180changed since you last ran <i>regxpcom</i>, so nothing is registered.&nbsp; If
181you do not see these messages the first time you run it, there is the
182possibility that some other process, possibly the build process, has already
183executed this step.</p>
184<h2><b>Running the Test Suite</b></h2>
185<p>Before running the test suite, you should change to the <i>mozilla/xpcom/sample</i>
186directory and build it.&nbsp; This will build and install a sample component
187which is used by the test suite.&nbsp; If you do not have this component
188available, some of the Python tests will fail.</p>
189
190<p>To run the test suite, run <i>xpcom/test/regrtest.py.</i>&nbsp; This runs the
191tests and ensures that the test output is as expected.&nbsp; If all tests
192pass, you have a fully functioning Python XPCOM package.&nbsp; Enjoy!</p>
193
194</body>
195
196</html>
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette