Skip to content

Commit

Permalink
removed trace
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Wimmer committed Jul 23, 2024
1 parent 670eebd commit 25d5bb2
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 88 deletions.
40 changes: 28 additions & 12 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ permissions:
jobs:
build:

runs-on: ubuntu-22.04
runs-on: self-hosted
env:
ODOO_TEST: "16.0"
ODOO_PYTHON_VERSION: "3.9.13"
ODOOCMD: "/home/githubrunner_wodoo/.local/bin/odoo"

steps:
- uses: actions/checkout@v4
Expand All @@ -31,24 +33,38 @@ jobs:
git config --global user.name '[email protected]'
git fetch
- name: do some testing
- name: install pipx
run: |
sudo apt update && sudo apt install -y python3-dev \
python3-pip python3-venv python3-virtualenv
pip install pip -U
pip install pipx
- name: setup gimera
run: |
set -ex
pipx install gimera
pipx upgrade gimera
- name: install woodo
run: |
pipx install -e --force .
pipx runpip wodoo install requests==2.31.0
cd /tmp
odoo init odoo1 "$ODOO_TEST"
cd /tmp/odoo1
#WHY?
pipx runpip wodoo install requests==2.31.0 || true
- name: do some testing
run: |
TEMPODOODIR="./$(basename $(mktemp))/odoo"
mkdir -p "$TEMPODOODIR"
cd "$TEMPODOODIR"
$ODOOCMD init . "$ODOO_TEST"
docker ps
odoo reload
rm -Rf ~/.cache/gimera
odoo build
odoo -f db reset
odoo update crm
odoo down
$ODOOCMD reload
$ODOOCMD setting ODOO_PYTHON_VERSION=$ODOO_PYTHON_VERSION
$ODOOCMD build
$ODOOCMD -f db reset
$ODOOCMD update crm
$ODOOCMD down
- name: increment version
run: |
Expand Down
15 changes: 3 additions & 12 deletions wodoo/lib_composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,17 +356,6 @@ def _download_images(config, images_url):
config.dirs["images"],
]
)
# subprocess.check_call(
# [
# "git",
# "config",
# "--global",
# "--add",
# "safe.directory",
# str(config.dirs["images"]),
# ],
# cwd=config.dirs["images"],
# )
current_branch = subprocess.check_output(
["git", "rev-parse", "--abbrev-ref", "HEAD"],
encoding="utf8",
Expand All @@ -375,7 +364,9 @@ def _download_images(config, images_url):
effective_branch = config.ODOO_IMAGES_BRANCH or consts.IMAGES_REPO_BRANCH

if effective_branch and effective_branch != current_branch:
subprocess.check_call(["git", "checkout", effective_branch])
subprocess.check_call(
["git", "checkout", effective_branch], cwd=config.dirs["images"]
)

if subprocess.check_output(
["git", "remote"], encoding="utf8", cwd=config.dirs["images"]
Expand Down
152 changes: 88 additions & 64 deletions wodoo/module_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ def get_all_used_modules(self, include_uninstall=False):

return list(result)

def get_all_external_dependencies(self, modules, python_version=None):
def get_all_external_dependencies(self, modules, python_version):
global_data = {"pip": []}
for module_name in modules:
module = Module.get_by_name(module_name)
Expand Down Expand Up @@ -934,88 +934,100 @@ def extract_deps(data):
)
return global_data

def resolve_pydeps(self, pydeps, python_version=None):
pydeps = list(set(pydeps))
libnames = [_extract_python_libname(x) for x in pydeps]
result = set()

if python_version:
assert isinstance(python_version, tuple)
str_python_version = ".".join(map(str, python_version))

class LeaveOut(Exception):
pass
def _filter_requirements(self, pydeps, python_version):
assert isinstance(python_version, tuple)
str_python_version = ".".join(map(str, python_version))

# keep highest version and or leaveout loosers
def _map(x):
if x:
try:
x = x.split("#")[0]
base = x.split(";")[0].strip()
if base.endswith(".*"):
# xlwt==1.3.*
base = base[:-2]
for extra in x.split(";")[1:]:
if not python_version and "python_version" in x:
abort("Please provide python version")
res = eval(
extra,
{
"python_version": str_python_version,
"sys_platform": sys.platform,
},
)
if not res:
raise LeaveOut()

arr = iscompatible.parse_requirements(base)
except LeaveOut:
arr = []
except Exception as ex:
import pudb

pudb.set_trace()
raise
else:
arr = []
for arr in arr:
if arr:
arr = list(arr)
arr[1] = iscompatible.string_to_tuple(arr[1])
yield tuple(arr)

parsed_requirements = []
for inst in pydeps:
libname = _extract_python_libname(inst)
if "@" in inst:
def _filter(x):
if not x:
return
if "@" in x:
# concrete url like "pymssql@git+https://github.com/marcwimmer/pymssql"
parsed_requirements.append(inst)
else:
for parsed in [
_map(x) for x in pydeps if _extract_python_libname(x) == libname
]:
for x in parsed:
parsed_requirements.append((libname, x))
return x
x = x.split("#")[0].strip()
if not x:
return
for extra in x.split(";")[1:]:
if not python_version and "python_version" in x:
abort("Please provide python version")
res = eval(
extra,
{
"python_version": str_python_version,
"sys_platform": sys.platform,
},
)
if not res:
return
return STRIP(x)

def STRIP(dep):
res = dep.split("#")[0].split(";")[0].strip()
if res.endswith(".*"):
# xlwt==1.3.*
res = res[:-2]
return res

def _make_tuples(dep):
libname = _extract_python_libname(dep)
if not libname:
return []
if 'greenlet' in dep[0]:
import pudb;pudb.set_trace()
try:
reqs = iscompatible.parse_requirements(dep)
except Exception as ex:
import pudb;pudb.set_trace()
raise
reqs = list(reqs)
if reqs:
for i in range(len(reqs)):
try:
reqs[i] = list(reqs[i])
reqs[i][1] = iscompatible.string_to_tuple(reqs[i][1])
except:
import pudb;pudb.set_trace()
raise
return libname, tuple(reqs)

reqs = {}
for dep in list(filter(_filter, pydeps)):
dep = STRIP(dep)
print(dep)
libname, version = _make_tuples(dep)
reqs.setdefault(libname, []).append(version)
"""
parsed_requirements ilike
[
('>=', '1.0.0'),
('>=', '1.2.0')
]
"""
return reqs

def _pydeps_filter_best_fit(self, pydeps):
result = set()
allowed = ["==", ">="]
unallowed = [
x
for x in parsed_requirements
for x in pydeps
if not isinstance(x, str) and x[1][0] not in allowed
]
if unallowed:
raise Exception(f"Unhandled: {unallowed} - only {allowed} allowed")

for libname in libnames:
for libname in pydeps.keys():
# mixed == and >=
reqs = list(set([x[1] for x in parsed_requirements if x[0] == libname]))
reqs = pydeps.get(libname, [])

#handle case: reqs = [()]
unspecific_ones = [x for x in reqs if not x]
if len(unspecific_ones) == len(reqs):
result.add(libname)
continue
reqs = [x for x in reqs if x]

ge = sorted([x for x in reqs if x[0] == ">="], key=lambda x: x[1])
gt = sorted(
[x for x in reqs if x[0] == ">"], key=lambda x: x[1]
Expand Down Expand Up @@ -1047,7 +1059,19 @@ def _map(x):
elif ge:
result.add(f"{libname}{ge[-1][0]}{'.'.join(map(str, ge[-1][1]))}")
else:
result.add(libname)
if len(reqs) == 1:
result.add(f"{libname}{reqs[0][-1][0]}{'.'.join(map(str, reqs[0][-1][1]))}")
else:
result.add(libname)
return list(sorted(result))


def resolve_pydeps(self, pydeps, python_version):
pydeps = list(set(pydeps))

parsed_requirements = self._filter_requirements(pydeps, python_version)
result = self._pydeps_filter_best_fit(parsed_requirements)

return list(result)


Expand Down

0 comments on commit 25d5bb2

Please sign in to comment.