diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5b7d43c..a9242a1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,11 +2,11 @@ default_language_version: python: python3 repos: - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 22.8.0 hooks: - id: black - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 + rev: v4.3.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -21,18 +21,18 @@ repos: - id: mixed-line-ending args: ["--fix=lf"] - repo: https://github.com/pycqa/flake8 - rev: 4.0.1 + rev: 5.0.4 hooks: - id: flake8 name: flake8 except __init__.py exclude: /__init__\.py$ - additional_dependencies: ["flake8-bugbear==20.1.4"] + additional_dependencies: ["flake8-bugbear==22.9.11"] - repo: https://github.com/asottile/pyupgrade - rev: v2.31.0 + rev: v2.38.0 hooks: - id: pyupgrade -- repo: https://github.com/pre-commit/mirrors-isort - rev: v5.10.1 +- repo: https://github.com/pycqa/isort + rev: 5.10.1 hooks: - id: isort exclude: /__init__\.py$ diff --git a/acsoo/config.py b/acsoo/config.py index b97b245..af8893e 100644 --- a/acsoo/config.py +++ b/acsoo/config.py @@ -4,8 +4,10 @@ import os from configparser import NoOptionError, NoSectionError, RawConfigParser +from pathlib import Path import click +import tomli DEFAULT_CONFIG_FILE = "acsoo.cfg" SECTION = "acsoo" @@ -31,6 +33,10 @@ def __init__(self, filename): ) self.__cfgfile = filename self.__cfg.read(filename) + pyproject_path = Path("pyproject.toml") + self.__pyproject = {} + if pyproject_path.is_file(): + self.__pyproject = tomli.loads(pyproject_path.read_text()) @staticmethod def add_default_map_reader(reader): @@ -44,20 +50,14 @@ def get_default_map(self): @property def series(self): - r = self.__cfg.get(SECTION, "series") + r = self.__pyproject.get("tool", {}).get("hatch-odoo", {}).get( + "odoo_version_override", None + ) or self.__cfg.get(SECTION, "series") if not r: - raise click.ClickException("Missing series in {}.".format(self.__cfgfile)) - if r not in ( - "8.0", - "9.0", - "10.0", - "11.0", - "12.0", - "13.0", - "14.0", - "15.0", - "16.0", - ): + raise click.ClickException( + "Odoo series not found in pyproject.toml and {}.".format(self.__cfgfile) + ) + if r not in ("14.0", "15.0", "16.0"): raise click.ClickException( "Unsupported series {} in {}.".format(r, self.__cfgfile) ) @@ -65,17 +65,20 @@ def series(self): @property def version(self): - r = self.__cfg.get(SECTION, "version") + r = self.__pyproject.get("project", {}).get("version", None) or self.__cfg.get( + SECTION, "version" + ) if not r: - raise click.ClickException("Missing version in {}.".format(self.__cfgfile)) + raise click.ClickException( + "Missing version in pyproject.toml and {}.".format(self.__cfgfile) + ) + if r.startswith(self.series + ".") and len(r.split(".")) > 4: + r = r[len(self.series) + 1 :] return r @property def trigram(self): - r = self.__cfg.get(SECTION, "trigram") - if not r: - raise click.ClickException("Missing trigram in {}.".format(self.__cfgfile)) - return r + return self.__cfg.get(SECTION, "trigram", fallback="") @property def pushable(self): diff --git a/acsoo/tag_requirements.py b/acsoo/tag_requirements.py index ad88c2e..5db6464 100644 --- a/acsoo/tag_requirements.py +++ b/acsoo/tag_requirements.py @@ -50,8 +50,8 @@ def _get_last_sha(filename): return check_output(["git", "log", "-n", "1", "--format=%h", filename]).strip() -def _has_tag_local(series, trigram, sha, repo_dir): - tag_re = re.compile(series + "[-_]" + trigram + "[-_]") +def _has_tag_local(series, sha, repo_dir): + tag_re = re.compile(series + "[-_]") tags = check_output(["git", "tag", "--points-at", sha], cwd=repo_dir) for tag in tags.split(): tag = tag.strip() @@ -60,9 +60,9 @@ def _has_tag_local(series, trigram, sha, repo_dir): return False -def _has_tag_remote(series, trigram, sha, repo_url): +def _has_tag_remote(series, sha, repo_url): prefix = "refs/tags/" - tag_re = re.compile(prefix + series + "[-_]" + trigram + "[-_]") + tag_re = re.compile(prefix + series + "[-_]") tag_lines = check_output( ["git", "ls-remote", "-t", repo_url], universal_newlines=True ) @@ -84,7 +84,7 @@ def _is_committed(requirement): def _ensure_tag(config, req, sha, repo_url, eggtag, dry_run): - ex_tag = _has_tag_remote(config.series, config.trigram, sha, repo_url) + ex_tag = _has_tag_remote(config.series, sha, repo_url) if ex_tag: click.echo("tag {ex_tag} already exists on {repo_url}@{sha}".format(**locals())) return @@ -130,7 +130,7 @@ def do_tag_requirements(config, src, requirement, yes, dry_run=False): if not os.path.isdir(os.path.join(repo_dir, ".git")): os.makedirs(repo_dir) check_call(["git", "init"], cwd=repo_dir) - ex_tag = _has_tag_local(config.series, config.trigram, sha, repo_dir) + ex_tag = _has_tag_local(config.series, sha, repo_dir) if ex_tag: # this assumes that if we find the tag locally # it is also present on the remote, in rare situations @@ -150,7 +150,7 @@ def do_tag_requirements(config, src, requirement, yes, dry_run=False): ], cwd=repo_dir, ) - ex_tag = _has_tag_local(config.series, config.trigram, sha, repo_dir) + ex_tag = _has_tag_local(config.series, sha, repo_dir) if ex_tag: click.echo("tag {ex_tag} already exists on {url}@{sha}".format(**locals())) continue diff --git a/acsoo/templates/hooks.py b/acsoo/templates/hooks.py index 9fea6f6..2823c2b 100644 --- a/acsoo/templates/hooks.py +++ b/acsoo/templates/hooks.py @@ -1,36 +1,9 @@ -import os -import shutil - -ODOO_PYTHON2 = ("8.0", "9.0", "10.0") -ODOO_KEEP_INIT_PY = ODOO_PYTHON2 -ODOO_LEGACY_NS = ("8.0", "9.0") - - def pre_render_project(configurator): variables = configurator.variables odoo_series = variables["odoo.series"] - if odoo_series in ODOO_PYTHON2: - python_version = "python" - else: - python_version = "python3" - - configurator.variables["python_version"] = python_version configurator.variables["odoo.major"] = int(odoo_series.split(".")[0]) def post_render_project(configurator): - variables = configurator.variables - root = configurator.target_directory - root = os.path.join(root, variables["project.name"]) - odoo_series = variables["odoo.series"] - if odoo_series in ODOO_LEGACY_NS: - shutil.rmtree(os.path.join(root, "odoo")) - else: - shutil.rmtree(os.path.join(root, "odoo_addons")) - - if odoo_series not in ODOO_KEEP_INIT_PY: - # Delete init file - filename = "__init__.py" - os.remove(os.path.join(root, "odoo", filename)) - os.remove(os.path.join(root, "odoo", "addons", filename)) + ... diff --git a/acsoo/templates/project/+project.name+/.bumpversion.cfg.bob b/acsoo/templates/project/+project.name+/.bumpversion.cfg.bob index d203ab5..30e52ee 100644 --- a/acsoo/templates/project/+project.name+/.bumpversion.cfg.bob +++ b/acsoo/templates/project/+project.name+/.bumpversion.cfg.bob @@ -4,18 +4,10 @@ commit = False [bumpversion:file:.bumpversion.cfg] -[bumpversion:file:acsoo.cfg] +[bumpversion:file:pyproject.toml] -{{% if odoo.series in ['8.0', '9.0'] %}} -[bumpversion:file:odoo_addons/{{{ project.trigram }}}_all/__openerp__.py] - -[bumpversion:file:odoo_addons/server_environment_files/dev/dev.conf] - -[bumpversion:file:odoo_addons/server_environment_files/test/test.conf] -{{% else %}} [bumpversion:file:odoo/addons/{{{ project.trigram }}}_all/__manifest__.py] [bumpversion:file:odoo/addons/server_environment_files/dev/dev.conf] [bumpversion:file:odoo/addons/server_environment_files/test/test.conf] -{{% endif %}} diff --git a/acsoo/templates/project/+project.name+/.coveragerc b/acsoo/templates/project/+project.name+/.coveragerc index c0e83c1..24389ff 100644 --- a/acsoo/templates/project/+project.name+/.coveragerc +++ b/acsoo/templates/project/+project.name+/.coveragerc @@ -1,4 +1,17 @@ [run] -omit= - venv* - src* +source = + ./odoo/addons +dynamic_context = test_function +branch = True +parallel = True + +[report] +omit = + */scenarios/* + */lib/* + */__manifest__.py + +# Regexes for lines to exclude from consideration +exclude_lines = + pragma: no cover + raise NotImplementedError diff --git a/acsoo/templates/project/+project.name+/.gitignore b/acsoo/templates/project/+project.name+/.gitignore index 9ec552f..024b9bc 100644 --- a/acsoo/templates/project/+project.name+/.gitignore +++ b/acsoo/templates/project/+project.name+/.gitignore @@ -1,5 +1,5 @@ /src -/release +/release*/ /.project /.settings /.pydevproject diff --git a/acsoo/templates/project/+project.name+/.gitlab-ci.yml.bob b/acsoo/templates/project/+project.name+/.gitlab-ci.yml.bob index e72a977..a4d5e83 100644 --- a/acsoo/templates/project/+project.name+/.gitlab-ci.yml.bob +++ b/acsoo/templates/project/+project.name+/.gitlab-ci.yml.bob @@ -17,11 +17,11 @@ before_script: } variables: - PYTHON: {{{ python_version }}} + PYTHON: python{{{ project.python_version }}} pre-commit: stage: test - image: python:3 + image: python:{{{ project.python_version }}} cache: key: pre-commit paths: @@ -36,17 +36,28 @@ build: stage: build # use odoo-{{{ odoo.series }}} runner so we have the pre-cloned odoo # except for that optimization, we don't need odoo dependencies for this job - image: ghcr.io/acsone/odoo-ci-image:v20210928.0 + image: ghcr.io/acsone/odoo-ci-image:v20220907.0 tags: - odoo-{{{ odoo.series }}} script: + {{% if odoo.enterprise -%}} - start_ssh_agent - - virtualenv --python=$PYTHON venv - - venv/bin/pip wheel --no-deps -r requirements.txt -e . --wheel-dir=./release + {{% endif -%}} + - virtualenv --python=$PYTHON venv && source venv/bin/activate + # install pinned build dependencies + - pip install "--only-binary=:all:" -r requirements-build.txt + # download/build all dependencies, with --no-build-isolation, + # to use the pinned build deps we just installed + - | + for group in '' '-test' '-doc' '-build' ; do + pip wheel --no-build-isolation --use-pep517 --wheel-dir=./release${group} -r requirements${group}.txt + done + # build the project + - pip wheel --no-build-isolation --no-index --no-deps --wheel-dir=./release-project . artifacts: expire_in: 1 week paths: - - release/ + - release*/ name: "${CI_PROJECT_NAME}-${CI_JOB_ID}-build" interruptible: true @@ -54,7 +65,7 @@ build: stage: test tags: - odoo-{{{ odoo.series }}} - image: ghcr.io/acsone/odoo-ci-image:v20210928.0 + image: ghcr.io/acsone/odoo-ci-image:v20220907.0 needs: - job: build artifacts: true @@ -63,45 +74,40 @@ build: license_check: extends: .test_common script: - - virtualenv --python=$PYTHON venv - - source venv/bin/activate - - pip install --no-index --find-links ./release -r requirements.txt + - virtualenv --python=$PYTHON venv && source venv/bin/activate + - pip install --no-deps --no-index ./release/*.whl - manifestoo -d odoo/addons check-licenses dev_status_check: extends: .test_common script: - - virtualenv --python=$PYTHON venv - - source venv/bin/activate - - pip install --no-index --find-links ./release -r requirements.txt + - virtualenv --python=$PYTHON venv && source venv/bin/activate + - pip install --no-deps --no-index ./release/*.whl - manifestoo -d odoo/addons check-dev-status --default-dev-status=Beta -{{% if odoo.series in ['8.0', '9.0'] %}} -{{% set odoocmd = 'openerp-server' %}} -{{% else %}} -{{% set odoocmd = 'odoo' %}} -{{% endif %}} test: extends: .test_common variables: DB_NAME: "${CI_PROJECT_NAME}-${CI_JOB_ID}" script: - pipx install acsoo # for checklog - - start_ssh_agent # for pushing translations - - virtualenv --python=$PYTHON venv - - venv/bin/pip install coverage + - virtualenv --python=$PYTHON venv && source venv/bin/activate # use --no-index so missing dependencies that would not be in *.whl are detected # install the project in editable mode (-e) so coverage sees it - - venv/bin/pip install --no-index --find-links release -e . + - pip install --no-index --find-links=./release --find-links=./release-build --find-links=./release-test -e .[test] - ADDONS_INIT=$(manifestoo -d odoo/addons list-depends --separator=,) - - echo Installing ${ADDONS_INIT} - - unbuffer venv/bin/click-odoo-initdb -c odoo-ci.cfg --new-database ${DB_NAME} --cache-prefix {{{ project.trigram }}} -m ${ADDONS_INIT} | acsoo checklog + - echo Installing dependent addons ${ADDONS_INIT} + - unbuffer click-odoo-initdb -c odoo-ci.cfg --new-database ${DB_NAME} --cache-prefix {{{ project.trigram }}} -m ${ADDONS_INIT} | acsoo checklog - ADDONS_TEST=$(manifestoo -d odoo/addons list --separator=,) - - echo Testing ${ADDONS_TEST} - - unbuffer venv/bin/coverage run --branch venv/bin/{{{ odoocmd }}} -c odoo-ci.cfg -d ${DB_NAME} --stop-after-init --no-xmlrpc -i ${ADDONS_TEST} --test-enable | acsoo checklog - - venv/bin/coverage html - - venv/bin/coverage report - - if [ "${CI_COMMIT_REF_NAME}" = "master" ] ; then makepot ; fi + - echo Installing project addons ${ADDONS_TEST} + - unbuffer coverage run venv/bin/odoo -c odoo-ci.cfg -d ${DB_NAME} --stop-after-init -i ${ADDONS_TEST} | acsoo checklog + - echo Testing project addons ${ADDONS_TEST} + - unbuffer coverage run venv/bin/odoo -c odoo-ci.cfg -d ${DB_NAME} --stop-after-init --test-tags ${ADDONS_TEST} --test-enable | acsoo checklog + - coverage combine + - coverage html --show-contexts + - coverage xml + - coverage report # Show coverage report so the GitLab coverage regex below works + - if [ "${CI_COMMIT_REF_NAME}" = "master" ] ; then start_ssh_agent ; makepot ; fi after_script: - dropdb --if-exists ${DB_NAME} coverage: '/TOTAL\s+\d+\s+\d+\s+\d+\s+\d+\s+(\d+\%)/' @@ -110,6 +116,10 @@ test: paths: - htmlcov/ name: "${CI_PROJECT_NAME}-${CI_JOB_ID}-coverage-html" + reports: + coverage_report: + coverage_format: cobertura + path: coverage.xml deploy-test: stage: deploy diff --git a/acsoo/templates/project/+project.name+/.pre-commit-config.yaml b/acsoo/templates/project/+project.name+/.pre-commit-config.yaml index a733d22..95ee357 100644 --- a/acsoo/templates/project/+project.name+/.pre-commit-config.yaml +++ b/acsoo/templates/project/+project.name+/.pre-commit-config.yaml @@ -1,19 +1,19 @@ exclude: "^(?!odoo/)|.pot$|.po$" default_language_version: python: python3 - node: "14.13.0" + node: "16.17.0" repos: - repo: https://github.com/myint/autoflake - rev: v1.4 + rev: v1.6.0 hooks: - id: autoflake args: ["-i", "--ignore-init-module-imports"] - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 22.8.0 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-prettier - rev: v2.3.0 + rev: v3.0.0-alpha.0 hooks: - id: prettier name: prettier + plugin-xml @@ -23,7 +23,7 @@ repos: args: - --plugin=@prettier/plugin-xml - repo: https://github.com/pre-commit/mirrors-eslint - rev: v7.27.0 + rev: v8.23.1 hooks: - id: eslint verbose: true @@ -31,7 +31,7 @@ repos: - --color - --fix - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.3.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -50,26 +50,22 @@ repos: - id: mixed-line-ending args: ["--fix=lf"] - repo: https://github.com/pycqa/flake8 - rev: 3.9.2 + rev: 5.0.4 hooks: - id: flake8 - name: flake8 - additional_dependencies: ["flake8-bugbear==21.4.3"] - - repo: https://github.com/pre-commit/mirrors-pylint - rev: v2.5.3 + additional_dependencies: ["flake8-bugbear==22.9.11"] + - repo: https://github.com/OCA/pylint-odoo + rev: 7.0.0 hooks: - - id: pylint - name: pylint + - id: pylint_odoo files: odoo/addons/ - args: [] - additional_dependencies: [pylint-odoo==3.7.1] - repo: https://github.com/asottile/pyupgrade - rev: v2.19.1 + rev: v2.38.0 hooks: - id: pyupgrade args: ["--py38-plus"] - - repo: https://github.com/pre-commit/mirrors-isort - rev: v5.8.0 + - repo: https://github.com/pycqa/isort + rev: 5.10.1 hooks: - id: isort name: isort except __init__.py diff --git a/acsoo/templates/project/+project.name+/README.rst.bob b/acsoo/templates/project/+project.name+/README.rst.bob index e89ff23..00dbf0a 100644 --- a/acsoo/templates/project/+project.name+/README.rst.bob +++ b/acsoo/templates/project/+project.name+/README.rst.bob @@ -11,16 +11,23 @@ Initialize virtualenv --------------------- - create and activate virtualenv, using python 3's standard `python -m venv` or possibly with virtualenvwrapper's - ``mkvirtualenv odoo-{{{ project.name }}} -a . --python=$(which {{{ python_version }}})`` + ``mkvirtualenv odoo-{{{ project.name }}} -a . --python=$(which python{{{ project.python_version }}})`` - make sure acsoo [#]_ and pip-deepfreeze [#]_ are installed and in your PATH - to save some time it is recommended to configure git-autoshare [#]_. +Pin build dependencies +---------------------- + +Use ``./sync-build.sh`` to update pinned build dependencies from +``requirements-build.txt.in`` to ``requirements-build.txt`` (empty +``requirements-build.txt`` first to update them all). + Install everything ------------------ -In an activated {{{ python_version }}} virtualenv, run:: +In an activated python{{{ project.python_version }}} virtualenv, run:: - pip-df sync + pip-df sync -x test,doc,dev When dependencies change, use ``pip-df sync`` again, possibly with ``--update``. Add unmerged VCS dependencies in ``requirements.txt.in``. See the @@ -31,11 +38,7 @@ Run Copy ``odoo.cfg.template`` to ``odoo.cfg`` and update it as needed, then run:: -{{% if odoo.series in ['8.0', '9.0'] %}} - odoo-autodiscover.py -c odoo.cfg -{{% else %}} odoo -c odoo.cfg -{{% endif %}} Develop @@ -61,5 +64,5 @@ To release using gitlab-ci .. [#] https://pypi.python.org/pypi/acsoo/#installation .. [#] https://pypi.python.org/pypi/pip-deepfreeze .. [#] https://pypi.python.org/pypi/git-autoshare -.. [#] https://github.com/ambv/black +.. [#] https://github.com/psf/black .. [#] https://github.com/pre-commit/pre-commit diff --git a/acsoo/templates/project/+project.name+/acsoo.cfg b/acsoo/templates/project/+project.name+/acsoo.cfg new file mode 100644 index 0000000..7cb7480 --- /dev/null +++ b/acsoo/templates/project/+project.name+/acsoo.cfg @@ -0,0 +1,4 @@ +# Use regular expressions to ignore Odoo warnings in CI? Be as specific as possible. +[checklog] +ignore= + addons/base/models/ir_actions_report.py.*: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead diff --git a/acsoo/templates/project/+project.name+/acsoo.cfg.bob b/acsoo/templates/project/+project.name+/acsoo.cfg.bob deleted file mode 100644 index e44eab4..0000000 --- a/acsoo/templates/project/+project.name+/acsoo.cfg.bob +++ /dev/null @@ -1,4 +0,0 @@ -[acsoo] -trigram={{{ project.trigram }}} -series={{{ odoo.series }}} -version=1.0.0 diff --git a/acsoo/templates/project/+project.name+/gitaggregate.yaml.bob b/acsoo/templates/project/+project.name+/gitaggregate.yaml.bob index a5c9932..3c63611 100644 --- a/acsoo/templates/project/+project.name+/gitaggregate.yaml.bob +++ b/acsoo/templates/project/+project.name+/gitaggregate.yaml.bob @@ -2,25 +2,26 @@ ./src/odoo-addons-enterprise: remotes: odoo: git@github.com:odoo/enterprise.git - origin: ssh://git@github.com/acsone/enterprise.git + acsone: ssh://git@github.com/acsone/enterprise.git merges: - odoo {{{ odoo.series }}} - - origin {{{ odoo.series }}}-with-setup - target: origin {{{ odoo.series }}}-{{{ project.trigram }}}_master + target: acsone {{{ odoo.series }}}-{{{ project.trigram }}}_master + shell_command_after: + # Add a pyproject.toml so pip wheel works. + - gh --repo acsone/enterprise pr diff {% if odoo.series == "16.0" %}12{% elif %}{% odoo.series == "14.0" %}11{% else %}TODO{% endif %} --patch | git am + {{% endif %}} ./src/odoo: remotes: odoo: https://github.com/odoo/odoo.git oca: https://github.com/OCA/OCB.git - origin: ssh://git@github.com/acsone/odoo.git + acsone: ssh://git@github.com/acsone/odoo.git merges: - oca {{{ odoo.series }}} - - origin {{{ odoo.series }}}-with-setup -{{% if odoo.enterprise and odoo.series == '9.0' %}} shell_command_after: - - git rm -r addons/web - - git rm openerp/addons/web - - git commit -m "remove community web addons (for use with enterprise)" addons/web openerp/addons/web -{{% endif %}} - target: origin {{{ odoo.series }}}-{{{ project.trigram }}}_master + # pyproject.toml + - curl -sSL https://github.com/odoo/odoo/pull/44001.patch | git am + # Support python -m odoo, for debugging configuration comfort. + - curl -sL https://github.com/odoo/odoo/pull/81864.patch | git am + target: acsone {{{ odoo.series }}}-{{{ project.trigram }}}_master diff --git a/acsoo/templates/project/+project.name+/odoo/__init__.py b/acsoo/templates/project/+project.name+/odoo/__init__.py deleted file mode 100644 index 5284146..0000000 --- a/acsoo/templates/project/+project.name+/odoo/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/acsoo/templates/project/+project.name+/odoo/addons/+project.trigram+_all/__manifest__.py.bob b/acsoo/templates/project/+project.name+/odoo/addons/+project.trigram+_all/__manifest__.py.bob index b2d9a56..60f5e7f 100644 --- a/acsoo/templates/project/+project.name+/odoo/addons/+project.trigram+_all/__manifest__.py.bob +++ b/acsoo/templates/project/+project.name+/odoo/addons/+project.trigram+_all/__manifest__.py.bob @@ -1,25 +1,22 @@ -{{% if odoo.series == '10.0' %}}# -*- coding: utf-8 -*-{{% endif %}} # Copyright 2020 ACSONE SA/NV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { - 'name': "{{{ project.name|capitalize }}}", - 'description': """ - Odoo aplication for {{{ project.name }}}""", - 'author': 'ACSONE SA/NV', - 'website': "http://acsone.eu", - 'category': '{{{ project.name }}}', - 'version': '{{{ odoo.series }}}.1.0.0', - 'license': 'AGPL-3', - 'depends': [ + "name": "{{{ project.name|capitalize }}}", + "description": """ + Odoo aplication for {{{ project.name|capitalize }}}""", + "author": "ACSONE SA/NV", + "website": "https://acsone.eu", + "category": "{{{ project.name }}}", + "version": "{{{ odoo.series }}}.1.0.0", + "license": "AGPL-3", + "depends": [ # {{{ project.name }}} open source addons # !!! no odoo enterprise addons dependencies !!! - # OCA/server-tools - 'mail_environment', - 'server_environment_ir_config_parameter', - # OCA/web - 'web_environment_ribbon', + # OCA + "mail_environment", + "server_environment_ir_config_parameter", + "web_environment_ribbon", ], - 'data': [ - ], - 'application': True, + "data": [], + "application": True, } diff --git a/acsoo/templates/project/+project.name+/odoo/addons/+project.trigram+_all/tests/__init__.py b/acsoo/templates/project/+project.name+/odoo/addons/+project.trigram+_all/tests/__init__.py new file mode 100644 index 0000000..9eb66b8 --- /dev/null +++ b/acsoo/templates/project/+project.name+/odoo/addons/+project.trigram+_all/tests/__init__.py @@ -0,0 +1 @@ +from . import test_dummy diff --git a/acsoo/templates/project/+project.name+/odoo/addons/+project.trigram+_all/tests/test_dummy.py b/acsoo/templates/project/+project.name+/odoo/addons/+project.trigram+_all/tests/test_dummy.py new file mode 100644 index 0000000..b926cd2 --- /dev/null +++ b/acsoo/templates/project/+project.name+/odoo/addons/+project.trigram+_all/tests/test_dummy.py @@ -0,0 +1,6 @@ +from odoo.tests.common import TransactionCase + + +class DummyTest(TransactionCase): + def test_dummy(self): + pass diff --git a/acsoo/templates/project/+project.name+/odoo/addons/__init__.py b/acsoo/templates/project/+project.name+/odoo/addons/__init__.py deleted file mode 100644 index 5284146..0000000 --- a/acsoo/templates/project/+project.name+/odoo/addons/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/acsoo/templates/project/+project.name+/odoo/addons/server_environment_files/__manifest__.py.bob b/acsoo/templates/project/+project.name+/odoo/addons/server_environment_files/__manifest__.py.bob index d7d2a21..84f44db 100644 --- a/acsoo/templates/project/+project.name+/odoo/addons/server_environment_files/__manifest__.py.bob +++ b/acsoo/templates/project/+project.name+/odoo/addons/server_environment_files/__manifest__.py.bob @@ -1,17 +1,16 @@ -{{% if odoo.series == '10.0' %}}# -*- coding: utf-8 -*-{{% endif %}} # Copyright 2020 ACSONE SA/NV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - 'name': 'Server configuration environment files', - 'description': """ + "name": "Server configuration environment files", + "description": """ Server configuration environment files""", - 'version': '{{{ odoo.series }}}.1.0.0', - 'depends': ['base'], - 'author': 'ACSONE SA/NV', - 'website': 'http://www.acsone.eu', - 'license': 'AGPL-3', - 'category': '{{{ project.name }}}', - 'data': [], - 'installable': True, + "version": "{{{ odoo.series }}}.1.0.0", + "depends": ["base"], + "author": "ACSONE SA/NV", + "website": "https://acsone.eu", + "license": "AGPL-3", + "category": "{{{ project.name }}}", + "data": [], + "installable": True, } diff --git a/acsoo/templates/project/+project.name+/odoo_addons/server_environment_files/__init__.py b/acsoo/templates/project/+project.name+/odoo_+project.name+/__init__.py similarity index 100% rename from acsoo/templates/project/+project.name+/odoo_addons/server_environment_files/__init__.py rename to acsoo/templates/project/+project.name+/odoo_+project.name+/__init__.py diff --git a/acsoo/templates/project/+project.name+/odoo_addons/+project.trigram+_all/i18n/fr.po b/acsoo/templates/project/+project.name+/odoo_+project.name+/scripts/__init__.py similarity index 100% rename from acsoo/templates/project/+project.name+/odoo_addons/+project.trigram+_all/i18n/fr.po rename to acsoo/templates/project/+project.name+/odoo_+project.name+/scripts/__init__.py diff --git a/acsoo/templates/project/+project.name+/odoo_addons/+project.trigram+_all/__init__.py b/acsoo/templates/project/+project.name+/odoo_addons/+project.trigram+_all/__init__.py deleted file mode 100644 index 1719821..0000000 --- a/acsoo/templates/project/+project.name+/odoo_addons/+project.trigram+_all/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/acsoo/templates/project/+project.name+/odoo_addons/+project.trigram+_all/__openerp__.py.bob b/acsoo/templates/project/+project.name+/odoo_addons/+project.trigram+_all/__openerp__.py.bob deleted file mode 100644 index a141f50..0000000 --- a/acsoo/templates/project/+project.name+/odoo_addons/+project.trigram+_all/__openerp__.py.bob +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -{ - 'name': "{{{ project.name }}}", - 'description': """ - Odoo aplication for {{{ project.name }}}""", - 'author': 'ACSONE SA/NV', - 'website': "http://acsone.eu", - 'category': '{{{ project.name }}}', - 'version': '{{{ odoo.series }}}.1.0.0', - 'license': 'AGPL-3', - 'depends': [ - # {{{ project.name }}} open source addons - # !!! no odoo enterprise addons dependencies !!! - # OCA/server-tools - 'base_optional_quick_create', - 'mail_environment', - 'server_environment_ir_config_parameter', - # OCA/web - 'web_dialog_size', - 'web_environment_ribbon', - 'web_sheet_full_width', - ], - 'data': [ - ], - 'application': True, -} diff --git a/acsoo/templates/project/+project.name+/odoo_addons/__init__.py b/acsoo/templates/project/+project.name+/odoo_addons/__init__.py deleted file mode 100644 index 5284146..0000000 --- a/acsoo/templates/project/+project.name+/odoo_addons/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/acsoo/templates/project/+project.name+/odoo_addons/server_environment_files/__openerp__.py.bob b/acsoo/templates/project/+project.name+/odoo_addons/server_environment_files/__openerp__.py.bob deleted file mode 100644 index ddd90f0..0000000 --- a/acsoo/templates/project/+project.name+/odoo_addons/server_environment_files/__openerp__.py.bob +++ /dev/null @@ -1,17 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2020 ACSONE SA/NV -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -{ - 'name': 'Server configuration environment files', - 'description': """ - Server configuration environment files""", - 'version': '{{{ odoo.series }}}.1.0.0', - 'depends': ['base'], - 'author': 'ACSONE SA/NV', - 'website': 'http://www.acsone.eu', - 'license': 'AGPL-3', - 'category': '{{{ project.name }}}', - 'data': [], - 'installable': True, -} diff --git a/acsoo/templates/project/+project.name+/odoo_addons/server_environment_files/default/base.conf b/acsoo/templates/project/+project.name+/odoo_addons/server_environment_files/default/base.conf deleted file mode 100644 index e69de29..0000000 diff --git a/acsoo/templates/project/+project.name+/odoo_addons/server_environment_files/dev/dev.conf b/acsoo/templates/project/+project.name+/odoo_addons/server_environment_files/dev/dev.conf deleted file mode 100644 index 97103ce..0000000 --- a/acsoo/templates/project/+project.name+/odoo_addons/server_environment_files/dev/dev.conf +++ /dev/null @@ -1,6 +0,0 @@ -[outgoing_mail] -smtp_host=localhost -smtp_port=1025 - -[ir.config_parameter] -ribbon.name=DEV 1.0.0
({db_name}) diff --git a/acsoo/templates/project/+project.name+/odoo_addons/server_environment_files/prod/prod.conf b/acsoo/templates/project/+project.name+/odoo_addons/server_environment_files/prod/prod.conf deleted file mode 100644 index cf4cace..0000000 --- a/acsoo/templates/project/+project.name+/odoo_addons/server_environment_files/prod/prod.conf +++ /dev/null @@ -1,2 +0,0 @@ -[ir.config_parameter] -ribbon.name=False diff --git a/acsoo/templates/project/+project.name+/odoo_addons/server_environment_files/test/test.conf b/acsoo/templates/project/+project.name+/odoo_addons/server_environment_files/test/test.conf deleted file mode 100644 index f833f61..0000000 --- a/acsoo/templates/project/+project.name+/odoo_addons/server_environment_files/test/test.conf +++ /dev/null @@ -1,2 +0,0 @@ -[ir.config_parameter] -ribbon.name=TEST 1.0.0
({db_name}) diff --git a/acsoo/templates/project/+project.name+/pyproject.toml.bob b/acsoo/templates/project/+project.name+/pyproject.toml.bob new file mode 100644 index 0000000..5e70b76 --- /dev/null +++ b/acsoo/templates/project/+project.name+/pyproject.toml.bob @@ -0,0 +1,54 @@ +# Use the hatchling build backend, with the hatch-odoo plugin. +[build-system] +requires = ["hatchling", "hatch-odoo"] +build-backend = "hatchling.build" + +# The standard project metadata section +# https://packaging.python.org/en/latest/specifications/declaring-project-metadata/ +[project] +name = "odoo-addons-{{{ project.name }}}" +description = "{{{ project.name|capitalize }}} Odoo Addons" +version = "{{{ odoo.series }}}.1.0.0" +readme = "README.rst" +requires-python = "=={{{ project.python_version }}}.*" +# Dependencies are dynamic because they will be generated from Odoo addons manifests. +dynamic = ["dependencies"] + +[project.optional-dependencies] +test = [ + "coverage", + "pygments", +] +doc = [] +dev = [ + "pytest", + "pytest-cov", + "pytest-odoo", + "watchdog" +] + +[project.scripts] + +[tool.hatch.build] +packages = ["odoo", "odoo_{{{ project.name }}}"] + +# Enable the hatch-odoo metadata hook to generate dependencies from addons manifests. +[tool.hatch.metadata.hooks.odoo-addons-dependencies] + +[tool.hatch-odoo] +# If our addons have non standard version numbers, let's help hatch-odoo discover the Odoo version. +odoo_version_override = "{{{ odoo.series }}}" +# Add dependencies that are not declared in Odoo addons manifests. +dependencies = [ + "click-odoo-contrib", + {{% if odoo.enterprise -%}} + # Odoo enterprise addons + "odoo-addons-enterprise", + {{% endif -%}} + # Optional Odoo dependencies not in Odoo's setup.py + "freezegun", + "num2words", + "pdfminer", + "xlrd", +] +addons_dirs = ["odoo/addons"] diff --git a/acsoo/templates/project/+project.name+/requirements-build.txt.in b/acsoo/templates/project/+project.name+/requirements-build.txt.in new file mode 100644 index 0000000..40e4a6f --- /dev/null +++ b/acsoo/templates/project/+project.name+/requirements-build.txt.in @@ -0,0 +1,7 @@ +# build dependencies for building the project and all its dependencies +# that need to be built from sources +hatchling +hatch-odoo +setuptools +setuptools-odoo +wheel diff --git a/acsoo/templates/project/+project.name+/requirements.txt.in.bob b/acsoo/templates/project/+project.name+/requirements.txt.in.bob index f4c54e8..77eb723 100644 --- a/acsoo/templates/project/+project.name+/requirements.txt.in.bob +++ b/acsoo/templates/project/+project.name+/requirements.txt.in.bob @@ -2,16 +2,13 @@ # odoo -r https://raw.githubusercontent.com/odoo/odoo/{{{ odoo.series }}}/requirements.txt -git+https://github.com/acsone/odoo.git@{{{ odoo.series }}}-{{{ project.trigram }}}_master#egg=odoo +odoo @ git+https://github.com/acsone/odoo.git@{{{ odoo.series }}}-{{{ project.trigram }}}_master {{% if odoo.enterprise %}} -git+ssh://git@github.com/acsone/enterprise.git@{{{ odoo.series }}}-{{{ project.trigram }}}_master#egg=odoo-addons-enterprise&subdirectory=setup -{{% endif %}} -{{% if odoo.major <= 10 %}} -odoo-autodiscover>=2.0 +egg=odoo-addons-enterprise @ git+ssh://git@github.com/acsone/enterprise.git@{{{ odoo.series }}}-{{{ project.trigram }}}_master {{% endif %}} # patched ACSONE addons # ... # patched OCA addons -# odoo{short_version}-addon-{addon} @ git+https://github.com/acsone/{oca-project}.git@{{{ odoo.series }}}-{{{ project.trigram }}}_master#subdirectory=setup/{addon} +# odoo-addon-{addon} @ git+https://github.com/acsone/{oca-project}.git@{{{ odoo.series }}}-{{{ project.trigram }}}_master#subdirectory=setup/{addon} diff --git a/acsoo/templates/project/+project.name+/setup.py.bob b/acsoo/templates/project/+project.name+/setup.py.bob deleted file mode 100644 index 46b3d09..0000000 --- a/acsoo/templates/project/+project.name+/setup.py.bob +++ /dev/null @@ -1,20 +0,0 @@ -from configparser import ConfigParser -from setuptools import setup - - -cfg = ConfigParser() -cfg.read('acsoo.cfg') - - -setup( - version=cfg.get('acsoo', 'series') + '.' + cfg.get('acsoo', 'version'), - name='odoo-addons-{{{ project.name }}}', - description='{{{ project.name|capitalize }}} Odoo Addons', - setup_requires=['setuptools-odoo'], - install_requires=[ - 'click-odoo-contrib>=1.4.1', - 'xlrd', - {{% if odoo.enterprise %}}'odoo-addons-enterprise',{{% endif -%}} - ], - odoo_addons=True, -) diff --git a/acsoo/templates/project/+project.name+/sync-build.sh b/acsoo/templates/project/+project.name+/sync-build.sh new file mode 100755 index 0000000..eb77763 --- /dev/null +++ b/acsoo/templates/project/+project.name+/sync-build.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Pin build dependencies from requirements-build.txt.in. + +set -e +VENV_DIR=$(mktemp -d) +trap "rm -rf $VENV_DIR" EXIT +python3 -m venv $VENV_DIR +source $VENV_DIR/bin/activate +if [ -f requirements-build.txt ] ; then + CONSTRAINTS="-c requirements-build.txt" +else + CONTRAINTS="" +fi +pip install -r requirements-build.txt.in $CONTRAINTS +pip freeze --all | grep -v "^pip==" > requirements-build.txt diff --git a/acsoo/templates/project/.mrbob.ini b/acsoo/templates/project/.mrbob.ini index 4b3a232..ea2cb98 100644 --- a/acsoo/templates/project/.mrbob.ini +++ b/acsoo/templates/project/.mrbob.ini @@ -5,8 +5,11 @@ project.name.required = True project.trigram.question = Project trigram (3 lowercase letters) project.trigram.required = True -odoo.series.question = Odoo series (8.0, 9.0, 10.0, 11.0, 13.0, 14.0, 15.0, 16.0) -odoo.series.default = 14.0 +project.python_version.question = Python version (3.8, 3.9, 3.10) +project.python_version.required = True + +odoo.series.question = Odoo series (14.0, 15.0, 16.0) +odoo.series.default = 16.0 odoo.series.required = True odoo.enterprise.question = Odoo Enterprise diff --git a/acsoo/tools.py b/acsoo/tools.py index 346a8a3..c154079 100644 --- a/acsoo/tools.py +++ b/acsoo/tools.py @@ -42,8 +42,8 @@ def call(cmd, cwd=None, log_level=logging.DEBUG, echo=False): log_cmd(cmd, cwd=cwd, level=log_level, echo=echo) try: return subprocess.call(cmd, cwd=cwd) - except subprocess.CalledProcessError: - raise click.ClickException(cmd_string(cmd)) + except subprocess.CalledProcessError as e: + raise click.ClickException(cmd_string(cmd)) from e def check_call(cmd, cwd=None, log_level=logging.DEBUG, echo=False): @@ -51,8 +51,8 @@ def check_call(cmd, cwd=None, log_level=logging.DEBUG, echo=False): log_cmd(cmd, cwd=cwd, level=log_level, echo=echo) try: return subprocess.check_call(cmd, cwd=cwd) - except subprocess.CalledProcessError: - raise click.ClickException(cmd_string(cmd)) + except subprocess.CalledProcessError as e: + raise click.ClickException(cmd_string(cmd)) from e def check_output( @@ -64,8 +64,8 @@ def check_output( return subprocess.check_output( cmd, cwd=cwd, universal_newlines=universal_newlines ) - except subprocess.CalledProcessError: - raise click.ClickException(cmd_string(cmd)) + except subprocess.CalledProcessError as e: + raise click.ClickException(cmd_string(cmd)) from e @contextlib.contextmanager diff --git a/setup.cfg b/setup.cfg index 6174436..dfdd533 100644 --- a/setup.cfg +++ b/setup.cfg @@ -29,6 +29,7 @@ install_requires = setuptools # must use odoo-autodiscover>=2 in Odoo<=10 wheel>=0.29 httpx + tomli [options.entry_points] console_scripts = diff --git a/tests/data/test1.cfg b/tests/data/test1.cfg index 724271c..f889150 100644 --- a/tests/data/test1.cfg +++ b/tests/data/test1.cfg @@ -1,5 +1,5 @@ [acsoo] -series=10.0 +series=16.0 trigram=xyz version=1.1.0 diff --git a/tests/test_config.py b/tests/test_config.py index a6c6be7..e525782 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -33,7 +33,7 @@ def test1(self): def test2(self): assert self.config.trigram == "xyz" assert self.config.version == "1.1.0" - assert self.config.series == "10.0" + assert self.config.series == "16.0" def test_default_map(self): default_map = self.config.get_default_map() diff --git a/tox.ini b/tox.ini index ed549e8..c5cbec1 100644 --- a/tox.ini +++ b/tox.ini @@ -21,7 +21,7 @@ python = [testenv] usedevelop = True -commands = py.test --cov-config=.coveragerc --cov=acsoo --cov-branch --ignore=tests/data {posargs} +commands = py.test --cov-config=.coveragerc --cov=acsoo --cov-branch --ignore=tests/data ./tests {posargs} deps = -r test-requirements.txt [testenv:twine_check]