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

setup: Vendor asyncudp #1367

Closed
wants to merge 7 commits into from
Closed
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
1 change: 1 addition & 0 deletions changes/1367.deps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Vendor `asyncudp` as `ai.backend.vendor.asyncudp` to avoid packaging issues due to its missing precompiled wheel distribution
301 changes: 143 additions & 158 deletions python.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ appdirs~=1.4.4
async_timeout~=4.0
asyncpg>=0.27.0
asynctest>=0.13.0
asyncudp>=0.4
attrs>=20.3
boto3~=1.26
cachetools~=5.2.0
Expand Down
2 changes: 1 addition & 1 deletion src/ai/backend/common/sd_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import os
import socket

import asyncudp
from ai.backend.vendor import asyncudp


class SystemdNotifier:
Expand Down
49 changes: 49 additions & 0 deletions src/ai/backend/vendor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Backend.AI Vendored Libarires

## Adding a new vendored library

First, add a git subtree from the library's repository.
You may change `main` to other branch names.

```
git remote add subtree-LIB https://github.com/OWNER/LIB
# NOTE: --squash is to required to avoid CLA signing issues from the upstream contributors.
git subtree add --prefix src/ai/backend/vendor/LIB subtree-LIB main --squash
```

Include it in our build chain by adding `BUILD` and `VERSION` files.

```
cp src/ai/backend/vendor/asyncudp/BUILD src/ai/backend/vendor/LIB/BUILD # use as reference
$EDITOR src/ai/backend/vendor/LIB/BUILD
cd src/ai/backend/vendor/LIB
ln -s ../../../../../VERSION
git add src/ai/backend/vendor/LIB
```

Update all existing references (if applicable) to the library like:

```diff
- import LIB
+ from ai.backend.vendor import LIB
```

Remove it from `requirements.txt` and regenerate the lockfiles if necessary.

```
$EDITOR requirements.txt
pants generate-lockfiles --resolve=python-default
```


## Updating an existing vendored libary

It is recommended to create a new branch first before running the following commands:

```
# NOTE: --squash is to required to avoid CLA signing issues from the upstream contributors.
git subtree pull --prefix src/ai/backend/vendor/LIB subtree-LIB main --squash
git push
```

Then create a pull request to ensure CI checks.
1 change: 1 addition & 0 deletions src/ai/backend/vendor/asyncudp/.github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: eerimoq
50 changes: 50 additions & 0 deletions src/ai/backend/vendor/asyncudp/.github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Test

on:
push:
pull_request:

jobs:

linux:

runs-on: ubuntu-20.04
strategy:
max-parallel: 4
matrix:
python-version: [3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Test
run: |
python -m unittest
release:
needs: [linux]
runs-on: ubuntu-20.04
if: startsWith(github.ref, 'refs/tags')

steps:
- name: Checkout
uses: actions/checkout@v1
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: 3.9
- name: Install pypa/build
run: |
python -m pip install build --user
- name: Build a source tarball
run: |
git clean -dfx
python -m build --sdist --outdir dist/ .
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
skip_existing: true
password: ${{secrets.pypi_password}}
72 changes: 72 additions & 0 deletions src/ai/backend/vendor/asyncudp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so
*.o
a.out

# Distribution / packaging
.Python
env/
venv/
.venv/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Vim IDE
*~
*.swp
*.swo

# IntelliJ IDEA
.idea/

# pyenv
.python-version
29 changes: 29 additions & 0 deletions src/ai/backend/vendor/asyncudp/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
python_sources(
name="src",
dependencies=[
":version",
],
# Since this is a vendored libary, we don't force our linters/checkers.
skip_black=True,
skip_flake8=True,
skip_isort=True,
skip_mypy=True,
)

python_distribution(
name="dist",
dependencies=[
":src",
"!!stubs/trafaret:stubs",
],
provides=python_artifact(
name="backend.ai-vendor-asyncudp",
description="asyncudp",
license="MIT",
),
entry_points={},
generate_setup=True,
tags=["wheel"],
)

resource(name="version", source="VERSION")
22 changes: 22 additions & 0 deletions src/ai/backend/vendor/asyncudp/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2021 Erik Moqvist

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

2 changes: 2 additions & 0 deletions src/ai/backend/vendor/asyncudp/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include LICENSE
recursive-include tests *.py
56 changes: 56 additions & 0 deletions src/ai/backend/vendor/asyncudp/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Asyncio high level UDP sockets
==============================

Asyncio high level UDP sockets.

Project homepage: https://github.com/eerimoq/asyncudp

Documentation: https://asyncudp.readthedocs.org/en/latest

Installation
============

.. code-block:: python
$ pip install asyncudp
Example client
==============

.. code-block:: python
import asyncio
import asyncudp
async def main():
sock = await asyncudp.create_socket(remote_addr=('127.0.0.1', 9999))
sock.sendto(b'Hello!')
print(await sock.recvfrom())
sock.close()
asyncio.run(main())
Example server
==============

.. code-block:: python
import asyncio
import asyncudp
async def main():
sock = await asyncudp.create_socket(local_addr=('127.0.0.1', 9999))
while True:
data, addr = await sock.recvfrom()
print(data, addr)
sock.sendto(data, addr)
asyncio.run(main())
Test
====

.. code-block::
$ python3 -m unittest
1 change: 1 addition & 0 deletions src/ai/backend/vendor/asyncudp/VERSION
Loading
Loading