few tweaks for python3 support

* switch from script to entry_points in setup.py
* move the cli script in ldapcherry (to be used as a module)
* put the __main__ code in a dedicated function constituting the entry
point
* add a few python3 environments in travis file
This commit is contained in:
kakwa 2019-02-07 20:34:49 +01:00
parent 3d6e24eb73
commit c81429a870
3 changed files with 27 additions and 9 deletions

View File

@ -8,12 +8,9 @@ language: python
before_install:
- '[ "$TEST_PEP8" == "1" ] || sudo ./tests/test_env/deploy.sh'
python:
- "2.7"
install:
- pip install -e .
- "if [[ $TEST_PEP8 == '1' ]]; then pip install pep8; fi"
- "if [[ $TEST_PEP8 == '1' ]]; then pip install pycodestyle; fi"
- pip install passlib
- pip install coveralls
@ -21,11 +18,23 @@ install:
#
#script:
# - coverage run --source=ldapcherry setup.py test
script: "if [[ $TEST_PEP8 == '1' ]]; then pep8 --repeat --show-source --exclude=.venv,.tox,dist,docs,build,*.egg,tests,misc,setup.py . scripts/ldapcherryd; else coverage run --source=ldapcherry setup.py test; fi"
script: "if [[ $TEST_PEP8 == '1' ]]; then pycodestyle --repeat --show-source --exclude=.venv,.tox,dist,docs,build,*.egg,tests,misc,setup.py . scripts/ldapcherryd; else coverage run --source=ldapcherry setup.py test; fi"
matrix:
include:
- python: "2.7"
env: TEST_PEP8=1
- python: "2.7"
env: TEST_PEP8=0
- python: "3.5"
env: TEST_PEP8=0
- python: "3.6"
env: TEST_PEP8=0
- python: "3.4"
env: TEST_PEP8=0
- python: "3.7"
env: TEST_PEP8=0
after_success:
- coveralls
after_failure:

View File

@ -102,7 +102,7 @@ def start(configfile=None, daemonize=False, environment=None,
engine.block()
if __name__ == '__main__':
def main():
from optparse import OptionParser
p = OptionParser()
@ -142,3 +142,6 @@ if __name__ == '__main__':
start(options.config, options.daemonize,
options.environment, options.fastcgi, options.scgi,
options.pidfile, options.cgi, options.debug)
if __name__ == '__main__':
main()

View File

@ -29,8 +29,12 @@ if sys.version_info[0] == 2:
'Mako'
],
elif sys.version_info[0] == 3:
print('unsupported version')
exit(1)
install_requires = [
'CherryPy >= 3.0.0',
'python-ldap',
'PyYAML',
'Mako'
],
else:
print('unsupported version')
exit(1)
@ -120,7 +124,9 @@ setup(
'ldapcherry.ppolicy'
],
data_files=resources_files,
scripts=['scripts/ldapcherryd'],
entry_points = {
'console_scripts': ['ldapcherryd = ldapcherry.cli:main']
},
url='https://github.com/kakwa/ldapcherry',
license=license,
description=small_description,