Skip to content

Commit

Permalink
much simplified building instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
cmacdonald committed Nov 23, 2023
1 parent 3e30509 commit b871e60
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 95 deletions.
115 changes: 22 additions & 93 deletions docs/source/building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,32 @@
Building PYJNIus
================

Building PyJNIus depends on `Cython <http://cython.org/>`_ and the `Java
Building PyJNIus is necessary for development purposes, or if there is no
pre-built binary for your particular platform.

Like installation of PyJNIus, building PyJNIus requires a `Java
<https://www.oracle.com/java/technologies/downloads/>`_ Development Kit
(includes the Java Runtime Environment).
to be installed.

Apart from the JDK, the building requirements for each platform are as follows:

- Linux: the GNU Compiler Collection (GCC).
- Windows Microsoft Visual C++ Build Tools (command-line tools subset of Visual
Studio) can be obtained from https://visualstudio.microsoft.com/downloads/.
For more information or options, see Python's `Windows Compilers wiki
<https://wiki.python.org/moin/WindowsCompilers>`_.
- macOS: `Xcode command-line tools <https://mac.install.guide/commandlinetools/index.html>`_.

Building on GNU/Linux distributions
-----------------------------------
In all cases, PyJNIus can be *built* and installed using::

You need the GNU Compiler Collection (GCC), the JDK installed (openjdk
will do), and Cython. Then, just type::
pip install .

pip install .
This installs Cython (as specified in the
`pyproject.toml <https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/>`_)
in a Python build environment. On all platforms, if PyJNIus cannot find your JDK, you can set
the `JAVA_HOME` shell environment variable (this is often needed on Windows).

If you want to compile the extension within the directory for any development,
If you want to compile the PyJNIus extension within the directory for any development,
just type::

make
Expand All @@ -25,88 +37,5 @@ You can run the tests suite to make sure everything is running right::

make tests


Building on Windows
-------------------

Python and pip must be installed and present in the ``PATH`` environment variable.

1. Download and install the JDK containing the JRE:

https://www.oracle.com/java/technologies/downloads/

2. Edit your system and environment variables (use the appropriate Java bitness
and version in the paths):

Add to your `Environment Variables
<https://en.wikipedia.org/wiki/Environment_variable>`_:

* ``JAVA_HOME``: C:\\Program Files\\Java\\jdk1.x.y_zz\\bin
* ``PATH``: C:\\Program Files\\Java\\jdk1.x.y_zz\\jre\\bin\\server
contains the ``jvm.dll`` necessary for importing and using PyJNIus.

.. note::
set PATH=%PATH%;C:\\Program Files\\Java\\jdk1.x.y_zz\\jre\\bin\\server

Add to System Variables or have it present in your ``PATH``:
* ``PATH``: C:\\Program Files\\Java\\jdk1.x.y_zz\\bin`

3. Download and install the C compiler:

Microsoft Visual C++ Build Tools (command-line tools subset of Visual
Studio) can be obtained from https://visualstudio.microsoft.com/downloads/

For more information or options, see Python's `Windows Compilers wiki
<https://wiki.python.org/moin/WindowsCompilers>`_.

4. Update `pip <https://pip.pypa.io/en/stable/installing>`_ and setuptools::

python -m pip install --upgrade pip setuptools

5. Install Cython::

python -m pip install --upgrade cython

6. Install Pyjnius::

pip install pyjnius

.. note::
In case of MinGWPy's GCC returning a ``CreateProcess failed: 5`` error
you need to run the command prompt with elevated permissions, so that
the compiler can access the JDK in ``C:\Program Files\Java\jdkx.y.z_b``
or ``C:\Program Files (x86)\Java\jdkx.y.z_b``.


Building for macOS
------------------

Python and pip must be installed and present in the ``PATH`` environment variable.


1. Download and install the JDK containing the JRE:

https://www.oracle.com/java/technologies/downloads/

2. Edit your system and environment variables (use the appropriate Java bitness
and version in the paths):

Add to your `Environment Variables
<https://en.wikipedia.org/wiki/Environment_variable>`_:

* ``export JAVA_HOME=/usr/libexec/java_home``

3. Install Xcode command-line tools.

4. Update `pip <https://pip.pypa.io/en/stable/installing>`_ and setuptools::

python -m pip install --upgrade pip setuptools

5. Install Cython::

python -m pip install --upgrade cython

6. Install Pyjnius::

pip install pyjnius

In these cases, you may need to have `Cython <https://pypi.org/project/Cython/>`_
and `pytest <https://pypi.org/project/pytest/>`_ installed in the current Python environment.
5 changes: 3 additions & 2 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ If there is no pre-compiled binary available, pip install will aim to compile
a binary on your operating system. For more information see the :ref:`building`
documentation.

You will need the Java JDK installed (`OpenJDK <https://openjdk.org/>`__` is fine).
You will need the Java JDK installed (`OpenJDK <https://openjdk.org/>`_ is fine).
PyJNIus searches for Java in the usual places on each operating system. If PyJNIus
cannot find Java, set the `JAVA_HOME` environment variable.
cannot find Java, set the `JAVA_HOME` environment variable (this is often needed
`on Windows <https://www.baeldung.com/java-home-on-windows-7-8-10-mac-os-x-linux#windows>`_).

Installation for Android
------------------------
Expand Down

0 comments on commit b871e60

Please sign in to comment.