Skip to content

Commit d781cee

Browse files
authored
Merge pull request #322 from acsone/rm-legacy-build
Remove legacy wheel build mechanism
2 parents 6120bfb + f18b572 commit d781cee

File tree

5 files changed

+12
-53
lines changed

5 files changed

+12
-53
lines changed

src/oca_github_bot/build_wheels.py

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import sys
99
import tempfile
1010
from pathlib import Path
11-
from typing import Tuple, Union
11+
from typing import Union
1212

1313
from .config import WHEEL_BUILD_TOOLS
14-
from .manifest import addon_dirs_in, get_manifest, get_odoo_series_from_version
14+
from .manifest import addon_dirs_in, get_manifest
1515
from .process import check_call
1616
from .pypi import DistPublisher
1717

@@ -65,25 +65,6 @@ def build_wheel(self, project_dir: Path, dist_dir: str) -> None:
6565
self._check_wheels(dist_dir)
6666
return True
6767

68-
def build_wheel_legacy(
69-
self, project_dir: Path, dist_dir: str, python_tag: Union[str, None] = None
70-
) -> None:
71-
with tempfile.TemporaryDirectory() as bdist_dir:
72-
cmd = [
73-
self.env_python,
74-
"setup.py",
75-
"bdist_wheel",
76-
"--dist-dir",
77-
dist_dir,
78-
"--bdist-dir",
79-
bdist_dir,
80-
]
81-
if python_tag:
82-
cmd.extend(["--python-tag", python_tag])
83-
check_call(cmd, cwd=project_dir)
84-
self._check_wheels(dist_dir)
85-
return True
86-
8768
def _check_wheels(self, dist_dir: Path) -> None:
8869
wheels = [f for f in os.listdir(dist_dir) if f.endswith(".whl")]
8970
check_call(["twine", "check"] + wheels, cwd=dist_dir)
@@ -93,16 +74,12 @@ def build_addon_wheel(self, addon_dir: Path, dist_dir: str) -> None:
9374
if not manifest.get("installable", True):
9475
return False
9576

96-
series = get_odoo_series_from_version(manifest.get("version", ""))
97-
98-
if series >= (12, 0) and (addon_dir / "pyproject.toml").is_file():
77+
if (addon_dir / "pyproject.toml").is_file():
9978
return self.build_wheel(addon_dir, dist_dir)
10079

10180
setup_py_dir = addon_dir / ".." / "setup" / addon_dir.name
102-
if series >= (8, 0) and (setup_py_dir / "setup.py").is_file():
103-
return self.build_wheel_legacy(
104-
setup_py_dir, dist_dir, python_tag="py2" if series < (11, 0) else "py3"
105-
)
81+
if (setup_py_dir / "setup.py").is_file():
82+
return self.build_wheel(setup_py_dir, dist_dir)
10683

10784
return False
10885

@@ -132,7 +109,6 @@ def build_and_publish_wheels(
132109
def build_and_publish_metapackage_wheel(
133110
addons_dir: str,
134111
dist_publisher: DistPublisher,
135-
series: Tuple[int, int],
136112
dry_run: bool,
137113
):
138114
setup_dir = Path(addons_dir) / "setup" / "_metapackage"
@@ -148,7 +124,5 @@ def build_and_publish_metapackage_wheel(
148124
setup_dir.joinpath("setup.cfg").write_text(
149125
"[metadata]\nlong_description = UNKNOWN\n"
150126
)
151-
if Builder.get().build_wheel_legacy(
152-
setup_dir, dist_dir, python_tag="py2" if series < (11, 0) else "py3"
153-
):
127+
if Builder.get().build_wheel(setup_dir, dist_dir):
154128
dist_publisher.publish(dist_dir, dry_run)

src/oca_github_bot/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def func_wrapper(*args, **kwargs):
144144
).split(",")
145145

146146
# minimum Odoo series supported by the bot
147-
MAIN_BRANCH_BOT_MIN_VERSION = os.environ.get("MAIN_BRANCH_BOT_MIN_VERSION", "8.0")
147+
MAIN_BRANCH_BOT_MIN_VERSION = os.environ.get("MAIN_BRANCH_BOT_MIN_VERSION", "11.0")
148148

149149
# First Odoo Series for which the whool_init and gen_metapackage tasks are run on main
150150
# branches. For previous versions, the setuptools_odoo task is run and generates

src/oca_github_bot/tasks/main_branch_bot.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
switchable,
1313
)
1414
from ..github import git_commit_if_needed, git_push_if_needed, temporary_clone
15-
from ..manifest import get_odoo_series_from_branch
1615
from ..process import check_call
1716
from ..queue import getLogger, task
1817
from ..version_branch import is_main_branch_bot_branch, is_supported_main_branch
@@ -144,7 +143,6 @@ def main_branch_bot(org, repo, branch, build_wheels, dry_run=False):
144143
build_and_publish_metapackage_wheel(
145144
clone_dir,
146145
dist_publisher,
147-
get_odoo_series_from_branch(branch),
148146
dry_run,
149147
)
150148

tests/test_build_wheels.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,31 +81,20 @@ def test_build_and_publish_wheels(setup_py, tmp_path):
8181
assert wheels[0].startswith("odoo12_addon_addon1")
8282
assert wheels[0].endswith(".whl")
8383
assert "-py3-" in wheels[0]
84-
# build with two addons, don't use pyproject.toml for this version
85-
_make_addon(addons_dir, "addon2", "10.0", setup_py=True, pyproject=False)
86-
build_and_publish_wheels(str(addons_dir), dist_publisher, dry_run=False)
87-
wheel_dirs = sorted(os.listdir(simple_index_root))
88-
assert len(wheel_dirs) == 2
89-
assert wheel_dirs[0] == "odoo10-addon-addon2"
90-
wheels = os.listdir(simple_index_root / "odoo10-addon-addon2")
91-
assert len(wheels) == 1
92-
assert wheels[0].startswith("odoo10_addon_addon2")
93-
assert wheels[0].endswith(".whl")
94-
assert "-py2-" in wheels[0]
9584
# test tag for Odoo 11, don't use pyproject.toml for this version
9685
_make_addon(addons_dir, "addon3", "11.0", setup_py=True, pyproject=False)
9786
build_and_publish_wheels(str(addons_dir), dist_publisher, dry_run=False)
9887
wheel_dirs = sorted(os.listdir(simple_index_root))
99-
assert len(wheel_dirs) == 3
100-
assert wheel_dirs[1] == "odoo11-addon-addon3"
88+
assert len(wheel_dirs) == 2
89+
assert wheel_dirs[0] == "odoo11-addon-addon3"
10190
wheels = os.listdir(simple_index_root / "odoo11-addon-addon3")
10291
assert len(wheels) == 1
10392
assert "-py2.py3-" in wheels[0]
10493
# test Odoo 15+ default addon naming scheme
10594
_make_addon(addons_dir, "addon4", "15.0", setup_py=setup_py, pyproject=not setup_py)
10695
build_and_publish_wheels(str(addons_dir), dist_publisher, dry_run=False)
10796
wheel_dirs = sorted(os.listdir(simple_index_root))
108-
assert len(wheel_dirs) == 4
97+
assert len(wheel_dirs) == 3
10998
assert wheel_dirs[0] == "odoo-addon-addon4"
11099
wheels = os.listdir(simple_index_root / "odoo-addon-addon4")
111100
assert len(wheels) == 1
@@ -123,9 +112,7 @@ def test_build_and_publish_metapackage(tmp_path):
123112
dist_publisher = RsyncDistPublisher(simple_index_root)
124113
# build with one addon
125114
_make_addon(addons_dir, "addon1", "12.0", metapackage="test")
126-
build_and_publish_metapackage_wheel(
127-
str(addons_dir), dist_publisher, (12, 0), dry_run=False
128-
)
115+
build_and_publish_metapackage_wheel(str(addons_dir), dist_publisher, dry_run=False)
129116
wheels = os.listdir(simple_index_root / "odoo12-addons-test")
130117
assert len(wheels) == 1
131118
assert wheels[0].startswith("odoo12_addons_test")

tests/test_version_branch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
def test_is_main_branch_bot_branch():
2020
assert not is_main_branch_bot_branch("6.1")
2121
assert not is_main_branch_bot_branch("7.0")
22-
assert is_main_branch_bot_branch("8.0")
22+
assert is_main_branch_bot_branch("11.0")
2323
assert is_main_branch_bot_branch("12.0")
2424
assert not is_main_branch_bot_branch("10.0-something")
2525
with set_config(MAIN_BRANCH_BOT_MIN_VERSION="10.0"):

0 commit comments

Comments
 (0)