Skip to content

Commit 341984f

Browse files
committed
feat: prioritize extra requirements
Odoo 13.0 requires vatnumber==1.2.0 that still needs use_2to3. Meanwhile [setuptools>=58.0.0 breaks support for use_2to3](https://stackoverflow.com/questions/69100275/error-while-downloading-the-requirements-using-pip-install-setup-command-use-2) so we need to fall back to setuptools<58.0.0. This commit prioritizes installing extra requirements to support that.
1 parent a30b955 commit 341984f

2 files changed

Lines changed: 38 additions & 16 deletions

File tree

odoo_venv/assets/presets.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ greenlet==1.1.2; sys_platform != 'win32' and python_version == '3.10'
5050
"""
5151
extra_requirement = """
5252
gevent==22.10.2; sys_platform != 'win32' and python_version == '3.10',
53-
greenlet==2.0.2; sys_platform != 'win32' and python_version == '3.10'
53+
greenlet==2.0.2; sys_platform != 'win32' and python_version == '3.10',
54+
setuptools<58.0.0
5455
"""
5556

5657
# always ignore those exotic requirements unless explicitely added

odoo_venv/main.py

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ def _process_requirement_line(
8787
ignored_req_map: dict,
8888
tmp_file,
8989
target_env_for_markers: dict[str, str],
90+
run_now: bool = False,
91+
venv_dir: Path | None = None,
92+
verbose: bool = False,
93+
dry_run: bool = False,
9094
) -> bool:
9195
req_line = req_line.strip()
9296
if not req_line or req_line.startswith("#"):
@@ -110,6 +114,14 @@ def _process_requirement_line(
110114

111115
if should_ignore:
112116
return False
117+
elif run_now:
118+
_run_command(
119+
["uv", "pip", "install", valid_line],
120+
venv_dir=venv_dir,
121+
verbose=verbose,
122+
dry_run=dry_run,
123+
)
124+
return True
113125
else:
114126
tmp_file.write(valid_line + "\n")
115127
return True
@@ -182,20 +194,7 @@ def create_odoo_venv( # noqa: C901
182194
f" ✔ Virtual environment created at {typer.style(str(venv_dir), fg=typer.colors.YELLOW)}",
183195
)
184196

185-
# 3. Install Odoo in editable mode
186-
if install_odoo:
187-
typer.secho("\nInstalling Odoo in editable mode...")
188-
_run_command(
189-
["uv", "pip", "install", "-e", f"file://{odoo_dir}#egg=odoo"],
190-
venv_dir=venv_dir,
191-
verbose=verbose,
192-
dry_run=dry_run,
193-
)
194-
typer.secho(
195-
" ✔ Installed Odoo in editable mode",
196-
)
197-
198-
# 4. Install requirements
197+
# 3. Install requirements
199198
all_req_files = []
200199
if install_odoo_requirements:
201200
odoo_reqs_file = odoo_dir / "requirements.txt"
@@ -245,7 +244,16 @@ def create_odoo_venv( # noqa: C901
245244

246245
if extra_requirements:
247246
for req_line in extra_requirements:
248-
if _process_requirement_line(req_line, ignored_req_map, tmp, target_env_for_markers):
247+
if _process_requirement_line(
248+
req_line,
249+
ignored_req_map,
250+
tmp,
251+
target_env_for_markers,
252+
run_now=True,
253+
venv_dir=venv_dir,
254+
verbose=verbose,
255+
dry_run=dry_run,
256+
):
249257
req_count += 1
250258

251259
if extra_requirements_file:
@@ -301,6 +309,19 @@ def create_odoo_venv( # noqa: C901
301309
_run_command(install_args, venv_dir=venv_dir, verbose=False, dry_run=dry_run)
302310
typer.secho(f" ✔ {typer.style(req_count, fg=typer.colors.YELLOW)} Packages installed successfully")
303311

312+
# 4. Install Odoo in editable mode
313+
if install_odoo:
314+
typer.secho("\nInstalling Odoo in editable mode...")
315+
_run_command(
316+
["uv", "pip", "install", "-e", f"file://{odoo_dir}#egg=odoo"],
317+
venv_dir=venv_dir,
318+
verbose=verbose,
319+
dry_run=dry_run,
320+
)
321+
typer.secho(
322+
" ✔ Installed Odoo in editable mode",
323+
)
324+
304325
os.remove(tmp_path)
305326

306327
typer.secho("\n✅ Environment setup complete!", fg=typer.colors.GREEN)

0 commit comments

Comments
 (0)