Kaydet (Commit) 23b21db3 authored tarafından Claude Paroz's avatar Claude Paroz

Fixed #28594 -- Removed Jython docs and specific code

Thanks Andrey Martyanov for the reporti, and Tim Graham for the review.
üst 32ade4d7
...@@ -5,7 +5,6 @@ import posixpath ...@@ -5,7 +5,6 @@ import posixpath
import re import re
import shutil import shutil
import stat import stat
import sys
import tempfile import tempfile
from importlib import import_module from importlib import import_module
from os import path from os import path
...@@ -336,9 +335,6 @@ class TemplateCommand(BaseCommand): ...@@ -336,9 +335,6 @@ class TemplateCommand(BaseCommand):
Make sure that the file is writeable. Make sure that the file is writeable.
Useful if our source is read-only. Useful if our source is read-only.
""" """
if sys.platform.startswith('java'):
# On Jython there is no os.access()
return
if not os.access(filename, os.W_OK): if not os.access(filename, os.W_OK):
st = os.stat(filename) st = os.stat(filename)
new_permissions = stat.S_IMODE(st.st_mode) | stat.S_IWUSR new_permissions = stat.S_IMODE(st.st_mode) | stat.S_IWUSR
......
...@@ -314,24 +314,11 @@ def python_reloader(main_func, args, kwargs): ...@@ -314,24 +314,11 @@ def python_reloader(main_func, args, kwargs):
pass pass
def jython_reloader(main_func, args, kwargs):
from _systemrestart import SystemRestart
_thread.start_new_thread(main_func, args)
while True:
if code_changed():
raise SystemRestart
time.sleep(1)
def main(main_func, args=None, kwargs=None): def main(main_func, args=None, kwargs=None):
if args is None: if args is None:
args = () args = ()
if kwargs is None: if kwargs is None:
kwargs = {} kwargs = {}
if sys.platform.startswith('java'):
reloader = jython_reloader
else:
reloader = python_reloader
wrapped_main_func = check_errors(main_func) wrapped_main_func = check_errors(main_func)
reloader(wrapped_main_func, args, kwargs) python_reloader(wrapped_main_func, args, kwargs)
======================== ================
Running Django on Jython Django on Jython
======================== ================
.. index:: Jython, Java, JVM .. index:: Jython, Java, JVM
Jython_ is an implementation of Python that runs on the Java platform (JVM). Jython_ is an implementation of Python that runs on the Java platform (JVM).
This document will get you up and running with Django on top of Jython.
Installing Jython
=================
Django works with Jython versions 2.7b2 and higher. See the Jython_ website for
download and installation instructions.
.. _jython: http://www.jython.org/ .. _jython: http://www.jython.org/
Creating a servlet container If you want to use Jython (which supports only Python 2.7 at the time of this
============================ writing), you must use Django 1.11.x (the last series to support Python 2).
Jython support may be readded to Django if a Python 3 compatible Jython is
If you just want to experiment with Django, skip ahead to the next section; released.
Django includes a lightweight Web server you can use for testing, so you won't
need to set up anything else until you're ready to deploy Django in production.
If you want to use Django on a production site, use a Java servlet container,
such as `Apache Tomcat`_. Full JavaEE applications servers such as `GlassFish`_
or `JBoss`_ are also OK, if you need the extra features they include.
.. _`Apache Tomcat`: https://tomcat.apache.org/
.. _GlassFish: https://javaee.github.io/glassfish/
.. _JBoss: https://www.jboss.org/
Installing Django
=================
The next step is to install Django itself. This is exactly the same as
installing Django on standard Python, so see
:ref:`removing-old-versions-of-django` and :ref:`install-django-code` for
instructions.
Installing Jython platform support libraries
============================================
The `django-jython`_ project contains database backends and management commands
for Django/Jython development. Note that the builtin Django backends won't work
on top of Jython.
.. _`django-jython`: https://github.com/beachmachine/django-jython
To install it, follow the `installation instructions`_ detailed on the project
website. Also, read the `database backends`_ documentation there.
.. _`installation instructions`: https://pythonhosted.org/django-jython/quickstart.html#install
.. _`database backends`: https://pythonhosted.org/django-jython/database-backends.html
Differences with Django on Jython
=================================
.. index:: JYTHONPATH
At this point, Django on Jython should behave nearly identically to Django
running on standard Python. However, are a few differences to keep in mind:
* Remember to use the ``jython`` command instead of ``python``. The
documentation uses ``python`` for consistency, but if you're using Jython
you'll want to mentally replace ``python`` with ``jython`` every time it
occurs.
* Similarly, you'll need to use the ``JYTHONPATH`` environment variable
instead of ``PYTHONPATH``.
* Any part of Django that requires `Pillow`_ will not work.
.. _Pillow: https://pillow.readthedocs.io/en/latest/
...@@ -275,14 +275,6 @@ more efficiently - faster, and using fewer system resources. ...@@ -275,14 +275,6 @@ more efficiently - faster, and using fewer system resources.
* :doc:`Performance and optimization overview <topics/performance>` * :doc:`Performance and optimization overview <topics/performance>`
Python compatibility
====================
Django aims to be compatible with multiple different flavors and versions of
Python:
* :doc:`Jython support <howto/jython>`
Geographic framework Geographic framework
==================== ====================
......
...@@ -19,13 +19,6 @@ database called SQLite_ so you won't need to set up a database just yet. ...@@ -19,13 +19,6 @@ database called SQLite_ so you won't need to set up a database just yet.
Get the latest version of Python at https://www.python.org/downloads/ or with Get the latest version of Python at https://www.python.org/downloads/ or with
your operating system's package manager. your operating system's package manager.
.. admonition:: Django on Jython
If you use Jython_ (a Python implementation for the Java platform), you'll
need to follow a few additional steps. See :doc:`/howto/jython` for details.
.. _jython: http://www.jython.org/
You can verify that Python is installed by typing ``python`` from your shell; You can verify that Python is installed by typing ``python`` from your shell;
you should see something like:: you should see something like::
......
...@@ -154,8 +154,6 @@ Django's codebase has been refactored to remove incompatibilities with ...@@ -154,8 +154,6 @@ Django's codebase has been refactored to remove incompatibilities with
on the Java Virtual Machine. Django is now compatible with the forthcoming on the Java Virtual Machine. Django is now compatible with the forthcoming
Jython 2.5 release. Jython 2.5 release.
See :doc:`/howto/jython`.
.. _Jython: http://www.jython.org/ .. _Jython: http://www.jython.org/
Generic relations in forms and admin Generic relations in forms and admin
......
...@@ -15,10 +15,10 @@ your operating system's package manager. ...@@ -15,10 +15,10 @@ your operating system's package manager.
.. admonition:: Django on Jython .. admonition:: Django on Jython
If you use Jython_ (a Python implementation for the Java platform), you'll Jython_ (a Python implementation for the Java platform) is not compatible
need to follow a few additional steps. See :doc:`/howto/jython` for details. with Python 3, so Django ≥ 2.0 cannot run on Jython.
.. _jython: http://jython.org/ .. _jython: http://www.jython.org/
.. admonition:: Python on Windows .. admonition:: Python on Windows
......
...@@ -100,15 +100,8 @@ class AdminScriptTestCase(unittest.TestCase): ...@@ -100,15 +100,8 @@ class AdminScriptTestCase(unittest.TestCase):
else: else:
os.remove(full_name) os.remove(full_name)
# Also try to remove the compiled file; if it exists, it could # Also remove a __pycache__ directory, if it exists; it could
# mess up later tests that depend upon the .py file not existing # mess up later tests that depend upon the .py file not existing
try:
if sys.platform.startswith('java'):
# Jython produces module$py.class files
os.remove(re.sub(r'\.py$', '$py.class', full_name))
except OSError:
pass
# Also remove a __pycache__ directory, if it exists
cache_name = os.path.join(self.test_dir, '__pycache__') cache_name = os.path.join(self.test_dir, '__pycache__')
if os.path.isdir(cache_name): if os.path.isdir(cache_name):
shutil.rmtree(cache_name) shutil.rmtree(cache_name)
...@@ -138,11 +131,6 @@ class AdminScriptTestCase(unittest.TestCase): ...@@ -138,11 +131,6 @@ class AdminScriptTestCase(unittest.TestCase):
# Define a temporary environment for the subprocess # Define a temporary environment for the subprocess
test_environ = os.environ.copy() test_environ = os.environ.copy()
if sys.platform.startswith('java'):
python_path_var_name = 'JYTHONPATH'
else:
python_path_var_name = 'PYTHONPATH'
old_cwd = os.getcwd() old_cwd = os.getcwd()
# Set the test environment # Set the test environment
...@@ -152,7 +140,7 @@ class AdminScriptTestCase(unittest.TestCase): ...@@ -152,7 +140,7 @@ class AdminScriptTestCase(unittest.TestCase):
del test_environ['DJANGO_SETTINGS_MODULE'] del test_environ['DJANGO_SETTINGS_MODULE']
python_path = [base_dir, django_dir, tests_dir] python_path = [base_dir, django_dir, tests_dir]
python_path.extend(ext_backend_base_dirs) python_path.extend(ext_backend_base_dirs)
test_environ[python_path_var_name] = os.pathsep.join(python_path) test_environ['PYTHONPATH'] = os.pathsep.join(python_path)
test_environ['PYTHONWARNINGS'] = '' test_environ['PYTHONWARNINGS'] = ''
# Move to the test directory and run # Move to the test directory and run
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment