Skip to content

Commit

Permalink
Export poetry.lock to requirements.txt instead of calling build-wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
carlcsaposs-canonical committed Sep 23, 2024
1 parent 6056906 commit c86ed6a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ jobs:
- name: Set up environment
run: |
pipx install poetry
pipx install tox
pipx inject poetry poetry-plugin-export
# TODO: Remove after https://github.com/python-poetry/poetry/pull/5980 is closed
poetry config warnings.export false
- name: Install CLI
run: pipx install ./cli/
- name: Build wheels from source
Expand Down
31 changes: 15 additions & 16 deletions cli/cli/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,32 +157,31 @@ def main():
subprocess.run(
["sudo", "apt-get", "install", *build_packages, "-y"], check=True
)
# Check for charmcraft pack wrapper (tox `build-wrapper` environment)
tox_environments = subprocess.run(
["tox", "list", "--no-desc"],
capture_output=True,
cwd=charm_.directory,
check=True,
encoding="utf-8",
).stdout.split("\n")
if "build-wrapper" in tox_environments:
print("[ccc-hub] Tox build wrapper detected", flush=True)
if (charm_.directory / "poetry.lock").exists():
print(
"[ccc-hub] Converting subset of poetry.lock to requirements.txt",
flush=True,
)
subprocess.run(
["tox", "run", "-e", "build-wrapper"],
[
"poetry",
"export",
"--only",
"main,charm-libs",
"--output",
"requirements.txt",
],
cwd=charm_.directory,
check=True,
)
requirements = "requirements-last-build.txt"
else:
requirements = "requirements.txt"
assert (charm_.directory / requirements).exists()
assert (charm_.directory / "requirements.txt").exists()
command = [
pyenv,
"exec",
"pip",
"install",
"-r",
requirements,
"requirements.txt",
# Build wheels from source
"--no-binary",
":all:",
Expand Down

0 comments on commit c86ed6a

Please sign in to comment.