Skip to main content

ftw.autofeature automatically registers ZCML features.

Extras features

The autofeature:extras directive automatically registers ZCML features for each extra (extras_requires) of your package. The feature for an extra is automatically provided when each dependency of the extra is installed.

Example

When having a setup.py like this:

from setuptools import setup, find_packages

setup(name='my.package',
      version='1.0.0dev0',
      packages=find_packages(exclude=['ez_setup']),
      namespace_packages=['my'],
      install_requires=[
          'setuptools',
          'ftw.autofeature',
      ],

      extras_require={
          'tests': ['unittest2'],
          'foo': ['foo', 'foo-compat'],
          'bar': ['bar', 'bar-compat']})

you can let ftw.autofeature automatically declare features for your extras:

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:zcml="http://namespaces.zope.org/zcml"
    xmlns:autofeature="http://namespaces.zope.org/autofeature">

    <include package="ftw.autofeature" file="meta.zcml" />
    <autofeature:extras />

    <configure zcml:condition="have my.package:foo">
        <!-- foo things -->
    </configure>

    <configure zcml:condition="have my.package:bar">
        <!-- bar things -->
    </configure>

    <configure zcml:condition="have my.package:foo:bar">
        <!-- foo and bar things -->
    </configure>

</configure>

The feature my.package:foo is only registered when the extras is installed. When installing both, foo and bar, multiple features are registered so that it easy to combine extras with AND:

  • my.package:foo

  • my.package:foo:bar

  • my.package:bar

  • my.package:bar:foo

Limitiation

We cannot really detect whether the extras was explictly used on installation time. We therefore test whether each dependency in the extras is installed. When each dependency is installed but not the extras explicitly, this will thus also register the feature.

Dump feature

The autofeature:dump directive dumps the currently registered ZCML features to the standard out. Simply use the directive to dump the features at any point in the ZCML:

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:autofeature="http://namespaces.zope.org/autofeature">

    <include package="ftw.autofeature" file="meta.zcml" />
    <autofeature:dump />

</configure>

Changelog

1.1.0 (2019-09-25)

  • Add Plone 5 support. [jone]

1.0.0 (2015-08-24)

  • Initial implementation [jone]

Release files for ftw.autofeature 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ftw.autofeature 1.1.0
File Size Uploaded
ftw.autofeature-1.1.0.tar.gz 13.9 kB Details

Release files / ftw.autofeature-1.1.0.tar.gz

Download URL ftw.autofeature-1.1.0.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2a66da7842cf8dc5c5d548de9645fff2cb19bf48eea4113ea2e1398bed2fc5f5
BLAKE2b-256 checksum
How to use checksums
e6953d420a88be27076906d342763c040bb38c60eeec498acef59a09e6ebd376
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/2.7.15

Release history Release notifications | RSS feed

This release

1.1.0 This release

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page