1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-23 18:51:51 +00:00

[workflows/ci.yml] Fix test support for Py 2.6

This commit is contained in:
dirkf 2023-06-30 03:52:39 +01:00
parent 2500300c2a
commit b08a580906
3 changed files with 83 additions and 56 deletions

View file

@ -6,9 +6,8 @@ env:
all-cpython-versions: 2.6, 2.7, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9 all-cpython-versions: 2.6, 2.7, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9
main-cpython-versions: 2.7, 3.2, 3.5, 3.9 main-cpython-versions: 2.7, 3.2, 3.5, 3.9
pypy-versions: pypy-2.7, pypy-3.6, pypy-3.7 pypy-versions: pypy-2.7, pypy-3.6, pypy-3.7
cpython-versions: all cpython-versions: main
# test-set: both test-set: both
test-set: core
on: on:
push: push:
@ -75,6 +74,10 @@ jobs:
contents: read contents: read
packages: write packages: write
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env:
PIP: python -m pip
PIP_DISABLE_PIP_VERSION_CHECK: true
PIP_NO_PYTHON_VERSION_WARNING: true
strategy: strategy:
fail-fast: true fail-fast: true
matrix: matrix:
@ -152,12 +155,14 @@ jobs:
- name: Set up Python 2.7 - name: Set up Python 2.7
if: ${{ matrix.python-version == '2.7' }} if: ${{ matrix.python-version == '2.7' }}
# install 2.7 # install 2.7
shell: bash
run: | run: |
sudo apt-get install -y python2 python-is-python2 sudo apt-get install -y python2 python-is-python2
echo "PYTHONHOME=/usr" >> "$GITHUB_ENV" echo "PYTHONHOME=/usr" >> "$GITHUB_ENV"
#-------- Python 2.6 -- #-------- Python 2.6 --
- name: Set up Python 2.6 environment - name: Set up Python 2.6 environment
if: ${{ matrix.python-version == '2.6' }} if: ${{ matrix.python-version == '2.6' }}
shell: bash
run: | run: |
openssl_name=openssl-1.0.2u openssl_name=openssl-1.0.2u
echo "openssl_name=${openssl_name}" >> "$GITHUB_ENV" echo "openssl_name=${openssl_name}" >> "$GITHUB_ENV"
@ -178,6 +183,7 @@ jobs:
- name: Build and set up Python 2.6 - name: Build and set up Python 2.6
if: ${{ matrix.python-version == '2.6' && ! steps.cache26.outputs.cache-hit }} if: ${{ matrix.python-version == '2.6' && ! steps.cache26.outputs.cache-hit }}
# dl and build locally # dl and build locally
shell: bash
run: | run: |
# Install build environment # Install build environment
sudo apt-get install -y build-essential llvm libssl-dev tk-dev \ sudo apt-get install -y build-essential llvm libssl-dev tk-dev \
@ -203,8 +209,7 @@ jobs:
# Download PyEnv from its GitHub repository. # Download PyEnv from its GitHub repository.
export PYENV_ROOT=${{ env.PYENV_ROOT }} export PYENV_ROOT=${{ env.PYENV_ROOT }}
export PATH=$PYENV_ROOT/bin:$PATH export PATH=$PYENV_ROOT/bin:$PATH
git clone https://github.com/pyenv/pyenv.git $PYENV_ROOT git clone "https://github.com/pyenv/pyenv.git" "$PYENV_ROOT"
eval "$(pyenv init --path)"
# Prevent pyenv build trying (and failing) to update pip # Prevent pyenv build trying (and failing) to update pip
export GET_PIP=get-pip-2.6.py export GET_PIP=get-pip-2.6.py
@ -216,17 +221,14 @@ jobs:
export LDFLAGS="-L$openssl_lib" export LDFLAGS="-L$openssl_lib"
export LD_LIBRARY_PATH="$openssl_lib" export LD_LIBRARY_PATH="$openssl_lib"
pyenv install 2.6.9 pyenv install 2.6.9
echo "PYTHONHOME=${PYENV_ROOT}" >> "$GITHUB_ENV" - name: Locate Python 2.6
echo "PATH=$PYENV_ROOT/bin:$PATH" >> "$GITHUB_ENV" if: ${{ matrix.python-version == '2.6' }}
- name: Set up cached Python 2.6 shell: bash
if: ${{ steps.cache26.outputs.cache-hit }}
run: | run: |
export PYENV_ROOT PYTHONHOME="${{ env.PYENV_ROOT }}/versions/2.6.9"
export PATH=$PYENV_ROOT/bin:$PATH echo "PYTHONHOME=$PYTHONHOME" >> "$GITHUB_ENV"
eval "$(pyenv init --path)" echo "PATH=${PYTHONHOME}/bin:$PATH" >> "$GITHUB_ENV"
pyenv local 2.6.9 echo "LD_LIBRARY_PATH=${{ env.openssl_dir }}/lib${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}" >> "$GITHUB_ENV"
echo "PYTHONHOME=${PYENV_ROOT}" >> "$GITHUB_ENV"
echo "PATH=$PYENV_ROOT/bin:$PATH" >> "$GITHUB_ENV"
#-------- Jython ------ #-------- Jython ------
- name: Set up Java 8 - name: Set up Java 8
if: ${{ matrix.python-impl == 'jython' }} if: ${{ matrix.python-impl == 'jython' }}
@ -236,8 +238,10 @@ jobs:
distribution: 'zulu' distribution: 'zulu'
- name: Setup Jython environment - name: Setup Jython environment
if: ${{ matrix.python-impl == 'jython' }} if: ${{ matrix.python-impl == 'jython' }}
shell: bash
run: | run: |
echo "JYTHON_ROOT=${HOME}/jython" >> "$GITHUB_ENV" echo "JYTHON_ROOT=${HOME}/jython" >> "$GITHUB_ENV"
echo "PIP=pip" >> "$GITHUB_ENV"
- name: Cache Jython - name: Cache Jython
id: cachejy id: cachejy
if: ${{ matrix.python-impl == 'jython' }} if: ${{ matrix.python-impl == 'jython' }}
@ -249,19 +253,21 @@ jobs:
${{ env.JYTHON_ROOT }} ${{ env.JYTHON_ROOT }}
- name: Install Jython - name: Install Jython
if: ${{ matrix.python-impl == 'jython' && ! steps.cachejy.outputs.cache-hit }} if: ${{ matrix.python-impl == 'jython' && ! steps.cachejy.outputs.cache-hit }}
shell: bash
run: | run: |
JYTHON_ROOT="${{ env.JYTHON_ROOT }}" JYTHON_ROOT="${{ env.JYTHON_ROOT }}"
curl -L "https://repo1.maven.org/maven2/org/python/jython-installer/2.7.1/jython-installer-2.7.1.jar" -o jython-installer.jar curl -L "https://repo1.maven.org/maven2/org/python/jython-installer/2.7.1/jython-installer-2.7.1.jar" -o jython-installer.jar
java -jar jython-installer.jar -s -d "${JYTHON_ROOT}" java -jar jython-installer.jar -s -d "${JYTHON_ROOT}"
echo "${JYTHON_ROOT}/bin" >> $GITHUB_PATH echo "${JYTHON_ROOT}/bin" >> "$GITHUB_PATH"
- name: Set up cached Jython - name: Set up cached Jython
if: ${{ steps.cachejy.outputs.cache-hit }} if: ${{ steps.cachejy.outputs.cache-hit }}
shell: bash
run: | run: |
JYTHON_ROOT="${{ env.JYTHON_ROOT }}" JYTHON_ROOT="${{ env.JYTHON_ROOT }}"
echo "${JYTHON_ROOT}/bin" >> $GITHUB_PATH echo "${JYTHON_ROOT}/bin" >> $GITHUB_PATH
#-------- pip --------- #-------- pip ---------
- name: Set up supported Python ${{ matrix.python-version }} pip - name: Set up supported Python ${{ matrix.python-version }} pip
if: ${{ (matrix.python-version != '3.2' && steps.setup-python.outputs.python-path) || matrix.python-version == '2.6' || matrix.python-version == '2.7' }} if: ${{ (matrix.python-version != '3.2' && steps.setup-python.outputs.python-path) || matrix.python-version == '2.7' }}
# This step may run in either Linux or Windows # This step may run in either Linux or Windows
shell: bash shell: bash
run: | run: |
@ -272,48 +278,66 @@ jobs:
get_pip="${{ contains(needs.select.outputs.own-pip-versions, matrix.python-version) && format('{0}/', matrix.python-version) || '' }}"; \ get_pip="${{ contains(needs.select.outputs.own-pip-versions, matrix.python-version) && format('{0}/', matrix.python-version) || '' }}"; \
curl -L -O "https://bootstrap.pypa.io/pip/${get_pip}get-pip.py"; \ curl -L -O "https://bootstrap.pypa.io/pip/${get_pip}get-pip.py"; \
python get-pip.py; } python get-pip.py; }
- name: Set up Python 2.6 pip
if: ${{ matrix.python-version == '2.6' }}
shell: bash
run: |
python -m pip --version || { \
curl -L -O "https://bootstrap.pypa.io/pip/2.6/get-pip.py"; \
curl -L -O "https://files.pythonhosted.org/packages/ac/95/a05b56bb975efa78d3557efa36acaf9cf5d2fd0ee0062060493687432e03/pip-9.0.3-py2.py3-none-any.whl"; \
python get-pip.py --no-setuptools --no-wheel pip-9.0.3-py2.py3-none-any.whl; }
# work-around to invoke pip module on 2.6: https://bugs.python.org/issue2751
echo "PIP=python -m pip.__main__" >> "$GITHUB_ENV"
- name: Set up other Python ${{ matrix.python-version }} pip - name: Set up other Python ${{ matrix.python-version }} pip
if: ${{ matrix.python-version == '3.2' && steps.setup-python.outputs.python-path }} if: ${{ matrix.python-version == '3.2' && steps.setup-python.outputs.python-path }}
shell: bash shell: bash
run: | run: |
# https://files.pythonhosted.org/packages/8a/e9/8468cd68b582b06ef554be0b96b59f59779627131aad48f8a5bce4b13450/wheel-0.29.0-py2.py3-none-any.whl
# https://files.pythonhosted.org/packages/06/4b/86a670fd21f7849adb092e40883c48dcd0d66b8a878fc8d63b7f0ea04213/setuptools-29.0.1-py2.py3-none-any.whl
python -m pip --version || { \ python -m pip --version || { \
curl -L -O "https://bootstrap.pypa.io/pip/3.2/get-pip.py"; \ curl -L -O "https://bootstrap.pypa.io/pip/3.2/get-pip.py"; \
curl -L -O "https://files.pythonhosted.org/packages/b2/d0/cd115fe345dd6f07ec1c780020a7dfe74966fceeb171e0f20d1d4905b0b7/pip-7.1.2-py2.py3-none-any.whl"; \ curl -L -O "https://files.pythonhosted.org/packages/b2/d0/cd115fe345dd6f07ec1c780020a7dfe74966fceeb171e0f20d1d4905b0b7/pip-7.1.2-py2.py3-none-any.whl"; \
python -v get-pip.py --no-setuptools --no-wheel pip-7.1.2-py2.py3-none-any.whl; } python get-pip.py --no-setuptools --no-wheel pip-7.1.2-py2.py3-none-any.whl; }
#-------- unittest ----
- name: Upgrade Unittest for Python 2.6
if: ${{ matrix.python-version == '2.6' }}
shell: bash
run: |
# see pip for Jython
$PIP -qq show unittest2 || { \
for u in "65/26/32b8464df2a97e6dd1b656ed26b2c194606c16fe163c695a992b36c11cdf/six-1.13.0-py2.py3-none-any.whl" \
"f2/94/3af39d34be01a24a6e65433d19e107099374224905f1e0cc6bbe1fd22a2f/argparse-1.4.0-py2.py3-none-any.whl" \
"c7/a3/c5da2a44c85bfbb6eebcfc1dde24933f8704441b98fdde6528f4831757a6/linecache2-1.0.0-py2.py3-none-any.whl" \
"17/0a/6ac05a3723017a967193456a2efa0aa9ac4b51456891af1e2353bb9de21e/traceback2-1.4.0-py2.py3-none-any.whl" \
"72/20/7f0f433060a962200b7272b8c12ba90ef5b903e218174301d0abfd523813/unittest2-1.1.0-py2.py3-none-any.whl"; do \
curl -L -O "https://files.pythonhosted.org/packages/${u}"; \
$PIP install ${u##*/}; \
done; }
# make tests use unittest2
for test in ./test/test_*.py; do
sed -r -i -e '/^import unittest$/s/test/test2 as unittest/' "$test"
done
#-------- nose -------- #-------- nose --------
- name: Install nose for Python ${{ matrix.python-version }} - name: Install nose for Python ${{ matrix.python-version }}
if: ${{ (matrix.python-version != '3.2' && steps.setup-python.outputs.python-path) || matrix.python-version == '2.6' || matrix.python-version == '2.7' }} if: ${{ (matrix.python-version != '3.2' && steps.setup-python.outputs.python-path) || matrix.python-version == '2.7' }}
shell: bash shell: bash
run: | run: |
echo "$PATH" echo "$PATH"
echo "$PYTHONHOME" echo "$PYTHONHOME"
python --version $PIP -qq show nose || $PIP install nose
python -m pip --version - name: Install nose for other Python 2
python -m pip nose --version || python -m pip install nose if: ${{ matrix.python-impl == 'jython' || matrix.python-version == '2.6' }}
- name: Install nose for other Python ${{ matrix.python-version }} shell: bash
run: |
# Work around deprecation of support for non-SNI clients at PyPI CDN (see https://status.python.org/incidents/hzmjhqsdjqgb)
$PIP -qq show nose || { \
curl -L -O "https://files.pythonhosted.org/packages/99/4f/13fb671119e65c4dce97c60e67d3fd9e6f7f809f2b307e2611f4701205cb/nose-1.3.7-py2-none-any.whl"; \
$PIP install nose-1.3.7-py2-none-any.whl; }
- name: Install nose for other Python 3
if: ${{ matrix.python-version == '3.2' && steps.setup-python.outputs.python-path }} if: ${{ matrix.python-version == '3.2' && steps.setup-python.outputs.python-path }}
shell: bash shell: bash
run: | run: |
python -m pip nose --version || { \ $PIP -qq show nose || { \
curl -L -O "https://files.pythonhosted.org/packages/15/d8/dd071918c040f50fa1cf80da16423af51ff8ce4a0f2399b7bf8de45ac3d9/nose-1.3.7-py3-none-any.whl"; \ curl -L -O "https://files.pythonhosted.org/packages/15/d8/dd071918c040f50fa1cf80da16423af51ff8ce4a0f2399b7bf8de45ac3d9/nose-1.3.7-py3-none-any.whl"; \
python --version; \ $PIP install nose-1.3.7-py3-none-any.whl; }
printf '%s\n' \
'import sys' \
'print(sys.path)' \
| python -; \
python -m pip --version; \
python -m pip install nose-1.3.7-py3-none-any.whl; }
- name: Install nose (Jython)
if: ${{ matrix.python-impl == 'jython' }}
# Work around deprecation of support for non-SNI clients at PyPI CDN (see https://status.python.org/incidents/hzmjhqsdjqgb)
run: |
pip nose --version || { \
curl -L -O "https://files.pythonhosted.org/packages/99/4f/13fb671119e65c4dce97c60e67d3fd9e6f7f809f2b307e2611f4701205cb/nose-1.3.7-py2-none-any.whl"; \
pip --version; \
pip install nose-1.3.7-py2-none-any.whl; }
- name: Set up nosetest test - name: Set up nosetest test
if: ${{ contains(needs.select.outputs.test-set, matrix.ytdl-test-set ) }} if: ${{ contains(needs.select.outputs.test-set, matrix.ytdl-test-set ) }}
shell: bash shell: bash
@ -321,7 +345,11 @@ jobs:
# define a test to validate the Python version used by nosetests # define a test to validate the Python version used by nosetests
printf '%s\n' \ printf '%s\n' \
'from __future__ import unicode_literals' \ 'from __future__ import unicode_literals' \
'import sys, os, platform, unittest' \ 'import sys, os, platform' \
'try:' \
' import unittest2 as unittest' \
'except ImportError:' \
' import unittest' \
'class TestPython(unittest.TestCase):' \ 'class TestPython(unittest.TestCase):' \
' def setUp(self):' \ ' def setUp(self):' \
' self.ver = os.environ["PYTHON_VER"].split("-")' \ ' self.ver = os.environ["PYTHON_VER"].split("-")' \
@ -340,7 +368,6 @@ jobs:
YTDL_TEST_SET: ${{ matrix.ytdl-test-set }} YTDL_TEST_SET: ${{ matrix.ytdl-test-set }}
PYTHON_VER: ${{ matrix.python-version }} PYTHON_VER: ${{ matrix.python-version }}
PYTHON_IMPL: ${{ matrix.python-impl }} PYTHON_IMPL: ${{ matrix.python-impl }}
run: | run: |
./devscripts/run_tests.${{ matrix.run-tests-ext }} ./devscripts/run_tests.${{ matrix.run-tests-ext }}

View file

@ -6,10 +6,6 @@ import os
from os.path import dirname as dirn from os.path import dirname as dirn
import sys import sys
from youtube_dl.compat import compat_register_utf8
compat_register_utf8()
print('WARNING: Lazy loading extractors is an experimental feature that may not always work', file=sys.stderr) print('WARNING: Lazy loading extractors is an experimental feature that may not always work', file=sys.stderr)
sys.path.insert(0, dirn(dirn((os.path.abspath(__file__))))) sys.path.insert(0, dirn(dirn((os.path.abspath(__file__)))))
@ -23,6 +19,10 @@ try:
except OSError: except OSError:
pass pass
from youtube_dl.compat import compat_register_utf8
compat_register_utf8()
from youtube_dl.extractor import _ALL_CLASSES from youtube_dl.extractor import _ALL_CLASSES
from youtube_dl.extractor.common import InfoExtractor, SearchInfoExtractor from youtube_dl.extractor.common import InfoExtractor, SearchInfoExtractor

View file

@ -11,13 +11,12 @@ import subprocess
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from youtube_dl.compat import compat_register_utf8 from youtube_dl.compat import compat_register_utf8
from youtube_dl.utils import encodeArgument from youtube_dl.utils import encodeArgument
rootDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
compat_register_utf8() compat_register_utf8()
rootDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
try: try:
_DEV_NULL = subprocess.DEVNULL _DEV_NULL = subprocess.DEVNULL
except AttributeError: except AttributeError:
@ -33,21 +32,22 @@ class TestExecution(unittest.TestCase):
subprocess.check_call([sys.executable, '-m', 'youtube_dl', '--version'], cwd=rootDir, stdout=_DEV_NULL) subprocess.check_call([sys.executable, '-m', 'youtube_dl', '--version'], cwd=rootDir, stdout=_DEV_NULL)
def test_main_exec(self): def test_main_exec(self):
subprocess.check_call([sys.executable, 'youtube_dl/__main__.py', '--version'], cwd=rootDir, stdout=_DEV_NULL) subprocess.check_call([sys.executable, os.path.normpath('youtube_dl/__main__.py'), '--version'], cwd=rootDir, stdout=_DEV_NULL)
@unittest.skipIf(sys.version_info < (2, 7), 'Python 2.6 doesn\'t support package execution') @unittest.skipIf(sys.version_info < (2, 7), 'Python 2.6 doesn\'t support package execution')
def test_cmdline_umlauts(self): def test_cmdline_umlauts(self):
os.environ['PYTHONIOENCODING'] = 'utf-8'
p = subprocess.Popen( p = subprocess.Popen(
[sys.executable, 'youtube_dl/__main__.py', encodeArgument('ä'), '--version'], [sys.executable, os.path.normpath('youtube_dl/__main__.py'), encodeArgument('ä'), '--version'],
cwd=rootDir, stdout=_DEV_NULL, stderr=subprocess.PIPE) cwd=rootDir, stdout=_DEV_NULL, stderr=subprocess.PIPE)
_, stderr = p.communicate() _, stderr = p.communicate()
self.assertFalse(stderr) self.assertFalse(stderr)
def test_lazy_extractors(self): def test_lazy_extractors(self):
lazy_extractors = 'youtube_dl/extractor/lazy_extractors.py' lazy_extractors = os.path.normpath('youtube_dl/extractor/lazy_extractors.py')
try: try:
subprocess.check_call([sys.executable, 'devscripts/make_lazy_extractors.py', lazy_extractors], cwd=rootDir, stdout=_DEV_NULL) subprocess.check_call([sys.executable, os.path.normpath('devscripts/make_lazy_extractors.py'), lazy_extractors], cwd=rootDir, stdout=_DEV_NULL)
subprocess.check_call([sys.executable, 'test/test_all_urls.py'], cwd=rootDir, stdout=_DEV_NULL) subprocess.check_call([sys.executable, os.path.normpath('test/test_all_urls.py')], cwd=rootDir, stdout=_DEV_NULL)
finally: finally:
for x in ['', 'c'] if sys.version_info[0] < 3 else ['']: for x in ['', 'c'] if sys.version_info[0] < 3 else ['']:
try: try: