diff --git a/README b/README index 5fde85a..e4cb71e 100644 --- a/README +++ b/README @@ -2,14 +2,14 @@ Installing PyMoira ================== -To install PyMoira, you will first need to install Pyrex_. It's always -a good idea to install Pyrex through your package manager, if -possible. Your system's Pyrex package may be named ``python-pyrex`` or -``pyrex-py25``. If your package manager doesn't have a package for -Pyrex, or if you wish to install Pyrex by hand anyway, you can do so +To install PyMoira, you will first need to install Cython_. It's +always a good idea to install Cython through your package manager, if +possible. Your system's Cython package may be named ``python3-cython`` +or ``py37-cython``. If your package manager doesn't have a package for +Cython, or if you wish to install Cython by hand anyway, you can do so by running:: - $ easy_install Pyrex + $ easy_install Cython Once you've done that, to install PyMoira globally, run:: @@ -33,7 +33,7 @@ build the Debian package of the latest release, run:: You will need the devscripts and git-buildpackage packages installed, as well as this package's build dependencies (debhelper, cdbs, -python-all-dev, python-support, python-pyrex, python-setuptools, +python-all-dev, python-support, python-cython, python-setuptools, debathena-libmoira-dev). -.. _Pyrex: http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/ +.. _Cython: https://cython.org/ diff --git a/_moira.pyx b/_moira.pyx index 80af823..acd3a39 100644 --- a/_moira.pyx +++ b/_moira.pyx @@ -1,3 +1,5 @@ +# cython: c_string_type=unicode, c_string_encoding=ascii + cdef extern from "moira/moira.h": int mr_krb5_auth(char * prog) int mr_auth(char * prog) @@ -57,6 +59,8 @@ def connect(server=''): if __connected: disconnect() + if isinstance(server, unicode): + server = server.encode('idna') status = mr_connect(server) if status != MR_SUCCESS: _error(status) diff --git a/moira.py b/moira.py index 7090a2d..2aa49b5 100644 --- a/moira.py +++ b/moira.py @@ -149,7 +149,7 @@ def access(handle, *args, **kwargs): try: _moira._access(handle, *args) return True - except MoiraException, e: + except MoiraException as e: if e.code != errors()['MR_PERM']: raise return False diff --git a/qy b/qy index baeccbb..ea52564 100755 --- a/qy +++ b/qy @@ -1,6 +1,8 @@ #!/usr/bin/python """qy: A scriptable, command-line Moira client.""" +from __future__ import print_function + import optparse import moira @@ -53,8 +55,8 @@ def main(): moira.auth(options.program) if args[0].startswith('_'): - print '\n'.join(', '.join(x) for x in - moira._list_query(*args)) + print('\n'.join(', '.join(x) for x in + moira._list_query(*args))) else: results = moira.query(fmt=tuple, *args) @@ -63,10 +65,10 @@ def main(): r = filter_fields(r, options.fields) if options.single: - print ', '.join(v for (k, v) in r) + print(', '.join(v for (k, v) in r)) else: for k, v in r: - print '%-*s: %s' % (keylen, k, v) + print('%-*s: %s' % (keylen, k, v)) print if __name__ == '__main__': diff --git a/setup.py b/setup.py index ff2db53..e196831 100755 --- a/setup.py +++ b/setup.py @@ -2,24 +2,23 @@ from setuptools import setup from distutils.extension import Extension -from Pyrex.Distutils import build_ext +from Cython.Build import cythonize setup( name="PyMoira", - version="4.3.0", + version="4.3.1", description="PyMoira - Python bindings for the Athena Moira library", author="Evan Broder", author_email="broder@mit.edu", license="MIT", py_modules=['moira'], - ext_modules=[ + ext_modules=cythonize([ Extension("_moira", ["_moira.pyx"], libraries=["moira", "krb5"]), Extension("mrclient", ["mrclient.pyx"], libraries=["mrclient", "moira"]), - ], + ]), scripts=['qy'], - cmdclass= {"build_ext": build_ext} )