Skip to content

Commit

Permalink
Merge pull request #8 from zopefoundation/browser_extra
Browse files Browse the repository at this point in the history
Move the heavy browser dependencies to a 'browser' extra
  • Loading branch information
jamadden authored Sep 28, 2017
2 parents 1d24b32 + e38a5d2 commit 9f61c6d
Show file tree
Hide file tree
Showing 23 changed files with 193 additions and 127 deletions.
40 changes: 19 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
language: python
sudo: false
python:
- 2.7
- 3.3
- 3.4
- 3.5
- 3.6
- pypy-5.4.1
- pypy3.3-5.2-alpha1
- 2.7
- 3.4
- 3.5
- 3.6
- pypy
- pypy3
env:
- DEP=test
matrix:
include:
- python: 2.7
env: DEP=no_such_extra
install:
- pip install -U pip setuptools
- pip install -U coverage coveralls zope.testing zope.testrunner
- pip install -U -e .[$DEP]
script:
- coverage run -m zope.testrunner --test-path=src --auto-color --auto-progress

- coverage run -m zope.testrunner --test-path=src
after_success:
- coveralls
- coveralls
notifications:
email: false

install:
- pip install -U pip setuptools
- pip install -U coveralls coverage zope.testrunner
- pip install -U -e ".[test]"


email: false
cache: pip

before_cache:
- rm -f $HOME/.cache/pip/log/debug.log
8 changes: 6 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
Changes
=======

2.2.1 (unreleased)
2.3.0 (unreleased)
------------------

- TBD
- Drop support for Python 3.3.

- Move the dependencies on ``zope.browser``, ``zope.publisher`` and
``zope.formlib`` (only needed to use the ``source`` and ``widget``
modules) into a new ``browser`` extra.

2.2.0 (2017-04-24)
------------------
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ include *.txt
include *.py
include buildout.cfg
include tox.ini
include .travis.yml
include .coveragerc

recursive-include src *

Expand Down
11 changes: 11 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
``zope.mimetype``
=================

.. image:: https://img.shields.io/pypi/v/zope.mimetype.svg
:target: https://pypi.python.org/pypi/zope.mimetype/
:alt: Latest release

.. image:: https://img.shields.io/pypi/pyversions/zope.mimetype.svg
:target: https://pypi.org/project/zope.mimetype/
:alt: Supported Python versions

.. image:: https://travis-ci.org/zopefoundation/zope.mimetype.png?branch=master
:target: https://travis-ci.org/zopefoundation/zope.mimetype

.. image:: https://coveralls.io/repos/github/zopefoundation/zope.mimetype/badge.svg?branch=master
:target: https://coveralls.io/github/zopefoundation/zope.mimetype?branch=master

This package provides a way to work with MIME content types. There
are several interfaces defined here, many of which are used primarily
to look things up based on different bits of information.
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[bdist_wheel]
universal = 1
95 changes: 49 additions & 46 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,50 @@ def read(*rnames):
with open(os.path.join(os.path.dirname(__file__), *rnames)) as f:
return f.read()

BROWSER_REQUIRES = [
'zope.browser', # ITerms in source.py
'zope.browserresource', # metaconfigure for icon in zcml.py
'zope.formlib>=4.0', # widget.py
'zope.publisher', # IBrowserRequest
]

TEST_REQUIRES = BROWSER_REQUIRES + [
'zope.testing',
'zope.testrunner',
]

setup(name='zope.mimetype',
version='2.2.1.dev0',
version='2.3.0.dev0',
author='Zope Foundation and Contributors',
author_email='[email protected]',
description = "A simple package for working with MIME content types",
description="A simple package for working with MIME content types",
long_description=(
read('README.rst')
+ '\n\n' +
read('src', 'zope', 'mimetype', 'README.txt')
read('src', 'zope', 'mimetype', 'README.rst')
+ '\n\n' +
read('src', 'zope', 'mimetype', 'retrieving_mime_types.txt')
read('src', 'zope', 'mimetype', 'retrieving_mime_types.rst')
+ '\n\n' +
read('src', 'zope', 'mimetype', 'codec.txt')
read('src', 'zope', 'mimetype', 'codec.rst')
+ '\n\n' +
read('src', 'zope', 'mimetype', 'constraints.txt')
read('src', 'zope', 'mimetype', 'constraints.rst')
+ '\n\n' +
read('src', 'zope', 'mimetype', 'contentinfo.txt')
read('src', 'zope', 'mimetype', 'contentinfo.rst')
+ '\n\n' +
read('src', 'zope', 'mimetype', 'event.txt')
read('src', 'zope', 'mimetype', 'event.rst')
+ '\n\n' +
read('src', 'zope', 'mimetype', 'typegetter.txt')
read('src', 'zope', 'mimetype', 'typegetter.rst')
+ '\n\n' +
read('src', 'zope', 'mimetype', 'source.txt')
read('src', 'zope', 'mimetype', 'source.rst')
+ '\n\n' +
read('src', 'zope', 'mimetype', 'widget.txt')
read('src', 'zope', 'mimetype', 'widget.rst')
+ '\n\n' +
read('src', 'zope', 'mimetype', 'utils.txt')
read('src', 'zope', 'mimetype', 'utils.rst')
+ '\n\n' +
read('CHANGES.rst')
),
keywords = "file content mimetype",
classifiers = [
),
keywords="file content mimetype",
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Intended Audience :: Developers',
Expand All @@ -65,7 +77,6 @@ def read(*rnames):
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
Expand All @@ -75,37 +86,29 @@ def read(*rnames):
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
'Framework :: Zope3'],
url='http://pypi.python.org/pypi/zope.mimetype',
url='https://github.com/zopefoundation/zope.mimetype',
license='ZPL 2.1',
packages=find_packages('src'),
package_dir = {'': 'src'},
package_dir={'': 'src'},
namespace_packages=['zope'],
extras_require = dict(
test=[
'zope.component',
'zope.testing',
]
),
install_requires=['setuptools',
'zope.browser',
'zope.browserresource',
'zope.component',
'zope.configuration',
'zope.contenttype>=3.5',
'zope.event',
'zope.formlib>=4.0',
'zope.i18n',
'zope.i18nmessageid',
'zope.interface',
'zope.publisher',
'zope.schema',
'zope.security',
],
tests_require=[
'zope.component',
'zope.testing',
],
extras_require={
'test': TEST_REQUIRES,
'browser': BROWSER_REQUIRES,
},
install_requires=[
'setuptools',
'zope.component',
'zope.configuration',
'zope.contenttype>=3.5',
'zope.event',
'zope.i18n',
'zope.i18nmessageid',
'zope.interface',
'zope.schema',
'zope.security',
],
tests_require=TEST_REQUIRES,
test_suite='zope.mimetype.tests',
include_package_data = True,
zip_safe = False,
)
include_package_data=True,
zip_safe=False,
)
2 changes: 1 addition & 1 deletion src/zope/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,18 @@ adapters and utilities and a couple of views:

>>> XMLConfig('configure.zcml', zope.mimetype)()

>>> len(list(zope.component.getGlobalSiteManager().registeredUtilities())) >= 760
>>> len(list(zope.component.getGlobalSiteManager().registeredUtilities())) >= 755
True

>>> len(list(zope.component.getGlobalSiteManager().registeredAdapters()))
107

The 'zmi_icon' adapters are only installed if zope.browserresource
is available:

>>> try:
... import zope.browserresource
... except ImportError:
... expected = 1
... else:
... expected = 107
>>> len(list(zope.component.getGlobalSiteManager().registeredAdapters())) == expected
True
43 changes: 24 additions & 19 deletions src/zope/mimetype/configure.zcml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:zcml="http://namespaces.zope.org/zcml"
i18n_domain="zope.mimetype">

<include package="zope.component" file="meta.zcml" />
Expand All @@ -21,25 +22,29 @@
/>

<adapter factory=".contentinfo.ContentInfo"/>
<adapter factory=".source.CodecTerms"/>
<adapter factory=".source.ContentTypeTerms"/>

<view
type="zope.publisher.interfaces.browser.IBrowserRequest"
for="zope.schema.interfaces.IChoice
zope.mimetype.interfaces.ICodecSource"
provides="zope.formlib.interfaces.IInputWidget"
factory=".widget.TranslatableSourceDropdownWidget"
permission="zope.Public"
/>

<view
type="zope.publisher.interfaces.browser.IBrowserRequest"
for="zope.schema.interfaces.IChoice
zope.mimetype.interfaces.IContentTypeSource"
provides="zope.formlib.interfaces.IInputWidget"
factory=".widget.TranslatableSourceDropdownWidget"
permission="zope.Public"
/>
<configure zcml:condition="installed zope.browser">

<adapter factory=".source.CodecTerms"/>
<adapter factory=".source.ContentTypeTerms"/>

<view
type="zope.publisher.interfaces.browser.IBrowserRequest"
for="zope.schema.interfaces.IChoice
zope.mimetype.interfaces.ICodecSource"
provides="zope.formlib.interfaces.IInputWidget"
factory=".widget.TranslatableSourceDropdownWidget"
permission="zope.Public"
/>

<view
type="zope.publisher.interfaces.browser.IBrowserRequest"
for="zope.schema.interfaces.IChoice
zope.mimetype.interfaces.IContentTypeSource"
provides="zope.formlib.interfaces.IInputWidget"
factory=".widget.TranslatableSourceDropdownWidget"
permission="zope.Public"
/>
</configure>

</configure>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
66 changes: 38 additions & 28 deletions src/zope/mimetype/tests/test_doctests.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,48 +37,58 @@
r"builtins"),
])

def optional_test_suite_setUp(required_module):

def setUp(test):
import importlib
try:
importlib.import_module(required_module)
except ImportError:
raise unittest.SkipTest("Required module %r missing" % (required_module,))
testing.setUp(test)
return setUp

def test_suite():
return unittest.TestSuite((
doctest.DocFileSuite(
'../retrieving_mime_types.txt',
setUp=testing.setUp, tearDown=testing.tearDown,
checker=checker),
'../retrieving_mime_types.rst',
setUp=testing.setUp, tearDown=testing.tearDown,
checker=checker),
doctest.DocFileSuite(
'../event.txt',
setUp=testing.setUp, tearDown=testing.tearDown,
globs={'print_function': print_function},
checker=checker),
'../event.rst',
setUp=testing.setUp, tearDown=testing.tearDown,
globs={'print_function': print_function},
checker=checker),
doctest.DocFileSuite(
'../source.txt',
setUp=testing.setUp, tearDown=testing.tearDown,
checker=checker),
'../source.rst',
setUp=optional_test_suite_setUp('zope.browser'), tearDown=testing.tearDown,
checker=checker),
doctest.DocFileSuite(
'../constraints.txt',
checker=checker),
'../constraints.rst',
checker=checker),
doctest.DocFileSuite(
'../contentinfo.txt',
setUp=testing.setUp, tearDown=testing.tearDown,
checker=checker),
'../contentinfo.rst',
setUp=testing.setUp, tearDown=testing.tearDown,
checker=checker),
doctest.DocFileSuite(
'../typegetter.txt',
checker=checker),
'../typegetter.rst',
checker=checker),
doctest.DocFileSuite(
'../utils.txt',
checker=checker),
'../utils.rst',
checker=checker),
doctest.DocFileSuite(
'../widget.txt',
setUp=testing.setUp, tearDown=testing.tearDown,
checker=checker),
'../widget.rst',
setUp=optional_test_suite_setUp('zope.publisher'), tearDown=testing.tearDown,
checker=checker),
doctest.DocFileSuite(
'../codec.txt',
optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
checker=checker,
'../codec.rst',
optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
checker=checker,
),
doctest.DocFileSuite(
'../configure.txt',
setUp=testing.setUp, tearDown=testing.tearDown,
checker=checker
'../configure.rst',
setUp=testing.setUp, tearDown=testing.tearDown,
checker=checker
),
))

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 9f61c6d

Please sign in to comment.