Esempio n. 1
0
def setup_hook(config):
    """Filter config parsed from a setup.cfg to inject our defaults."""
    metadata = config['metadata']
    metadata['version'] = packaging.get_version(metadata['name'],
                                                metadata.get('version', None))
    metadata['requires_dist'] = "\n".join(packaging.parse_requirements())
    config['metadata'] = metadata

    config['global'] = config.get('global', dict())
    config['global']['commands'] = config['global'].get('commands', "") + """
pbr.packaging.LocalSDist
"""
    if packaging.have_sphinx():
        config['global']['commands'] = config['global']['commands'] + """
pbr.packaging.LocalBuildDoc
pbr.packaging.LocalBuildLatex
"""

    #config['backwards_compat']['dependency_links'] = parse_dependency_links()
    #config['backwards_compat']['include_package_data'] = True
    #config['backwards_compat']['tests_require'] = parse_requirements(
    #    ["test-requirements.txt", "tools/test-requires"])

    files = config.get('files', dict())
    files['packages'] = smart_find_packages(
        files.get('packages', metadata['name']))
    config['files'] = files
Esempio n. 2
0
File: hooks.py Progetto: dprince/pbr
def setup_hook(config):
    """Filter config parsed from a setup.cfg to inject our defaults."""
    metadata = config['metadata']
    metadata['version'] = packaging.get_version(metadata['name'],
                                                metadata.get('version', None))
    metadata['requires_dist'] = "\n".join(packaging.parse_requirements())
    config['metadata'] = metadata

    config['global'] = config.get('global', dict())
    config['global']['commands'] = config['global'].get('commands', "") + """
pbr.packaging.LocalSDist
"""
    if packaging.have_sphinx():
        config['global']['commands'] = config['global']['commands'] + """
pbr.packaging.LocalBuildDoc
pbr.packaging.LocalBuildLatex
"""

    pbr_config = config.get('pbr', dict())
    use_egg = packaging.get_boolean_option(
        pbr_config, 'use-egg', 'PBR_USE_EGG')
    # We always want non-egg install unless explicitly requested
    if 'manpages' in pbr_config or not use_egg:
        config['global']['commands'] = config['global']['commands'] + """
pbr.packaging.DistutilsInstall
"""

    backwards_compat = config.get('backwards_compat', dict())
    backwards_compat['dependency_links'] = "\n".join(
        packaging.parse_dependency_links())
    backwards_compat['include_package_data'] = 'True'
    backwards_compat['tests_require'] = "\n".join(
        packaging.parse_requirements(
            ["test-requirements.txt", "tools/test-requires"]))
    config['backwards_compat'] = backwards_compat

    files = config.get('files', dict())
    package = files.get('packages', metadata['name']).strip()
    if os.path.isdir(package):
        files['packages'] = smart_find_packages(package)

    if 'manpages' in pbr_config:
        man_sections = dict()
        manpages = pbr_config['manpages']
        data_files = files.get('data_files', '')
        for manpage in manpages.split():
            section_number = manpage.strip()[-1]
            section = man_sections.get(section_number, list())
            section.append(manpage.strip())
            man_sections[section_number] = section
        for (section, pages) in man_sections.items():
            manpath = os.path.join(packaging.get_manpath(), 'man%s' % section)
            data_files = "%s\n%s" % (data_files, "%s =" % manpath)
            for page in pages:
                data_files = "%s\n%s" % (data_files, page)
        files['data_files'] = data_files

    config['files'] = files
Esempio n. 3
0
def _builder_inited(app):
    theme_dir = paths.get_html_theme_path()
    logger.info('Using otcdocstheme Sphinx theme from %s' % theme_dir)
    _setup_link_roles(app)

    # we only override configuration if the theme has been configured, meaning
    # users are using these features
    if app.config.html_theme != 'otcdocs':
        return

    # TODO(stephenfin): Once Sphinx 1.8 is released, we should move the below
    # to a 'config-inited' handler

    project_name = _get_project_name(app.srcdir)
    try:
        version = packaging.get_version(project_name)
    except Exception:
        version = None

    # NOTE(stephenfin): Chances are that whatever's in 'conf.py' is probably
    # wrong/outdated so, if we can, we intentionally overwrite it...
    if project_name:
        app.config.project = project_name

    app.config.html_last_updated_fmt = '%Y-%m-%d %H:%M'

    # ...except for version/release which, if blank, should remain that way to
    # cater for unversioned documents
    if app.config.version != '' and version:
        app.config.version = version
        app.config.release = version

    otc_logo = paths.get_otc_logo_path()
    pdf_theme_path = paths.get_pdf_theme_path()

    app.config.latex_engine = 'xelatex'
    app.config.latex_elements = {
        'papersize':
        'a4paper',
        'pointsize':
        '11pt',
        'figure_align':
        'H',
        'classoptions':
        ',openany',
        'preamble':
        r"""
\usepackage{""" + pdf_theme_path + """}
\\newcommand{\otclogo}{""" + otc_logo + """}
"""
    }
Esempio n. 4
0
 def _get_version_from_pkg_resources(self):
     """Get the version of the package from the pkg_resources record
     associated with the package.
     """
     try:
         requirement = pkg_resources.Requirement.parse(self.package)
         provider = pkg_resources.get_provider(requirement)
         return provider.version
     except pkg_resources.DistributionNotFound:
         # The most likely cause for this is running tests in a tree
         # produced from a tarball where the package itself has not been
         # installed into anything. Revert to setup-time logic.
         from pbr import packaging
         return packaging.get_version(self.package)
Esempio n. 5
0
    def _get_version_from_pkg_resources(self):
        """Obtain a version from pkg_resources or setup-time logic if missing.

        This will try to get the version of the package from the pkg_resources
        record associated with the package, and if there is no such record
        falls back to the logic sdist would use.
        """
        try:
            requirement = pkg_resources.Requirement.parse(self.package)
            provider = pkg_resources.get_provider(requirement)
            result_string = provider.version
        except pkg_resources.DistributionNotFound:
            # The most likely cause for this is running tests in a tree
            # produced from a tarball where the package itself has not been
            # installed into anything. Revert to setup-time logic.
            from pbr import packaging
            result_string = packaging.get_version(self.package)
        return SemanticVersion.from_pip_string(result_string)
Esempio n. 6
0
    def _get_version_from_pkg_resources(self):
        """Obtain a version from pkg_resources or setup-time logic if missing.

        This will try to get the version of the package from the pkg_resources
        record associated with the package, and if there is no such record
        falls back to the logic sdist would use.
        """
        try:
            requirement = pkg_resources.Requirement.parse(self.package)
            provider = pkg_resources.get_provider(requirement)
            result_string = provider.version
        except pkg_resources.DistributionNotFound:
            # The most likely cause for this is running tests in a tree
            # produced from a tarball where the package itself has not been
            # installed into anything. Revert to setup-time logic.
            from pbr import packaging
            result_string = packaging.get_version(self.package)
        return SemanticVersion.from_pip_string(result_string)
Esempio n. 7
0
 def _get_version_from_pkg_resources(self):
     """Get the version of the package from the pkg_resources record
     associated with the package.
     """
     provider = self._get_provider()
     if provider:
         return provider.version
     else:
         # The most likely cause for this is running tests in a tree
         # produced from a tarball where the package itself has not been
         # installed into anything. Revert to setup-time logic.
         try:
             from pbr import packaging
             return packaging.get_version(self.package)
         except ImportError:
             # You're killing me. We've got nothing here.
             print("Unable to import pbr, or find pkg_resources")
             print("information for %s" % self.package)
             raise
Esempio n. 8
0
 def _get_version_from_pkg_resources(self):
     """Get the version of the package from the pkg_resources record
     associated with the package.
     """
     provider = self._get_provider()
     if provider:
         return provider.version
     else:
         # The most likely cause for this is running tests in a tree
         # produced from a tarball where the package itself has not been
         # installed into anything. Revert to setup-time logic.
         try:
             from pbr import packaging
             return packaging.get_version(self.package)
         except ImportError:
             # You're killing me. We've got nothing here.
             print("Unable to import pbr, or find pkg_resources")
             print("information for %s" % self.package)
             raise
Esempio n. 9
0
 def hook(self):
     self.config['version'] = packaging.get_version(
         self.config['name'], self.config.get('version', None))
     packaging.append_text_list(
         self.config, 'requires_dist',
         packaging.parse_requirements())
Esempio n. 10
0
def _config_inited(app, config):

    # we only override configuration if the theme has been configured, meaning
    # users are using these features
    if config.html_theme not in ['otcdocs']:
        return

    if config.otcdocs_auto_name:
        project_name = _get_project_name(app.srcdir)

        if config.project and project_name:
            logger.info(
                "[otcdocstheme] "
                "overriding configured project name (%s) with name extracted "
                "from the package (%s); you can disable this behavior with "
                "the 'otcdocs_auto_name' option",
                config.project, project_name,
            )

        if project_name:
            config.project = project_name

    config.html_last_updated_fmt = '%Y-%m-%d %H:%M'

    if config.otcdocs_auto_version is False:
        logger.debug(
            '[otcdocstheme] auto-versioning disabled (configured by '
            'user)'
        )
        auto_version = False
    elif config.otcdocs_auto_version is True:
        logger.debug(
            '[otcdocstheme] auto-versioning enabled (configured by user)'
        )
        auto_version = True
    else:  # None
        doc_parts = os.path.abspath(app.srcdir).split(os.sep)[-2:]
        if doc_parts[0] in ('api-guide', 'api-ref', 'releasenotes'):
            logger.debug(
                f'[otcdocstheme] auto-versioning disabled (doc name '
                f'contains {doc_parts[0]}'
            )
            auto_version = False
        else:
            logger.debug(
                '[otcdocstheme] auto-versioning enabled (default)'
            )
            auto_version = True

    if auto_version:
        real_project_name = _get_project_name(app.srcdir)
        try:
            project_version = packaging.get_version(real_project_name)
        except Exception:
            project_version = ''

        if not project_version:
            logger.warning(
                '[otcdocstheme] could not extract version from '
                'project; defaulting to unversioned'
            )

        config.version = project_version
        config.release = project_version
Esempio n. 11
0
File: setup.py Progetto: zinic/eom
#!/usr/bin/env python
# Copyright (c) 2013 Rackspace Hosting, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.

from pbr import packaging
import setuptools

setuptools.setup(setup_requires=['d2to1>=0.2.10,<0.3', 'pbr>=0.5.16,<0.6'],
                 d2to1=True,
                 version=packaging.get_version('eom'))
Esempio n. 12
0
#!/usr/bin/env python
# Copyright (c) 2013 Rackspace Hosting, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.

from pbr import packaging
import setuptools

setuptools.setup(
    setup_requires=['d2to1>=0.2.10,<0.3', 'pbr>=0.5.16,<0.6'],
    d2to1=True,
    version=packaging.get_version('eom'))