44Getting Started
55===============
66
7+ .. highlight :: console
8+
79These instructions cover how to get a working copy of the source code and a
8- compiled version of the Jython interpreter (Jython is the version of Python
9- available from http://www.jython.org/). It also gives an overview of the
10+ compiled version of the Jython interpreter. (Jython is the version of Python
11+ available from http://www.jython.org.) It also gives an overview of the
1012directory structure of the Jython source code.
1113
1214OpenHatch has a partly-relevant `setup guide `_ for CPython for people who are
@@ -72,13 +74,13 @@ To get a working copy of the :ref:`in-development <indevbranch>` branch of
7274Jython (core developers use a different URL as outlined in :ref: `coredev `),
7375run::
7476
75- hg clone http://hg.python.org/jython
77+ $ hg clone http://hg.python.org/jython
7678
7779If you want a working copy of an already-released version of Jython,
7880i.e., a version in :ref: `maintenance mode <maintbranch >`, you can update your
7981working copy. For instance, to update your working copy to Jython 2.5, do::
8082
81- hg update 2.5
83+ $ hg update 2.5
8284
8385GitHub
8486^^^^^^
@@ -100,7 +102,20 @@ Compiling
100102
101103Compiling Jython is fairly simple, from the top level of a source checkout do::
102104
103- ant
105+ $ ant
106+
107+ Each time you issue this command, ``ant `` builds incrementally,
108+ by compiling those Java source files that have changed,
109+ and copying the Python and other files that have changed
110+ to the :file: `dist ` directory.
111+ Several other useful targets may be named to ``ant ``,
112+ in particular, ``ant clean `` will delete the :file: `dist ` and :file: `build `
113+ directories so that a subsequent plain ``ant `` will rebuild everything.
114+ The command::
115+
116+ $ ant -p
117+
118+ lists the top-level targets.
104119
105120.. _build-dependencies-jy :
106121
@@ -204,3 +219,67 @@ every rule.
204219``Tools ``
205220 Various tools that are (or have been) used to maintain Jython.
206221
222+
223+
224+ Manually regenerated files
225+ ==========================
226+
227+ Some files are programmatically generated, but not by ``ant ``,
228+ nor destroyed by ``ant clean ``.
229+ These must be regenerated by the developer when necessary,
230+ and new versions checked-in like source files.
231+
232+ Derived Java source
233+ -------------------
234+
235+ Some Java source that supports subclassing of built-in types
236+ is generated using Python scripts.
237+ These files need to be refreshed only when the signatures of exposed methods
238+ of the corresponding types change.
239+ A new one must be created when a new type is added.
240+ Notes about this are currently on the Jython Wiki at
241+ `Generating the *Derived classes <https://wiki.python.org/jython/GeneratedDerivedClasses >`_.
242+
243+ The launcher ``jython.exe ``
244+ ---------------------------
245+
246+ .. highlight :: ps1con
247+
248+ :file: `src/shell/jython.exe ` is the Windows Jython launcher.
249+ It is copied during the ``ant `` build to :file: `dist/bin `.
250+ However, it is derived from :file: `src/shell/jython.py ` using PyInstaller _
251+ by the following process.
252+
253+ If it is not already installed, install ``virtualenv ``
254+ with the command ``pip install virtualenv ``.
255+ In any convenient working directory, create a virtual environment, activate it,
256+ and install ``PyInstaller ``::
257+
258+ > virtualenv venv
259+ New python executable in ... venv\Scripts\python.exe
260+ Installing setuptools, pip, wheel...done.
261+ > .\venv\Scripts\activate
262+ (venv) > pip install pyinstaller
263+ Collecting pyinstaller
264+ ...
265+ Installing collected packages: future, pypiwin32, ..., pyinstaller
266+ Successfully installed ... pyinstaller-3.3
267+
268+ The above set-up need only be performed once.
269+
270+ Copy :file: `src/shell/jython.py ` to this working directory.
271+ Use ``PyInstaller `` to create a single-file executable,
272+ and copy that back to :file: `src/shell `::
273+
274+ (venv) > copy <checkoutdir>\src\shell\jython.py .
275+ (venv) > pyinstaller --onefile jython.py
276+ ...
277+ (venv) > copy .\dist\jython.exe <checkoutdir>\src\shell
278+
279+ Above, ``<checkoutdir> `` stands for the root directory of the Jython source.
280+ You *could * do all this in the source tree at :file: `src/shell `,
281+ but the virtual environment and ``PyInstaller `` leave a lot of
282+ working material behind, so it is best done elsewhere.
283+
284+ .. _PyInstaller : http://www.pyinstaller.org
285+
0 commit comments