Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

286 split python requirements #288

Merged
merged 6 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,32 @@ jobs:
run --rm -T metamanager
/mnt/root --config /mnt/config.json --just-resolve
<examples/input/conan-conflict/PP.json

# - name: Clean meta-manager outputs
# run: rm -rf output/ root/

# - name: Run PPpackage for project compressor
# run: >
# USER="$(id -u):$(id -g)" docker compose
# --file .github/compose.yaml
# run --rm -T
# metamanager
# /mnt/root --config /mnt/config.json
# <examples/project/compressor/requirements.json

# - name: Build project compressor
# run: ./examples/project/compressor/build-in-container.sh docker ${{ github.workspace }}/root ${{ github.workspace }}/output/generators

# - name: Run project compressor
# run: ./examples/project/compressor/build/output/compressor
# wait for Ubuntu 24 becoming ubuntu-latest
fakealpm:
runs-on: ubuntu-24.04
steps:
- uses: actions/[email protected]

- name: Install fakealpm dependencies
uses: awalsh128/[email protected]
with:
packages: libarchive-dev libalpm-dev gcc cmake ninja-build libboost-all-dev nlohmann-json3-dev
run: sudo apt install libarchive-dev libalpm-dev gcc cmake ninja-build libboost-all-dev nlohmann-json3-dev

- name: Build fakelpm
run: ./src/installer/pacman/fakealpm/build.sh src/installer/pacman/fakealpm/ build/fakealpm/ /usr/local
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,12 @@ First, the build context for the project is created with our meta-manager:
./examples/metamanager/$method/run.sh < examples/project/compressor/requirements.json
```

Next we need to move the directories from `tmp/`. `tmp/root` goes to `examples/project/compressor/build/root` and `tmp/output/generators/` into `examples/project/compressor/build/generators/`.

Then we can run the provided script, which uses the `root/` directory as image rootfs and builds the project with build script `examples/project/compressor/build.sh`. The script is just the modified version of commands run in the Conan documentation.
This creates the image rootfs in the `tmp/root` directory and generators in `tmp/output/generators`. Then we can run the provided script, which builds the project with build script `examples/project/compressor/build.sh`. The script is just the modified version of commands run in the Conan documentation. The paths to the image rootfs and generators need to be absolute.

```bash
./examples/project/compressor/build-in-container.sh $containerizer
./examples/project/compressor/build-in-container.sh $containerizer $PWD/tmp/root $PWD/tmp/output/generators

./examples/project/compressor/build/output/compressor
./examples/project/compressor/build/compressor
```

We can also invoke the meta-manager directly without the `run.sh` scripts and then we would not have to move the directories as we could specify the output directories directly. The only problem with this method is that the containerized meta-manager needs to have path translations for the containerizer set for the root directory and that requires changing the config.json file. The native version doesn't have this problem as it resides in the same mount namespace as the containerizer.
8 changes: 4 additions & 4 deletions examples/project/compressor/build-in-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ fi

project_root="$PWD/examples/project/compressor"

mkdir -p "$project_root/build/output"
mkdir -p "$project_root/build"

"$1" run --rm \
--mount type=bind,source="$project_root/build/generators",target=/mnt/generators \
--mount type=bind,source="$3",target=/mnt/generators \
--mount type=bind,source="$project_root/compressor",target=/mnt/source \
--mount type=bind,source="$project_root/build/output",target=/mnt/output \
--mount type=bind,source="$project_root/build",target=/mnt/build \
--mount type=bind,source="$project_root/build.sh",target=/mnt/build.sh \
--rootfs "$project_root/build/root" \
--rootfs "$2" \
bash /mnt/build.sh
4 changes: 2 additions & 2 deletions examples/project/compressor/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

cmake -S /mnt/source -B /mnt/output -DCMAKE_TOOLCHAIN_FILE=/mnt/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
cmake --build /mnt/output
cmake -S /mnt/source -B /mnt/build -DCMAKE_TOOLCHAIN_FILE=/mnt/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
cmake --build /mnt/build
2 changes: 0 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
pre-commit
hypercorn
setuptools

-e ./src/utils/json --config-settings editable_mode=compat
-e ./src/utils/async --config-settings editable_mode=compat
Expand Down
42 changes: 42 additions & 0 deletions requirements-run.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
./src/utils/json --config-settings editable_mode=compat
./src/utils/async --config-settings editable_mode=compat
./src/utils/cli --config-settings editable_mode=compat
./src/utils/container --config-settings editable_mode=compat
./src/utils/file --config-settings editable_mode=compat
./src/utils/lock --config-settings editable_mode=compat
./src/utils/python --config-settings editable_mode=compat
./src/utils/serialization --config-settings editable_mode=compat



./src/repository-driver/interface/ --config-settings editable_mode=compat

./src/repository-driver/update/

./src/repository-driver/conan/
./src/repository-driver/pacman/
./src/repository-driver/AUR/



./src/installer/interface/ --config-settings editable_mode=compat

./src/installer/pacman/
./src/installer/conan/



./src/translator/interface/ --config-settings editable_mode=compat

./src/translator/pacman/
./src/translator/conan/



./src/generator/interface/ --config-settings editable_mode=compat

./src/generator/conan/



./src/metamanager/
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
setuptools
7 changes: 4 additions & 3 deletions src/metamanager/PPpackage/metamanager/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
from sys import stderr, stdin

from httpx import Client as HTTPClient
from sqlitedict import SqliteDict

from PPpackage.utils.container import Containerizer
from PPpackage.utils.json.validate import validate_json_io, validate_json_io_path
from sqlitedict import SqliteDict

from .create_graph import create_graph, write_graph_to_file
from .exceptions import HandledException, handle_exception_group
Expand Down Expand Up @@ -43,7 +42,9 @@ async def main(
containerizer = Containerizer(config.containerizer)

print("Pulling the solver image...", file=stderr)
containerizer.pull("docker.io/fackop/pppackage-solver", "latest")
containerizer.pull_if_missing(
"docker.io/fackop/pppackage-solver:latest"
)

input = validate_json_io(Input, stdin.buffer)

Expand Down
7 changes: 5 additions & 2 deletions src/utils/container/PPpackage/utils/container/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@ def run(

return return_code

def pull(self, repository: str, tag: str):
def pull_if_missing(self, tag: str):
with PodmanClient(base_url=str(self.config.url)) as client:
client.images.pull(repository, tag)
exists = client.images.exists(tag)

if not exists:
client.images.pull(tag)

def translate(self, container_path: Path):
for path_translation in self.config.path_translations:
Expand Down