mirror of
https://github.com/erkin/ponysay.git
synced 2024-12-01 08:17:59 +01:00
dependency test in python that runs both on py2 and py3
Signed-off-by: Mattias Andrée <maandree@operamail.com>
This commit is contained in:
parent
38a1b564f6
commit
e2aaeba4ac
2 changed files with 67 additions and 46 deletions
|
@ -1,46 +0,0 @@
|
||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
# Compatible with bash dash zsh mksh ksh ksh93
|
|
||||||
# but not with fish
|
|
||||||
# problematic with tcsh csh
|
|
||||||
|
|
||||||
|
|
||||||
br=0 # build required
|
|
||||||
bs=0 # build recommended
|
|
||||||
bo=0 # build optional
|
|
||||||
rr=0 # runtime required
|
|
||||||
ro=0 # runtime optional
|
|
||||||
pv=0 # python version
|
|
||||||
|
|
||||||
|
|
||||||
(hash chmod 2>/dev/null) || (br=1 ; ro=1 ; echo 'Missing chmod, install coreutils [build required + runtime optional]')
|
|
||||||
|
|
||||||
(hash gzip 2>/dev/null) || (bo=1 ; echo 'Missing gzip, install gzip [build optional]')
|
|
||||||
(hash makeinfo 2>/dev/null) || (bo=1 ; echo 'Missing makeinfo, install texinfo [build optional]')
|
|
||||||
(hash install-info 2>/dev/null) || (bo=1 ; echo 'Missing install-info, install info [build optional]')
|
|
||||||
|
|
||||||
(hash auto-auto-complete 2>/dev/null) || (bo=1 ; echo 'Missing auto-auto-complete, install auto-auto-complete>=3 [build optional]')
|
|
||||||
|
|
||||||
(hash python 2>/dev/null) || (br=1 ; rr=1 ; echo 'Missing python, install python>=3 [build+runtime required]')
|
|
||||||
|
|
||||||
(hash cut 2>/dev/null) && (hash python 2>/dev/null) &&
|
|
||||||
(test ! $(env python --version 2>&1 | cut -d ' ' -f 2 | cut -d '.' -f 1) = 3) && (
|
|
||||||
(hash python3 2>/dev/null) ||
|
|
||||||
(br=1 ; rr=1 ; pv=1 ; echo 'Missing python>=3, install python (may be named python3) [build+runtime required]'))
|
|
||||||
|
|
||||||
(hash stty 2>/dev/null) || (rr=1 ; echo 'Missing stty, install coreutils [runtime required]')
|
|
||||||
|
|
||||||
(hash ponytool 2>/dev/null) || (ro=1 ; echo 'Missing ponytool, install util-say [runtime optional]')
|
|
||||||
(hash chmod 2>/dev/null) || (rr=1 ; echo 'Missing chmod, install coreutils [runtime optional]')
|
|
||||||
|
|
||||||
( (test $br = 1) || (test $rr = 1) || (test $ro = 1) || (test $pv = 1) ) && echo
|
|
||||||
|
|
||||||
(test $br = 1) && echo 'You will not be able to build and install ponysay.'
|
|
||||||
(test $rr = 1) && echo 'You will not be able to run ponysay.'
|
|
||||||
(test $pv = 1) && echo 'Unable to verify version of python.'
|
|
||||||
|
|
||||||
(test $br = 0) && (test $bs = 0) && (test $bo = 0) && (test $rr = 0) && (test $ro = 0) &&
|
|
||||||
echo && echo 'Everything appears to be in order, enjoy ponysay!'
|
|
||||||
|
|
||||||
echo
|
|
||||||
|
|
67
setup/dependencies.py
Executable file
67
setup/dependencies.py
Executable file
|
@ -0,0 +1,67 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('chmod', 'coreutils', None, 2, 1),
|
||||||
|
('gzip', 'gzip', 'compression of manuals', 1, 0),
|
||||||
|
('makeinfo', 'texinfo', 'compilation of info manual', 1, 0),
|
||||||
|
('install-info', 'texinfo', 'installation of info manual', 1, 0),
|
||||||
|
('auto-auto-complete', 'auto-auto-complete>=3', 'compilation of shell tab-completion', 1, 0),
|
||||||
|
('stty', 'coreutils', None, 0, 2),
|
||||||
|
('ponytool', 'util-say>=3', 'KMS utilisation and PNG support', 0, 1),
|
||||||
|
(None, 'python>=3', None, 2, 2)
|
||||||
|
]
|
||||||
|
|
||||||
|
path = os.environ['PATH'].split(':')
|
||||||
|
|
||||||
|
build_required = True
|
||||||
|
build_optional = True
|
||||||
|
runtime_required = True
|
||||||
|
runtime_optional = True
|
||||||
|
|
||||||
|
def test(dependency):
|
||||||
|
executable = dependency[0]
|
||||||
|
if executable is None:
|
||||||
|
if sys.version_info.major == 3:
|
||||||
|
return
|
||||||
|
executable = 'python3'
|
||||||
|
for p in path:
|
||||||
|
if len(p) != 0:
|
||||||
|
if os.path.exists((p + '/' + executable).replace('//', '/')):
|
||||||
|
return
|
||||||
|
global build_required, build_optional, runtime_required, runtime_optional
|
||||||
|
requirement = ''
|
||||||
|
if dependency[3] == 2: build_required = False ; requirement += 'build required + '
|
||||||
|
if dependency[3] == 1: build_optional = False ; requirement += 'build optional + '
|
||||||
|
if dependency[4] == 2: runtime_required = False ; requirement += 'runtime required + '
|
||||||
|
if dependency[4] == 1: runtime_optional = False ; requirement += 'runtime optional + '
|
||||||
|
requirement = requirement[:len(requirement) - 3]
|
||||||
|
print('Missing %s, install %s. [%s]' % (executable, dependency[1], requirement))
|
||||||
|
if dependency[2] is not None:
|
||||||
|
print(' Required for %s.' % dependency[2])
|
||||||
|
|
||||||
|
for dependency in dependencies:
|
||||||
|
test(dependency)
|
||||||
|
|
||||||
|
rc = 0
|
||||||
|
|
||||||
|
if not build_required:
|
||||||
|
print('You will not be able to build and install ponysay.')
|
||||||
|
rc = 1
|
||||||
|
elif not build_optional:
|
||||||
|
print('You will have to tweak to installation to build and install ponysay.')
|
||||||
|
|
||||||
|
if not runtime_required:
|
||||||
|
print('You will not be able to run ponysay.')
|
||||||
|
rc = 1
|
||||||
|
elif not runtime_optional:
|
||||||
|
print('You will be missing some features in ponysay.')
|
||||||
|
|
||||||
|
if not (build_required and build_optional and runtime_required and runtime_optional):
|
||||||
|
print('\nEverything appears to be in order, enjoy ponysay!')
|
||||||
|
|
||||||
|
exit(rc)
|
||||||
|
|
Loading…
Reference in a new issue