Skip to content

Commit 0830097

Browse files
committed
Experimenting with namespace package settings - following similar
strategy to Paste and using pkg_resources if available otherwise pkgutil
1 parent 92310d7 commit 0830097

File tree

4 files changed

+25
-28
lines changed

4 files changed

+25
-28
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/ndg_httpsclient.egg-info/
2+
/dist/

ndg/__init__.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
"""ndg_httpsclient - PyOpenSSL utility to make a httplib-like interface suitable
2-
for use with urllib2
3-
4-
This is a setuptools namespace_package. DO NOT place any other
5-
code in this file! There is no guarantee that it will be installed
6-
with easy_install. See:
7-
8-
http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
9-
10-
... for details.
11-
"""
12-
__author__ = "P J Kershaw"
13-
__date__ = "06/01/12"
14-
__copyright__ = "(C) 2012 Science and Technology Facilities Council"
15-
__license__ = "BSD - see LICENSE file in top-level directory"
16-
__contact__ = "[email protected]"
17-
__revision__ = '$Id$'
18-
19-
__import__('pkg_resources').declare_namespace(__name__)
1+
try:
2+
import pkg_resources
3+
pkg_resources.declare_namespace(__name__)
4+
except ImportError:
5+
# don't prevent use if pkg_resources isn't installed
6+
from pkgutil import extend_path
7+
__path__ = extend_path(__path__, __name__)
8+
9+
import modulefinder
10+
for p in __path__:
11+
modulefinder.AddPackagePath(__name__, p)

ndg/httpsclient/ssl_peer_verification.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ class ServerSSLCertVerification(object):
4141
'userid': 'UID'
4242
}
4343
SUBJ_ALT_NAME_EXT_NAME = 'subjectAltName'
44-
PARSER_RE_STR = '/(%s)=' % '|'.join(list(DN_LUT.keys()) + list(DN_LUT.values()))
44+
PARSER_RE_STR = '/(%s)=' % '|'.join(list(DN_LUT.keys()) + \
45+
list(DN_LUT.values()))
4546
PARSER_RE = re.compile(PARSER_RE_STR)
4647

4748
__slots__ = ('__hostname', '__certDN', '__subj_alt_name_match')

setup.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use_setuptools()
66
from setuptools import setup, find_packages
77

8+
NAMESPACE_PKGS = ['ndg']
9+
810
_long_description = '''
911
This is a HTTPS client implementation for httplib and urllib2 based on
1012
PyOpenSSL. PyOpenSSL provides a more fully featured SSL implementation over the
@@ -102,17 +104,17 @@
102104

103105
setup(
104106
name='ndg_httpsclient',
105-
version="0.4.0",
107+
version="0.4.1",
106108
description='Provides enhanced HTTPS support for httplib and urllib2 using '
107109
'PyOpenSSL',
108110
author='Richard Wilkinson and Philip Kershaw',
109111
author_email='[email protected]',
110112
url='https://github.com/cedadev/ndg_httpsclient/',
111113
long_description=_long_description,
112114
license='BSD - See LICENCE file for details',
113-
namespace_packages=['ndg'],
114115
packages=find_packages(),
115-
package_dir={'ndg.httpsclient': 'ndg/httpsclient'},
116+
namespace_packages=NAMESPACE_PKGS,
117+
# package_dir={'ndg.httpsclient': 'ndg/httpsclient'},
116118
package_data={
117119
'ndg.httpsclient': [
118120
'test/README',
@@ -121,9 +123,9 @@
121123
'test/pki/ca/*.0'
122124
],
123125
},
124-
install_requires = ['PyOpenSSL'],
125-
extras_require = {'subjectAltName_support': 'pyasn1'},
126-
classifiers = [
126+
install_requires=['PyOpenSSL'],
127+
extras_require={'subjectAltName_support': 'pyasn1'},
128+
classifiers=[
127129
'Development Status :: 3 - Alpha',
128130
'Environment :: Console',
129131
'Environment :: Web Environment',
@@ -143,8 +145,8 @@
143145
'Topic :: System :: Systems Administration :: Authentication/Directory',
144146
'Topic :: Software Development :: Libraries :: Python Modules'
145147
],
146-
zip_safe = False,
147-
entry_points = {
148+
zip_safe=False,
149+
entry_points={
148150
'console_scripts': ['ndg_httpclient = ndg.httpsclient.utils:main',
149151
],
150152
}

0 commit comments

Comments
 (0)