diff --git a/.gitignore b/.gitignore index b2db1c3..bee93c0 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index efd7f15..c57cffb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/devel_scripts/install_jython.sh b/devel_scripts/install_jython.sh new file mode 100755 index 0000000..2c86cf7 --- /dev/null +++ b/devel_scripts/install_jython.sh @@ -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" diff --git a/librefi/compat.py b/librefi/compat.py index 15f9930..6a4fd38 100644 --- a/librefi/compat.py +++ b/librefi/compat.py @@ -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'): diff --git a/requirements_dev.txt b/requirements_dev.txt index f3c7e8e..451cb85 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1 +1,2 @@ nose +wheel diff --git a/tests/py2_compat.py b/tests/compat.py similarity index 78% rename from tests/py2_compat.py rename to tests/compat.py index dd8f18a..e13b6e9 100644 --- a/tests/py2_compat.py +++ b/tests/compat.py @@ -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