Skip to content

Commit 4dc6abc

Browse files
committed
[ADD] pyproject to build OCA's python environement for the Odoo instance
1 parent 7e6469b commit 4dc6abc

6 files changed

Lines changed: 2300 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,4 @@ docs/_build/
8686

8787
# OCA rules
8888
!static/lib/
89+
src/

CONTRIBUTE.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Contribute to the OCA's Odoo instance
2+
3+
This guide aims to help happy volunteers to contribute to the OCA's Odoo instance. I
4+
suppose mainly the OCA's Internal Tools team.
5+
6+
It's split into 3 sections:
7+
8+
- [Concepts](#concepts): Main concepts to understand and general organization
9+
- [Processes](#processes): Helping doing the work without missing crucial steps
10+
- [HowTos](#howto): How to do specific tasks
11+
12+
## Concepts
13+
14+
This repository is setup as other OCA's repositories to launch CI as usual and as an
15+
extra configuration in order to realease the OCA' Docker image used by our Odoo
16+
instance.
17+
18+
Managing and freezing modules versions rely on python tools:
19+
20+
- [uv](https://docs.astral.sh/uv/)
21+
- [hatch-odoo](https://pypi.org/project/hatch-odoo/)
22+
23+
## Processes
24+
25+
Here we focus on what to do without explaining how to do it.
26+
27+
## HowTos
28+
29+
Here we focus on how to do it, it's a suggest way to works but feel free to use your own
30+
way.
31+
32+
### Setup developer environment
33+
34+
Requirements:
35+
36+
- Postrgesql
37+
- [uv](https://docs.astral.sh/uv/)
38+
- Some dependencies to be able to build some python packages: `libpq-dev`,
39+
`build-essential`, TODO
40+
41+
Prepare a python virtual environment and install the required dependencies:
42+
43+
```bash
44+
uv sync
45+
```
46+
47+
### Setup database and launch tests
48+
49+
- setup database with demo data and all oca modules installed
50+
51+
```bash
52+
uv run odoo -d oca-custom -i oca_all --stop-after-init --without-de
53+
```
54+
55+
- run tests using pytest launcher
56+
57+
````bash
58+
uv run pytest --odoo-database oca-custom --cov ./oca_psc_team/ oca_psc_team/
59+
``
60+
61+
### Update OCB Branch
62+
63+
```bash
64+
uvx --from git-aggregator gitaggregate -c repos.yaml -d ./src/ocb -p
65+
uv sync -P odoo
66+
````
67+
68+
### Update a specific OCA module dependency using the latest pypi release
69+
70+
```bash
71+
uv sync -P odoo14-addon-<module-name>
72+
```
73+
74+
### Bump all dependencies to the latest version
75+
76+
```bash
77+
uv sync -U
78+
```

pyproject.toml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
[build-system]
2+
requires = ["hatchling", "hatch-odoo"]
3+
build-backend = "hatchling.build"
4+
5+
6+
[project]
7+
name = "oca-custom"
8+
version = "0.1.0"
9+
description = "Odoo by OCA"
10+
# readme = "README.md"
11+
requires-python = "==3.9.*"
12+
dynamic = ["dependencies"]
13+
14+
[tool.hatch.build]
15+
packages = ["./"]
16+
17+
# Enable the hatch-odoo metadata hook to generate dependencies from addons manifests.
18+
[tool.hatch.metadata.hooks.odoo-addons-dependencies]
19+
# Enable the hatch-odoo build hook to locate the Odoo addons and package them in odoo/addons.
20+
# if not provided, "locals" modules (those in './') are not found and cannot be installed...
21+
[tool.hatch.build.hooks.odoo-addons-dirs]
22+
23+
[tool.hatch-odoo]
24+
# dependencies that are not in the addons manifest
25+
dependencies = [
26+
"odoo==14.0.*",
27+
# indirect unrealeased dependencies
28+
"odoo-addons-design-themes==14.0.*",
29+
# Add some constraints to Odoo deps that should be in their setup.py
30+
"Babel==2.9.1",
31+
"chardet==3.0.4",
32+
"decorator==4.3.0",
33+
"docutils==0.14",
34+
"ebaysdk==2.1.5",
35+
"freezegun==0.3.15",
36+
"gevent==20.9.0 ",
37+
# gevent==21.8.0 ",
38+
"greenlet==1.1.2",
39+
"idna==2.6",
40+
"Jinja2==2.11.2",
41+
"libsass>=0.18.0",
42+
"lxml==4.6.5",
43+
"Mako==1.0.7",
44+
"MarkupSafe==1.1.0",
45+
"num2words==0.5.6",
46+
"ofxparse==0.19",
47+
# ofxparse==0.21",
48+
"passlib==1.7.1",
49+
"Pillow==8.1.1",
50+
"polib==1.1.0",
51+
"psutil==5.6.6",
52+
"psycopg2==2.9.10",
53+
"pydot==1.4.1",
54+
"PyPDF2==1.26.0",
55+
"pyserial==3.4",
56+
"python-dateutil==2.7.3",
57+
"pytz",
58+
"pyusb==1.0.2",
59+
"qrcode==6.1",
60+
"reportlab==3.5.55",
61+
"requests==2.21.0",
62+
# requests==2.25.1; python_version > '3.9' # (Jammy) versions < 2.25 aren't compatible w/ urllib3 1.26. Bullseye = 2.25.1. min version = 2.22.0 (Focal)",
63+
# urllib3==1.26.5; python_version > '3.9' # (Jammy) indirect / min version = 1.25.8 (Focal with security backports)",
64+
"zeep==3.2.0",
65+
"python-stdnum==1.8",
66+
"vobject==0.9.6.1",
67+
"Werkzeug==0.16.1 ",
68+
# Werkzeug==2.0.2 ; python_version > '3.9' # (Jammy)",
69+
"XlsxWriter==1.1.2",
70+
"xlwt==1.3.*",
71+
"xlrd==1.2.0",
72+
# TODO: add constraints in github connector module
73+
"PyGithub<2.0.0",
74+
]
75+
addons_dirs = ["./"]
76+
77+
[tool.uv]
78+
# On OCA 14.0 series translations commits are realeased
79+
# in pre-release state
80+
prerelease = "allow"
81+
# tell uv when dependencies may change
82+
cache-keys = [
83+
{ file = "pyproject.toml" },
84+
{ file = "**/__manifest__.py" },
85+
]
86+
87+
dev-dependencies = [
88+
"parameterized>=0.9.0",
89+
"pytest>8",
90+
"pytest-odoo>=2",
91+
"pytest-cov>=5.0.0",
92+
"pytest-xdist>=3.6.1",
93+
"manifestoo>=1.0",
94+
"odoo-test-helper",
95+
"websocket-client",
96+
]
97+
98+
99+
[tool.uv.sources]
100+
odoo = { git = "https://github.com/OCA/OCB", branch = "14.0" }
101+
odoo-addons-design-themes = { git = "https://github.com/petrus-v/design-themes", branch = "14.0-oca-20250317" }
102+
103+
odoo14-addon-membership-delegated-partner-line = { git = "https://github.com/OCA/vertical-association", rev = "refs/pull/151/head", subdirectory = "setup/membership_delegated_partner_line" }
104+
105+
106+
[tool.pytest]
107+
addopts = "-v -s --cov-report term-missing"
108+
109+
[tool.coverage.run]
110+
branch = true
111+
omit = [
112+
"./**/tests/*",
113+
"./**/__manifest__.py",
114+
]

repos.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
./src/design-themes:
2+
defaults:
3+
refmap: "14.0"
4+
remotes:
5+
odoo: https://github.com/odoo/design-themes
6+
acsone: https://github.com/acsone/design-themes
7+
petrus-v: git@github.com:petrus-v/design-themes
8+
merges:
9+
- odoo 14.0
10+
- acsone 14.0-with-pyproject
11+
target: petrus-v 14.0-oca-20250317

test-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
# While running tests, coverage is trying to read configuration in pyproject.toml
2+
coverage[toml]
13
odoo14-addon-membership-delegated-partner-line @ git+https://github.com/OCA/vertical-association@refs/pull/151/head#subdirectory=setup/membership_delegated_partner_line

0 commit comments

Comments
 (0)