Merge branch 'jython-compat' into 'master'

Jython compatibility

See merge request laudom/librefi!6
master
Lauren Liberda 2020-11-29 19:00:01 +00:00
commit 2635869f1d
6 changed files with 54 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.jython_cache/
# Created by https://www.toptal.com/developers/gitignore/api/python,linux,windows,macos,jetbrains,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=python,linux,windows,macos,jetbrains,visualstudiocode

View File

@ -15,6 +15,20 @@ py3.8-unit_tests:
- nosetests tests/*.py
- python setup.py sdist bdist_wheel
jy2.7-unit_tests:
image: openjdk:11-slim
before_script:
- apt-get -y update
- apt-get -y install wget
- ./devel_scripts/install_jython.sh
- export PATH="$HOME/jython/bin:$PATH"
- jython -m pip install -r requirements.txt
- jython -m pip install -r requirements_dev.txt
script:
- jython -m nose tests/*.py
# wheel building doesn't work on jython
- jython setup.py sdist
py2.7-integration_test:
image: python:2.7-buster
before_script:
@ -41,3 +55,14 @@ py3.9-integration_test:
- apt-get -y install network-manager
script:
- python3 -m librefi
jy2.7-integration_tests:
image: openjdk:11-slim
before_script:
- apt-get -y update
- apt-get -y install wget network-manager
- ./devel_scripts/install_jython.sh
- export PATH="$HOME/jython/bin:$PATH"
- jython -m pip install -r requirements.txt
script:
- jython -m librefi

10
devel_scripts/install_jython.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
# https://git.sakamoto.pl/laudom/haruhi-dl/-/blob/master/devscripts/install_jython.sh
wget https://repo1.maven.org/maven2/org/python/jython-installer/2.7.2/jython-installer-2.7.2.jar
if [ "$(sha512sum jython-installer-2.7.2.jar | awk '{print $1}')" != "d3ae09ebcb1ad27123d1b325729a18aa9e793039ca3428167455ce51217f10735949d2acea39f89e5414015c97bdd319657aced3753b764dddb09200e8cff40e" ]; then
echo "invalid sha512 checksum for jython installer"
exit 2137
fi
java -jar jython-installer-2.7.2.jar -s -d "$HOME/jython"

View File

@ -2652,7 +2652,13 @@ except ImportError: # Python 2
compat_os_name = os._name if os.name == 'java' else os.name
compat_sys_platform = sys.platform
# jython returns something like PyShadowString('java1.8.0_272', 'linux2')
# https://www.javadoc.io/static/org.python/jython-standalone/2.7.1/org/python/core/PyShadowString.html
# we are only interested in the shadow string here
try:
compat_sys_platform = sys.platform.getshadow()
except AttributeError:
compat_sys_platform = sys.platform
# a little breaking changes on python 3.3 and 3.8
# https://docs.python.org/3/library/sys.html#sys.platform
if compat_sys_platform.startswith('linux'):

View File

@ -1 +1,2 @@
nose
wheel

View File

@ -4,6 +4,11 @@ from __future__ import unicode_literals
from os import listdir, path
import re
from librefi.compat import (
compat_sys_platform,
compat_str,
)
def test_fxcker_files_py2_compatibility():
dir = path.join('.', 'librefi', 'fxckers')
@ -17,3 +22,8 @@ def test_fxcker_files_py2_compatibility():
print(content)
print(fxcker)
raise AssertionError('fxcker %s not containing required compat imports' % (fxcker))
def test_compat_sys_platform():
assert isinstance(compat_sys_platform, compat_str)
assert 'java' not in compat_sys_platform