Git Product home page Git Product logo

hatch-odoo's Introduction

hatch-odoo

PyPI - Version PyPI - Python Version


A hatch(ling) plugin to work with projects containing Odoo addons. This tool will help you package a project containing Odoo addons so it can be installed with pip:

  • automatically generates dependencies based on Odoo addons manifests,
  • package addons into the odoo/addons namespace independently of the source project layout,
  • install the addons in editable mode without fiddling with --addons-path,

Table of Contents

Quick start

Assuming you have a project containing your awesome Odoo addons at the root of your project repository, you can set it up by creating a pyproject.toml file like so.

# Use the hatchling build backend, with the hatch-odoo plugin.
[build-system]
requires = ["hatchling", "hatch-odoo"]
build-backend = "hatchling.build"

[project]
name = "MyAwesomeProject"
version = "1.0"
readme = "README.md"
requires-python = ">=3.8"
# Dependencies are dynamic because they will be generated from Odoo addons manifests.
dynamic = ["dependencies"]

# Enable the hatch-odoo metadata hook to generate dependencies from addons manifests.
[tool.hatch.metadata.hooks.odoo-addons-dependencies]
# Enable the hatch-odoo build hook to package the Odoo addons into odoo/addons.
[tool.hatch.build.hooks.odoo-addons-dirs]

[tool.hatch-odoo]
# If our addons have non standard version numbers, let's help hatch-odoo discover the Odoo version.
odoo_version_override = "15.0"
# Let's add additional dependencies that are not declared in addons manifests.
dependencies = ["click-odoo-contrib"]
# Our addons are in the project root directory.
addons_dirs = ["."]

You can then install it in editable mode, together with its dependencies in a virtual environment with a procedure like this:

# python3 -m venv .venv
# source .venv/bin/activate
# pip install --upgrade pip setuptools wheel
# pip install -r https://raw.githubusercontent.com/odoo/odoo/15.0/requirements.txt
# pip install -e git+https://github.com/odoo/[email protected]
# pip install -e .
# odoo

All dependencies (such as OCA addons and external dependencies) declared in your project addons manifests will be downloaded and installed from PyPI automatically.

There is no need to configure the Odoo addons path: since addons are installed in odoo/addons, the regular Python import machinery works out of the box

You can then pin dependencies for reproducibility with pip freeze or other tools. pip-deepfreeze is known to work well with git URLs, but other tools such as pip-tools, may work as well.

Alternative project layouts

Depending on your taste and requirements, there are several alternative ways to organize your source code. The test projects in tests/data each have a README that describe the layout and corresponding tradeoffs, with the corresponding pyproject.toml.

License

hatch-odoo is distributed under the terms of the MIT license.

hatch-odoo's People

Contributors

pre-commit-ci[bot] avatar sbidoul avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.