Add support for running on PyPy.

master 2.0.0
Isis Lovecruft 2015-02-22 22:45:04 +00:00
parent 5025df1661
commit d66b23b896
No known key found for this signature in database
GPG Key ID: 18C16EC5F9F1D673
3 changed files with 42 additions and 5 deletions

View File

@ -32,12 +32,18 @@ import encodings
import locale import locale
import os import os
import platform import platform
import psutil
import shlex import shlex
import subprocess import subprocess
import sys import sys
import threading import threading
## Using psutil is recommended, but since the extension doesn't run with the
## PyPy interpreter, we'll run even if it's not present.
try:
import psutil
except ImportError:
psutil = None
from . import _parsers from . import _parsers
from . import _util from . import _util
@ -81,10 +87,19 @@ class GPGMeta(type):
the same. (Sorry Windows users; maybe you should switch to anything the same. (Sorry Windows users; maybe you should switch to anything
else.) else.)
.. note: This function will only run if the psutil_ Python extension
is installed. Because psutil won't run with the PyPy interpreter,
use of it is optional (although highly recommended).
.. _psutil: https://pypi.python.org/pypi/psutil
:returns: True if there exists a gpg-agent process running under the :returns: True if there exists a gpg-agent process running under the
same effective user ID as that of this program. Otherwise, same effective user ID as that of this program. Otherwise,
returns False. returns False.
""" """
if not psutil:
return False
this_process = psutil.Process(os.getpid()) this_process = psutil.Process(os.getpid())
ownership_match = False ownership_match = False

View File

@ -28,7 +28,6 @@ from time import mktime
import codecs import codecs
import encodings import encodings
import os import os
import psutil
import threading import threading
import random import random
import re import re
@ -418,7 +417,7 @@ def _make_passphrase(length=None, save=False, file=None):
passphrase = _make_random_string(length) passphrase = _make_random_string(length)
if save: if save:
ruid, euid, suid = psutil.Process(os.getpid()).uids ruid, euid, suid = os.getresuid()
gid = os.getgid() gid = os.getgid()
now = mktime(localtime()) now = mktime(localtime())

View File

@ -22,11 +22,19 @@
from __future__ import absolute_import from __future__ import absolute_import
from __future__ import print_function from __future__ import print_function
import platform
import setuptools import setuptools
import sys import sys
import os import os
import versioneer import versioneer
try:
import __pypy__
except ImportError:
_isPyPy = False
else:
_isPyPy = True
versioneer.versionfile_source = 'gnupg/_version.py' versioneer.versionfile_source = 'gnupg/_version.py'
versioneer.versionfile_build = 'gnupg/_version.py' versioneer.versionfile_build = 'gnupg/_version.py'
@ -75,6 +83,13 @@ def get_requirements():
# Required to make `collections.OrderedDict` available on Python<=2.6 # Required to make `collections.OrderedDict` available on Python<=2.6
requirements.append('ordereddict==1.1#a0ed854ee442051b249bfad0f638bbec') requirements.append('ordereddict==1.1#a0ed854ee442051b249bfad0f638bbec')
# Don't try to install psutil on PyPy:
if _isPyPy:
for line in requirements[:]:
if line.startswith('psutil'):
print("Not installing %s on PyPy..." % line)
requirements.remove(line)
return requirements, links return requirements, links
@ -89,8 +104,8 @@ This module allows easy access to GnuPG's key management, encryption and \
signature functionality from Python programs, by interacting with GnuPG \ signature functionality from Python programs, by interacting with GnuPG \
through file descriptors. Input arguments are strictly checked and sanitised, \ through file descriptors. Input arguments are strictly checked and sanitised, \
and therefore this module should be safe to use in networked applications \ and therefore this module should be safe to use in networked applications \
requiring direct user input. It is intended for use with Python 2.6 or \ requiring direct user input. It is intended for use on Windows, MacOS X, BSD, \
greater. or Linux, with Python 2.6, Python 2.7, Python 3.3, Python 3.4, or PyPy.
""", """,
license="GPLv3+", license="GPLv3+",
@ -119,7 +134,13 @@ greater.
classifiers=[ classifiers=[
"Development Status :: 5 - Production/Stable", "Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers", "Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Operating System :: Android",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: BSD",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python", "Programming Language :: Python",
"Programming Language :: Python :: 2", "Programming Language :: Python :: 2",
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
@ -127,6 +148,8 @@ greater.
"Programming Language :: Python :: 2.7", "Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.4",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Security :: Cryptography", "Topic :: Security :: Cryptography",
"Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Utilities",] "Topic :: Utilities",]