From 8ae32539fe13f05b30233c36b93934f964275d24 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Fri, 1 May 2020 16:43:20 +0200 Subject: [PATCH] Switch to setuptools and use pytest --- .github/workflows/python.yml | 5 +++-- .gitignore | 1 + MANIFEST.in | 2 +- run_tests | 14 -------------- setup.cfg | 2 ++ setup.py | 33 ++++++++++++--------------------- 6 files changed, 19 insertions(+), 38 deletions(-) delete mode 100755 run_tests create mode 100644 setup.cfg diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index e97a0338..3758b961 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -33,9 +33,10 @@ jobs: run: | python -m pip install --upgrade pip pip install -e . + python setup.py develop - name: Compile all scripts run: python -m compileall -f terminatorlib/ tests/ remotinator terminator - - name: Run legacy tests - run: bash run_tests + - name: Run tests + run: python setup.py test diff --git a/.gitignore b/.gitignore index 7f74dcdf..d7a0e263 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ /.bzr ## Python +/.eggs *.pyc *.egg-info /build diff --git a/MANIFEST.in b/MANIFEST.in index 65fbcd51..f2d8d548 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ -include AUTHORS CHANGELOG* COPYING INSTALL README* remotinator setup.py terminator run_tests +include AUTHORS CHANGELOG* COPYING INSTALL README* remotinator setup.py terminator recursive-include data * recursive-include doc * recursive-include po * diff --git a/run_tests b/run_tests deleted file mode 100755 index cc7fb56a..00000000 --- a/run_tests +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -for t in tests/test*; do - echo $t - file_type=$(file -b $t) - case ${file_type} in - *[Pp]ython*) python ${t} || exit 1 ;; - *Bourne*) bash ${t} || exit 1 ;; - *bash*) bash ${t} || exit 1 ;; - *perl*) perl ${t} || exit 1 ;; - *) echo "Unknown" ;; - esac - echo -done diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..b7e47898 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[aliases] +test=pytest diff --git a/setup.py b/setup.py index 38a819a9..90a48fac 100755 --- a/setup.py +++ b/setup.py @@ -1,13 +1,13 @@ #!/usr/bin/env python -from distutils.core import setup -from distutils.dist import Distribution -from distutils.cmd import Command +from setuptools import setup, Distribution, Command + from distutils.command.install_data import install_data from distutils.command.build import build from distutils.dep_util import newer from distutils.log import warn, info, error from distutils.errors import DistutilsFileError + import glob import os import sys @@ -20,6 +20,7 @@ PO_DIR = 'po' MO_DIR = os.path.join('build', 'mo') CSS_DIR = os.path.join('terminatorlib', 'themes') + class TerminatorDist(Distribution): global_options = Distribution.global_options + [ ("build-documentation", None, "Build the documentation"), @@ -177,21 +178,6 @@ class InstallData(install_data): return data_files -class Test(Command): - user_options = [] - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - import subprocess - import sys - errno = subprocess.call(['bash', 'run_tests']) - raise SystemExit(errno) - - if platform.system() in ['FreeBSD', 'OpenBSD']: man_dir = 'man' else: @@ -232,6 +218,9 @@ setup(name=APP_NAME, 'terminatorlib', 'terminatorlib.plugins', ], + setup_requires=[ + 'pytest-runner', + ], install_requires=[ 'pycairo', 'configobj', @@ -239,8 +228,10 @@ setup(name=APP_NAME, 'pygobject', 'psutil', ], + tests_require=[ + 'pytest', + ], package_data={'terminatorlib': ['preferences.glade', 'layoutlauncher.glade']}, - cmdclass={'build': BuildData, 'install_data': InstallData, 'uninstall': Uninstall, 'test':Test}, - distclass=TerminatorDist - ) + cmdclass={'build': BuildData, 'install_data': InstallData, 'uninstall': Uninstall}, + distclass=TerminatorDist)