Beispiel #1
0
def _get_version(
    addon_dir,
    manifest,
    odoo_version_override=None,
    git_post_version=True,
    post_version_strategy_override=None,
):
    """ Get addon version information from an addon directory """
    version = manifest.get("version")
    if not version:
        warn("No version in manifest in %s" % addon_dir)
        version = "0.0.0"
    if not odoo_version_override:
        if len(version.split(".")) < 5:
            raise DistutilsSetupError("Version in manifest must have at least "
                                      "5 components and start with "
                                      "the Odoo series number in %s" %
                                      addon_dir)
        odoo_version = ".".join(version.split(".")[:2])
    else:
        odoo_version = odoo_version_override
    if odoo_version not in ODOO_VERSION_INFO:
        raise DistutilsSetupError("Unsupported odoo version '{}' in {}".format(
            odoo_version, addon_dir))
    odoo_version_info = ODOO_VERSION_INFO[odoo_version]
    if git_post_version:
        version = get_git_postversion(
            addon_dir,
            post_version_strategy_override
            or odoo_version_info["git_postversion_strategy"],
        )
    return version, odoo_version, odoo_version_info
Beispiel #2
0
def _get_version(addon_dir,
                 manifest,
                 odoo_version_override=None,
                 git_post_version=True):
    """ Get addon version information from an addon directory """
    version = manifest.get('version')
    if not version:
        warn("No version in manifest in %s" % addon_dir)
        version = '0.0.0'
    if not odoo_version_override:
        if len(version.split('.')) < 5:
            raise DistutilsSetupError("Version in manifest must have at least "
                                      "5 components and start with "
                                      "the Odoo series number in %s" %
                                      addon_dir)
        odoo_version = '.'.join(version.split('.')[:2])
    else:
        odoo_version = odoo_version_override
    if odoo_version not in ODOO_VERSION_INFO:
        raise DistutilsSetupError("Unsupported odoo version '%s' in %s" %
                                  (odoo_version, addon_dir))
    odoo_version_info = ODOO_VERSION_INFO[odoo_version]
    if git_post_version:
        version = get_git_postversion(addon_dir)
    return version, odoo_version, odoo_version_info
Beispiel #3
0
def prepare_odoo_addon(
    depends_override=None,
    external_dependencies_override=None,
    odoo_version_override=None,
):
    addons_dir, addons_ns = _find_addons_dir()
    potential_addons = os.listdir(addons_dir)
    # list installable addons, except auto-installable ones
    # in case we want to combine an addon and it's glue modules
    # in a package named after the main addon
    addons = [
        a for a in potential_addons
        if is_installable_addon(os.path.join(addons_dir, a),
                                unless_auto_installable=True)
    ]
    if len(addons) == 0:
        # if no addon is found, it may mean we are trying to package
        # a single module that is marked auto-install, so let's try
        # listing all installable modules
        addons = [
            a for a in potential_addons
            if is_installable_addon(os.path.join(addons_dir, a))
        ]
    if len(addons) != 1:
        raise DistutilsSetupError("%s must contain exactly one "
                                  "installable Odoo addon dir, found %s" %
                                  (os.path.abspath(addons_dir), addons))
    addon_name = addons[0]
    addon_dir = os.path.join(addons_dir, addon_name)
    return get_addon_setuptools_keywords(
        addon_dir,
        depends_override,
        external_dependencies_override,
        odoo_version_override,
    )
Beispiel #4
0
def prepare_odoo_addon(depends_override={},
                       external_dependencies_override={},
                       odoo_version_override=None):
    addons_dir, addons_ns = _find_addons_dir()
    potential_addons = os.listdir(addons_dir)
    # list installable addons, except auto-installable ones
    # in case we want to combine an addon and it's glue modules
    # in a package named after the main addon
    addons = [
        a for a in potential_addons
        if is_installable_addon(os.path.join(addons_dir, a),
                                unless_auto_installable=True)
    ]
    if len(addons) == 0:
        # if no addon is found, it may mean we are trying to package
        # a single module that is marked auto-install, so let's try
        # listing all installable modules
        addons = [
            a for a in potential_addons
            if is_installable_addon(os.path.join(addons_dir, a))
        ]
    if len(addons) != 1:
        raise DistutilsSetupError('%s must contain exactly one '
                                  'installable Odoo addon dir, found %s' %
                                  (os.path.abspath(addons_dir), addons))
    addon_name = addons[0]
    addon_dir = os.path.join(addons_dir, addon_name)
    manifest = read_manifest(addon_dir)
    version, odoo_version_info = _get_version(addon_dir,
                                              manifest,
                                              odoo_version_override,
                                              git_post_version=True)
    install_requires = get_install_requires_odoo_addon(
        addon_dir,
        depends_override=depends_override,
        external_dependencies_override=external_dependencies_override,
        odoo_version_override=odoo_version_override,
    )
    setup_keywords = {
        'name': make_pkg_name(odoo_version_info, addon_name, False),
        'version': version,
        'description': _get_description(addon_dir, manifest),
        'long_description': _get_long_description(addon_dir, manifest),
        'url': manifest.get('website'),
        'license': manifest.get('license'),
        'packages': setuptools.find_packages(),
        'include_package_data': True,
        'namespace_packages': _ns_to_namespace_packages(addons_ns),
        'zip_safe': False,
        'install_requires': install_requires,
        'author': _get_author(manifest),
        'author_email': _get_author_email(manifest),
        'classifiers': _make_classifiers(manifest)
        # TODO: more classifiers: development status, ...
        # TODO: keywords
    }
    # import pprint; pprint.pprint(setup_keywords)
    return {k: v for k, v in setup_keywords.items() if v is not None}
Beispiel #5
0
def _get_odoo_version_info(addons_dir, odoo_version_override=None):
    """ Detect Odoo version from an addons directory """
    odoo_version_info = None
    addons = os.listdir(addons_dir)
    for addon in addons:
        addon_dir = os.path.join(addons_dir, addon)
        if is_installable_addon(addon_dir):
            manifest = read_manifest(addon_dir)
            _, addon_odoo_version_info = _get_version(
                addon_dir, manifest, odoo_version_override,
                git_post_version=False)
            if odoo_version_info is not None and \
                    odoo_version_info != addon_odoo_version_info:
                raise DistutilsSetupError("Not all addons are for the same "
                                          "odoo version in %s (error detected "
                                          "in %s)" % (addons_dir, addon))
            odoo_version_info = addon_odoo_version_info
    return odoo_version_info
Beispiel #6
0
    def finalize_options(self):
        self.proto = self.distribution.x_proto or ()

        self.set_undefined_options(
            'build',
            ('build_temp', 'build_temp'),
            ('build_lib', 'build_lib'),
        )
        self.set_undefined_options(
            'build_ext',
            ('inplace', 'inplace'),
        )

        from os.path import isfile
        if self.protoc and not isfile(self.protoc):
            from distutils.spawn import find_executable
            self.protoc = find_executable(self.protoc)
        if not self.protoc:
            raise DistutilsSetupError("Unable to find 'protoc'")