odoo-dev 0.1.0__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
odoo_dev/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """Odoo Development Environment Helper."""
2
2
 
3
- __version__ = "0.1.0"
3
+ __version__ = "0.2.0"
@@ -1,21 +1,91 @@
1
1
  """Setup commands for initializing Odoo development environment."""
2
2
 
3
+ import os
3
4
  import subprocess
4
5
  from pathlib import Path
5
- from typing import Annotated
6
6
 
7
7
  import typer
8
8
 
9
- from odoo_dev.config import load_config
10
- from odoo_dev.utils.console import error, success, warning
9
+ from odoo_dev.config import (
10
+ DEFAULT_ODOO_VERSION,
11
+ DEFAULT_PYTHON_VERSION,
12
+ find_project_root,
13
+ load_config,
14
+ load_dotenv,
15
+ )
16
+ from odoo_dev.utils.console import info, success, warning
17
+
18
+
19
+ def _prompt_for_versions() -> None:
20
+ """Prompt for ODOO_VERSION and PYTHON_VERSION if not set.
21
+
22
+ Checks environment and .env file. If not found, prompts interactively
23
+ and optionally saves to .env.
24
+ """
25
+ project_dir = find_project_root()
26
+ env_file = project_dir / ".env"
27
+
28
+ # Load existing .env
29
+ load_dotenv(env_file)
30
+
31
+ odoo_version = os.getenv("ODOO_VERSION")
32
+ python_version = os.getenv("PYTHON_VERSION")
33
+
34
+ updates = {}
35
+
36
+ if not odoo_version:
37
+ odoo_version = typer.prompt(
38
+ "Odoo version",
39
+ default=DEFAULT_ODOO_VERSION,
40
+ )
41
+ os.environ["ODOO_VERSION"] = odoo_version
42
+ updates["ODOO_VERSION"] = odoo_version
43
+
44
+ if not python_version:
45
+ python_version = typer.prompt(
46
+ "Python version",
47
+ default=DEFAULT_PYTHON_VERSION,
48
+ )
49
+ os.environ["PYTHON_VERSION"] = python_version
50
+ updates["PYTHON_VERSION"] = python_version
51
+
52
+ # Offer to save to .env if we prompted for anything
53
+ if updates:
54
+ if typer.confirm("Save these settings to .env?", default=True):
55
+ _update_env_file(env_file, updates)
56
+ success(f"Settings saved to {env_file}")
57
+
58
+
59
+ def _update_env_file(env_file: Path, updates: dict[str, str]) -> None:
60
+ """Update or create .env file with new values."""
61
+ existing = {}
62
+
63
+ if env_file.exists():
64
+ for line in env_file.read_text().splitlines():
65
+ line = line.strip()
66
+ if line and not line.startswith("#") and "=" in line:
67
+ key, _, value = line.partition("=")
68
+ existing[key.strip()] = value.strip()
69
+
70
+ # Merge updates
71
+ existing.update(updates)
72
+
73
+ # Write back
74
+ content = "\n".join(f"{k}={v}" for k, v in sorted(existing.items()))
75
+ env_file.write_text(content + "\n")
11
76
 
12
77
 
13
78
  def setup(
14
79
  community: bool = typer.Option(
15
- False, "--community", help="Set up Community edition only (skip Enterprise repos)"
80
+ False,
81
+ "--community",
82
+ help="Set up Community edition only (skip Enterprise repos)",
16
83
  ),
17
84
  ) -> None:
18
85
  """Complete setup: clone Odoo repos, configure VSCode, build image."""
86
+ # Prompt for versions if not configured
87
+ _prompt_for_versions()
88
+
19
89
  cfg = load_config()
20
90
 
21
91
  success("Setting up complete Odoo development environment...")
@@ -34,7 +104,9 @@ def setup(
34
104
 
35
105
  # Set up local virtual environment
36
106
  success("\nSetting up local Python virtual environment...")
37
- warning(f"This will install system dependencies and Python {cfg.python_version} if needed")
107
+ warning(
108
+ f"This will install system dependencies and Python {cfg.python_version} if needed"
109
+ )
38
110
  setup_venv()
39
111
 
40
112
  # Prompt for Docker setup
@@ -42,6 +114,7 @@ def setup(
42
114
  if typer.confirm("Continue with Docker setup?", default=True):
43
115
  success("\nBuilding Docker image...")
44
116
  from odoo_dev.commands.docker import build
117
+
45
118
  build(community=community)
46
119
  else:
47
120
  warning("Skipping Docker setup. Run 'odoo-dev build' later.")
@@ -72,7 +145,9 @@ def setup_venv() -> None:
72
145
  stdout=subprocess.PIPE,
73
146
  )
74
147
  # Would pipe to sh, but let's be explicit
75
- warning("Please install uv manually: curl -LsSf https://astral.sh/uv/install.sh | sh")
148
+ warning(
149
+ "Please install uv manually: curl -LsSf https://astral.sh/uv/install.sh | sh"
150
+ )
76
151
 
77
152
  # Create virtual environment
78
153
  if not cfg.venv_path.exists():
@@ -88,7 +163,13 @@ def setup_venv() -> None:
88
163
  _update_python_path(cfg)
89
164
 
90
165
  # Install requirements
91
- venv_pip = ["uv", "pip", "install", "--python", str(cfg.venv_path / "bin" / "python")]
166
+ venv_pip = [
167
+ "uv",
168
+ "pip",
169
+ "install",
170
+ "--python",
171
+ str(cfg.venv_path / "bin" / "python"),
172
+ ]
92
173
 
93
174
  # Install Odoo requirements
94
175
  odoo_requirements = cfg.project_dir / "odoo" / "requirements.txt"
@@ -110,7 +191,9 @@ def setup_venv() -> None:
110
191
 
111
192
  # Install dev tools
112
193
  success("Installing development tools...")
113
- subprocess.run([*venv_pip, "pytest", "pytest-odoo", "debugpy", "manifestoo", "coverage"])
194
+ subprocess.run(
195
+ [*venv_pip, "pytest", "pytest-odoo", "debugpy", "manifestoo", "coverage"]
196
+ )
114
197
 
115
198
  success("\nVirtual environment setup complete!")
116
199
  success(f"To activate: source {cfg.venv_path}/bin/activate")
@@ -193,10 +276,12 @@ def _setup_odoo_config(cfg, community_only: bool = False) -> None:
193
276
  if not community_only:
194
277
  addons_paths.append(str(cfg.project_dir / "enterprise"))
195
278
 
196
- addons_paths.extend([
197
- str(cfg.project_dir / "design-themes"),
198
- str(cfg.project_dir / "addons"),
199
- ])
279
+ addons_paths.extend(
280
+ [
281
+ str(cfg.project_dir / "design-themes"),
282
+ str(cfg.project_dir / "addons"),
283
+ ]
284
+ )
200
285
 
201
286
  # Filter to only existing paths
202
287
  addons_paths = [p for p in addons_paths if Path(p).exists()]
@@ -335,7 +420,7 @@ def _update_python_path(cfg) -> None:
335
420
  if "# Odoo PYTHONPATH setup" in content:
336
421
  return
337
422
 
338
- pythonpath_setup = '''
423
+ pythonpath_setup = """
339
424
  # Odoo PYTHONPATH setup
340
425
  if [ -z "$_OLD_VIRTUAL_PYTHONPATH" ]; then
341
426
  _OLD_VIRTUAL_PYTHONPATH="$PYTHONPATH"
@@ -357,7 +442,7 @@ if [ -n "$ODOO_PYTHONPATH" ]; then
357
442
  export PYTHONPATH
358
443
  fi
359
444
  # End Odoo PYTHONPATH setup
360
- '''
445
+ """
361
446
 
362
447
  content += pythonpath_setup
363
448
  activate_script.write_text(content)
odoo_dev/config.py CHANGED
@@ -4,6 +4,10 @@ import os
4
4
  from dataclasses import dataclass
5
5
  from pathlib import Path
6
6
 
7
+ # Default versions
8
+ DEFAULT_ODOO_VERSION = "19.0"
9
+ DEFAULT_PYTHON_VERSION = "3.12"
10
+
7
11
 
8
12
  @dataclass
9
13
  class ProjectConfig:
@@ -95,7 +99,7 @@ def load_config(project_dir: Path | None = None) -> ProjectConfig:
95
99
  return ProjectConfig(
96
100
  project_dir=project_dir,
97
101
  script_dir=project_dir / ".odoo-deploy",
98
- odoo_version=os.getenv("ODOO_VERSION", "18.0"),
99
- python_version=os.getenv("PYTHON_VERSION", "3.12"),
102
+ odoo_version=os.getenv("ODOO_VERSION", DEFAULT_ODOO_VERSION),
103
+ python_version=os.getenv("PYTHON_VERSION", DEFAULT_PYTHON_VERSION),
100
104
  project_name=project_dir.name,
101
105
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: odoo-dev
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Odoo Development Environment Helper
5
5
  Requires-Python: >=3.12
6
6
  Requires-Dist: rich>=13.0.0
@@ -1,14 +1,14 @@
1
- odoo_dev/__init__.py,sha256=k91qzqyJaW_n2LwmsJoDER8z90x2wcVNODzKACLUxKc,66
1
+ odoo_dev/__init__.py,sha256=4FMP4CsWGOwjb25y-xmg7JfXKoM6Dg1jtahnjMxF1rU,66
2
2
  odoo_dev/cli.py,sha256=SqY07yLgOGEUkrUvbBM9Sfon87nUUbM_wDk96n_pScg,714
3
- odoo_dev/config.py,sha256=LbWsJbcvIfE5fbxkZK_iItaYDhiB0t8mF6wQk2d8hpM,2865
3
+ odoo_dev/config.py,sha256=tZ_aDAsHeDSFs6fLwdn974UzTIPAR3DHBLmdvO4jyeM,2977
4
4
  odoo_dev/commands/__init__.py,sha256=yOxitS1Oes2ZS95F0nXyw3LDOBXCFWmudZInYbTu1eQ,33
5
5
  odoo_dev/commands/db.py,sha256=7DnI28y2YpugnjoMkyTYymLMZ5MjNagfD6T15RWvZ0c,9605
6
6
  odoo_dev/commands/docker.py,sha256=I5dvxRX4uHzwBwTM7d7yhMphge8fdKoqjXCKo_-7FQw,5386
7
7
  odoo_dev/commands/run.py,sha256=FPi_rIyMOWadZfMPin0TXHbdBcW1YIuqUseBEhr4PnE,11882
8
- odoo_dev/commands/setup.py,sha256=M67rE1qWA2iYA3S15cZAt_-Za2iXWau1QAbt-nvOCQU,11260
8
+ odoo_dev/commands/setup.py,sha256=lRgjMm38_JrazgOiSr7_MF9BlI1G5lOtQobmM30WN0U,13366
9
9
  odoo_dev/utils/__init__.py,sha256=EDPdElYZN3cPJtZIkNjXFoItz1mPBPUsasQzb6mRrss,36
10
10
  odoo_dev/utils/console.py,sha256=bRbXVD15QiMhdU8Rp4cyaoA1-J8vFX8r16TwsYurUug,549
11
- odoo_dev-0.1.0.dist-info/METADATA,sha256=stKenzdej2YmQ_ubYOG2vsHzZdAGT6zhQu9re0gHkQE,3155
12
- odoo_dev-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
13
- odoo_dev-0.1.0.dist-info/entry_points.txt,sha256=EKJCgGArQtoRNYRBRcbkRfIXO_APFkYujr2u8-UCfXo,46
14
- odoo_dev-0.1.0.dist-info/RECORD,,
11
+ odoo_dev-0.2.0.dist-info/METADATA,sha256=VW7yDxdRTd04ySU_8vTCd50evX-D_DDNiHM67QWafIE,3155
12
+ odoo_dev-0.2.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
13
+ odoo_dev-0.2.0.dist-info/entry_points.txt,sha256=EKJCgGArQtoRNYRBRcbkRfIXO_APFkYujr2u8-UCfXo,46
14
+ odoo_dev-0.2.0.dist-info/RECORD,,