backend.ai-krunner-static-gnu


Namebackend.ai-krunner-static-gnu JSON
Version 4.3.0 PyPI version JSON
download
home_pagehttps://backend.ai
SummaryBackend.AI Kernel Runner based on GNU libc
upload_time2024-09-20 12:24:51
maintainerNone
docs_urlNone
authorLablup Inc.
requires_python>=3.6
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # backend.ai-krunner-static-gnu
Backend.AI Kernel Runner Package for glibc-based Kernels

This package contains a statically built Python distribution and 3rd-party libraries required to run
[our krunner module](https://github.com/lablup/backend.ai/tree/main/src/ai/backend/kernel)
inside containers whose images are provided by users.

The krunner wheel itself can be installed into any Python environments (the content of this plugin
package is agnostic to platforms and architectures as it's a mere declaration of the plugin
interface), but we still apply the binary wheel platform tags so that setuptools could distinguish
the target CPU architecture as follows:

| Where is Backend.AI running? | What is the user container's base image? | The krunner wheel used |
|------------------------------|------------------------------------------|------------------------|
| manylinux (x86-64)           | manylinux (x86-64)                       | `backend.ai_krunner_static_gnu-X.X.X-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl` |
| manylinux (x86-64)           | musllinux (x86-64)                       | `backend.ai_krunner_alpine-X.X.X-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl` |
| manylinux (aarch64)          | manylinux (aarch64)                      | `backend.ai_krunner_static_gnu-X.X.X-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl` |
| manylinux (aarch64)          | musllinux (aarch64)                      | `backend.ai_krunner_alpine-X.X.X-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl` |
| musllinux (x86-64)           | manylinux (x86-64)                       | `backend.ai_krunner_static_gnu-X.X.X-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl` |
| musllinux (x86-64)           | musllinux (x86-64)                       | `backend.ai_krunner_alpine-X.X.X-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl` |
| musllinux (aarch64)          | manylinux (aarch64)                      | `backend.ai_krunner_static_gnu-X.X.X-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl` |
| musllinux (aarch64)          | musllinux (aarch64)                      | `backend.ai_krunner_alpine-X.X.X-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl` |
| macOS (x86-64)               | manylinux (x86-64)                       | `backend.ai_krunner_static_gnu-X.X.X-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl` |
| macOS (x86-64)               | musllinux (x86-64)                       | `backend.ai_krunner_alpine-X.X.X-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl` |
| macOS (aarch64)              | manylinux (aarch64)                      | `backend.ai_krunner_static_gnu-X.X.X-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl` |
| macOS (aarch64)              | musllinux (aarch64)                      | `backend.ai_krunner_alpine-X.X.X-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl` |

We named the krunner package based on musl 1.2 as "alpine" because practically Alpine linux is the
only distribution which actively uses musl and it is currently not possible to build static CPython
which can import 3rd-party dynamic modules on top of the musl ecosystem.

## Notice about source distribution

This package is to distribute prebuilt binaries, so the source distribution does not have prebuilt
binaries and does not work as intended.  Just refer this repository on how we build stuffs.

## How to read below

* `{distro}` is a string like `static-gnu`, `alpine`, etc. depending on which repository you are in.
* `{distro_}` is a string same to `{distro}` but with hyphens replaced with underscores for Python
  package names and paths. (e.g., `static_gnu`, `alpine`)

## Development

```console
$ git clone https://github.com/lablup/backend.ai-krunner-{distro} krunner-{distro}
$ cd krunner-{distro}
$ pyenv virtualenv 3.12.2 venv-krunner  # you may share the same venv with other krunner projects
$ pyenv local venv-krunner
$ pip install -U pip setuptools
$ pip install -U -r build/requirements.txt
$ pip install -U -e .
```

## How to update

1. Modify Dockerfile and/or other contents.
  - To update the Python version, update `src/ai/backend/krunner/{distro_}/krunner-python.{distro}.txt`
    and the dockerfiles (both python and wheels) accordingly, including the
    `PYTHON_VERSION` environment variable and the download URL of the
    statically built Python distribution.
2. Increment *the volume version number* specified as a label `ai.backend.krunner.version`
   in `src/ai/backend/krunner/{distro_}/krunner-env.{distro}.dockerfile`
3. Run `scripts/build.py`.
4. Repeat the above steps for each distro version. (For static builds, there is only one.)
5. Increment *the package version number* in `src/ai/backend/krunner/{distro_}/__init__.py`
6. `rm -r dist/* build/*` (skip if these directories do not exist and or are empty)
7. Commit.
8. Create a signed annotated tag and push the tag to let GitHub Action build and publish wheels.

Note that `src/ai/backend/krunner/{distro_}/krunner-version.{distro}.txt` files are
overwritten by the build script from the label.

WARNING: We should choose [`x86_64_v2` binaries from the indygreg repository](https://gregoryszorc.com/docs/python-build-standalone/main/running.html)
when updating the Python runtime version for CPU compatibility with some of our
test setups and customer sites.

## Making a minimal glibc-based image compatibile with this krunner package

[Use CentOS 7 or later and install this list of packages.](https://github.com/lablup/backend.ai-krunner-static-gnu/blob/master/compat-test.Dockerfile)
Also [refer the test script](https://github.com/lablup/backend.ai-krunner-static-gnu/blob/main/scripts/test.sh).

## Build custom ttyd binary

**⚠️ Warning: Use a x86-64 host to build ttyd, because:**
  - ttyd uses `musl` as their C stdlib, not `glibc`.
  - The `musl` toochain used by the build script is x86_64 binaries.

`libwebsockets>=4.0.0` features auto ping/pong with 5 min default interval.
(https://github.com/warmcat/libwebsockets#connection-validity-tracking) And,
`ws_ping_pong_interval` of ttyd is not effective in `libwebsockets>=4.0.0`.
This seems to be the reason why `ttyd>=1.6.1` does not set
`ws_ping_pong_interval` for `libwebsockets>=4.0.0`.
(https://github.com/tsl0922/ttyd/blob/master/src/server.c#L456)

To fix this issue, we modify and build the latest version of `libwebsockets` used by the ttyd build script manually.

```console
# Prepare Ubuntu environment (possibly, through container) and dependencies.
sudo apt-get update
sudo apt-get install -y autoconf automake build-essential cmake curl file libtool

# Download ttyd source.
git clone https://github.com/tsl0922/ttyd.git
cd ttyd
```

Now let's modify `./scripts/cross-build.sh`.  
Add these two lines under `pushd "${BUILD_DIR}/libwebsockets-${LIBWEBSOCKETS_VERSION}"`:
```sh
sed -i 's/context->default_retry.secs_since_valid_ping = 300/context->default_retry.secs_since_valid_ping = 20/g' lib/core/context.c 
sed -i 's/context->default_retry.secs_since_valid_hangup = 310/context->default_retry.secs_since_valid_hangup = 30/g' lib/core/context.c 
```

Finally, build the `ttyd` binary.   
```console
# Run build script.
./scripts/cross-build.sh

# Check ttyd binary version.
./build/ttyd --version
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://backend.ai",
    "name": "backend.ai-krunner-static-gnu",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Lablup Inc.",
    "author_email": "devops@lablup.com",
    "download_url": "https://files.pythonhosted.org/packages/e1/45/23d5435ce37abca128f4a10eb1f73b4bb6a5cf25bc53da8f4d3e221d0e83/backend_ai_krunner_static_gnu-4.3.0.tar.gz",
    "platform": null,
    "description": "# backend.ai-krunner-static-gnu\nBackend.AI Kernel Runner Package for glibc-based Kernels\n\nThis package contains a statically built Python distribution and 3rd-party libraries required to run\n[our krunner module](https://github.com/lablup/backend.ai/tree/main/src/ai/backend/kernel)\ninside containers whose images are provided by users.\n\nThe krunner wheel itself can be installed into any Python environments (the content of this plugin\npackage is agnostic to platforms and architectures as it's a mere declaration of the plugin\ninterface), but we still apply the binary wheel platform tags so that setuptools could distinguish\nthe target CPU architecture as follows:\n\n| Where is Backend.AI running? | What is the user container's base image? | The krunner wheel used |\n|------------------------------|------------------------------------------|------------------------|\n| manylinux (x86-64)           | manylinux (x86-64)                       | `backend.ai_krunner_static_gnu-X.X.X-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl` |\n| manylinux (x86-64)           | musllinux (x86-64)                       | `backend.ai_krunner_alpine-X.X.X-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl` |\n| manylinux (aarch64)          | manylinux (aarch64)                      | `backend.ai_krunner_static_gnu-X.X.X-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl` |\n| manylinux (aarch64)          | musllinux (aarch64)                      | `backend.ai_krunner_alpine-X.X.X-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl` |\n| musllinux (x86-64)           | manylinux (x86-64)                       | `backend.ai_krunner_static_gnu-X.X.X-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl` |\n| musllinux (x86-64)           | musllinux (x86-64)                       | `backend.ai_krunner_alpine-X.X.X-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl` |\n| musllinux (aarch64)          | manylinux (aarch64)                      | `backend.ai_krunner_static_gnu-X.X.X-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl` |\n| musllinux (aarch64)          | musllinux (aarch64)                      | `backend.ai_krunner_alpine-X.X.X-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl` |\n| macOS (x86-64)               | manylinux (x86-64)                       | `backend.ai_krunner_static_gnu-X.X.X-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl` |\n| macOS (x86-64)               | musllinux (x86-64)                       | `backend.ai_krunner_alpine-X.X.X-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl` |\n| macOS (aarch64)              | manylinux (aarch64)                      | `backend.ai_krunner_static_gnu-X.X.X-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl` |\n| macOS (aarch64)              | musllinux (aarch64)                      | `backend.ai_krunner_alpine-X.X.X-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl` |\n\nWe named the krunner package based on musl 1.2 as \"alpine\" because practically Alpine linux is the\nonly distribution which actively uses musl and it is currently not possible to build static CPython\nwhich can import 3rd-party dynamic modules on top of the musl ecosystem.\n\n## Notice about source distribution\n\nThis package is to distribute prebuilt binaries, so the source distribution does not have prebuilt\nbinaries and does not work as intended.  Just refer this repository on how we build stuffs.\n\n## How to read below\n\n* `{distro}` is a string like `static-gnu`, `alpine`, etc. depending on which repository you are in.\n* `{distro_}` is a string same to `{distro}` but with hyphens replaced with underscores for Python\n  package names and paths. (e.g., `static_gnu`, `alpine`)\n\n## Development\n\n```console\n$ git clone https://github.com/lablup/backend.ai-krunner-{distro} krunner-{distro}\n$ cd krunner-{distro}\n$ pyenv virtualenv 3.12.2 venv-krunner  # you may share the same venv with other krunner projects\n$ pyenv local venv-krunner\n$ pip install -U pip setuptools\n$ pip install -U -r build/requirements.txt\n$ pip install -U -e .\n```\n\n## How to update\n\n1. Modify Dockerfile and/or other contents.\n  - To update the Python version, update `src/ai/backend/krunner/{distro_}/krunner-python.{distro}.txt`\n    and the dockerfiles (both python and wheels) accordingly, including the\n    `PYTHON_VERSION` environment variable and the download URL of the\n    statically built Python distribution.\n2. Increment *the volume version number* specified as a label `ai.backend.krunner.version`\n   in `src/ai/backend/krunner/{distro_}/krunner-env.{distro}.dockerfile`\n3. Run `scripts/build.py`.\n4. Repeat the above steps for each distro version. (For static builds, there is only one.)\n5. Increment *the package version number* in `src/ai/backend/krunner/{distro_}/__init__.py`\n6. `rm -r dist/* build/*` (skip if these directories do not exist and or are empty)\n7. Commit.\n8. Create a signed annotated tag and push the tag to let GitHub Action build and publish wheels.\n\nNote that `src/ai/backend/krunner/{distro_}/krunner-version.{distro}.txt` files are\noverwritten by the build script from the label.\n\nWARNING: We should choose [`x86_64_v2` binaries from the indygreg repository](https://gregoryszorc.com/docs/python-build-standalone/main/running.html)\nwhen updating the Python runtime version for CPU compatibility with some of our\ntest setups and customer sites.\n\n## Making a minimal glibc-based image compatibile with this krunner package\n\n[Use CentOS 7 or later and install this list of packages.](https://github.com/lablup/backend.ai-krunner-static-gnu/blob/master/compat-test.Dockerfile)\nAlso [refer the test script](https://github.com/lablup/backend.ai-krunner-static-gnu/blob/main/scripts/test.sh).\n\n## Build custom ttyd binary\n\n**\u26a0\ufe0f Warning: Use a x86-64 host to build ttyd, because:**\n  - ttyd uses `musl` as their C stdlib, not `glibc`.\n  - The `musl` toochain used by the build script is x86_64 binaries.\n\n`libwebsockets>=4.0.0` features auto ping/pong with 5 min default interval.\n(https://github.com/warmcat/libwebsockets#connection-validity-tracking) And,\n`ws_ping_pong_interval` of ttyd is not effective in `libwebsockets>=4.0.0`.\nThis seems to be the reason why `ttyd>=1.6.1` does not set\n`ws_ping_pong_interval` for `libwebsockets>=4.0.0`.\n(https://github.com/tsl0922/ttyd/blob/master/src/server.c#L456)\n\nTo fix this issue, we modify and build the latest version of `libwebsockets` used by the ttyd build script manually.\n\n```console\n# Prepare Ubuntu environment (possibly, through container) and dependencies.\nsudo apt-get update\nsudo apt-get install -y autoconf automake build-essential cmake curl file libtool\n\n# Download ttyd source.\ngit clone https://github.com/tsl0922/ttyd.git\ncd ttyd\n```\n\nNow let's modify `./scripts/cross-build.sh`.  \nAdd these two lines under `pushd \"${BUILD_DIR}/libwebsockets-${LIBWEBSOCKETS_VERSION}\"`:\n```sh\nsed -i 's/context->default_retry.secs_since_valid_ping = 300/context->default_retry.secs_since_valid_ping = 20/g' lib/core/context.c \nsed -i 's/context->default_retry.secs_since_valid_hangup = 310/context->default_retry.secs_since_valid_hangup = 30/g' lib/core/context.c \n```\n\nFinally, build the `ttyd` binary.   \n```console\n# Run build script.\n./scripts/cross-build.sh\n\n# Check ttyd binary version.\n./build/ttyd --version\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Backend.AI Kernel Runner based on GNU libc",
    "version": "4.3.0",
    "project_urls": {
        "Homepage": "https://backend.ai"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bf4fd2813472af4d5460d7466f5e65612a6d84fafc972e64b10ebf69a359cebc",
                "md5": "ed6eb91c1265ceafdb6640f4c925f868",
                "sha256": "16125ec1e767fc12e3eda51b65e99cd3b35ad3cb40e2f33a5983b9be77653034"
            },
            "downloads": -1,
            "filename": "backend.ai_krunner_static_gnu-4.3.0-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "ed6eb91c1265ceafdb6640f4c925f868",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 47088487,
            "upload_time": "2024-09-20T12:24:43",
            "upload_time_iso_8601": "2024-09-20T12:24:43.994611Z",
            "url": "https://files.pythonhosted.org/packages/bf/4f/d2813472af4d5460d7466f5e65612a6d84fafc972e64b10ebf69a359cebc/backend.ai_krunner_static_gnu-4.3.0-py3-none-manylinux2014_aarch64.musllinux_1_1_aarch64.macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "29716cb81c37ea818067b96b4876046e1b18e3edef4c75ba987a22b9cfcd1877",
                "md5": "69b4148c5800d66e31928bfdebaec8f5",
                "sha256": "8f880eb9adfa99ce0e86c2b1555ae673c87d937ad1adc120307a4890f2c9cb03"
            },
            "downloads": -1,
            "filename": "backend.ai_krunner_static_gnu-4.3.0-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl",
            "has_sig": false,
            "md5_digest": "69b4148c5800d66e31928bfdebaec8f5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 48385907,
            "upload_time": "2024-09-20T12:24:48",
            "upload_time_iso_8601": "2024-09-20T12:24:48.108342Z",
            "url": "https://files.pythonhosted.org/packages/29/71/6cb81c37ea818067b96b4876046e1b18e3edef4c75ba987a22b9cfcd1877/backend.ai_krunner_static_gnu-4.3.0-py3-none-manylinux2014_x86_64.musllinux_1_1_x86_64.macosx_11_0_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e14523d5435ce37abca128f4a10eb1f73b4bb6a5cf25bc53da8f4d3e221d0e83",
                "md5": "9e209b19726fbef142a656d66b97a5d8",
                "sha256": "6da61a7a5cb47d363ebf8a9fcb6862a91aae4aeb9d6a95963552432f70a828d7"
            },
            "downloads": -1,
            "filename": "backend_ai_krunner_static_gnu-4.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9e209b19726fbef142a656d66b97a5d8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 7891,
            "upload_time": "2024-09-20T12:24:51",
            "upload_time_iso_8601": "2024-09-20T12:24:51.480912Z",
            "url": "https://files.pythonhosted.org/packages/e1/45/23d5435ce37abca128f4a10eb1f73b4bb6a5cf25bc53da8f4d3e221d0e83/backend_ai_krunner_static_gnu-4.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-20 12:24:51",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "backend.ai-krunner-static-gnu"
}
        
Elapsed time: 0.50842s