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 some old source-only dependencies #1370

Closed
wants to merge 10 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 .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ src/ai/backend/runner/*.ttf filter=lfs diff=lfs merge=lfs -text
src/ai/backend/runner/*.bin filter=lfs diff=lfs merge=lfs -text
src/ai/backend/runner/*.so filter=lfs diff=lfs merge=lfs -text
src/ai/backend/runner/*.tar.xz filter=lfs diff=lfs merge=lfs -text
vendor/wheelhouse/*.whl filter=lfs diff=lfs merge=lfs -text
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,6 @@ logs

.python-runtime

docs/manager/rest-reference/openapi.json
docs/manager/rest-reference/openapi.json
/vendor/*/build/
/vendor/*/dist/
1 change: 1 addition & 0 deletions changes/1370.deps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Vendor `asyncudp` and `temporenc` into the `vendor/` directory with precompiled wheels to avoid packaging issues
7 changes: 7 additions & 0 deletions pants.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pants_ignore = [
"/docs/", # TODO: docs build config
"*.log",
"/tools/pants-plugins",
"/vendor/",
"!/vendor/wheelhouse",
]

[anonymous-telemetry]
Expand Down Expand Up @@ -57,6 +59,11 @@ search_path = ["<PYENV>"]

[python-repos]
indexes = ["https://dist.backend.ai/pypi/simple/", "https://pypi.org/simple/"]
find_links = ["file://%(buildroot)s/vendor/wheelhouse"]
path_mappings = ["WHEELS_DIR|%(buildroot)s/vendor/wheelhouse"]

[python.resolves_to_constraints_file]
python-default = "constraints.txt"

[python.resolves]
python-default = "python.lock"
Expand Down
361 changes: 190 additions & 171 deletions python.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions 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 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 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
22 changes: 22 additions & 0 deletions 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 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 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
125 changes: 125 additions & 0 deletions vendor/asyncudp/asyncudp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import asyncio

from .version import __version__


class ClosedError(Exception):
pass


class _SocketProtocol:

def __init__(self, packets_queue_max_size):
self._error = None
self._packets = asyncio.Queue(packets_queue_max_size)

def connection_made(self, transport):
pass

def connection_lost(self, transport):
self._packets.put_nowait(None)

def datagram_received(self, data, addr):
self._packets.put_nowait((data, addr))

def error_received(self, exc):
self._error = exc
self._packets.put_nowait(None)

async def recvfrom(self):
return await self._packets.get()

def raise_if_error(self):
if self._error is None:
return

error = self._error
self._error = None

raise error


class Socket:
"""A UDP socket. Use :func:`~asyncudp.create_socket()` to create an
instance of this class.

"""

def __init__(self, transport, protocol):
self._transport = transport
self._protocol = protocol

def close(self):
"""Close the socket.

"""

self._transport.close()

def sendto(self, data, addr=None):
"""Send given packet to given address ``addr``. Sends to
``remote_addr`` given to the constructor if ``addr`` is
``None``.

Raises an error if a connection error has occurred.

>>> sock.sendto(b'Hi!')

"""

self._transport.sendto(data, addr)
self._protocol.raise_if_error()

async def recvfrom(self):
"""Receive a UDP packet.

Raises ClosedError on connection error, often by calling the
close() method from another task. May raise other errors as
well.

>>> data, addr = sock.recvfrom()

"""

packet = await self._protocol.recvfrom()
self._protocol.raise_if_error()

if packet is None:
raise ClosedError()

return packet

def getsockname(self):
"""Get bound infomation.

>>> local_address, local_port = sock.getsockname()

"""

return self._transport.get_extra_info('sockname')

async def __aenter__(self):
return self

async def __aexit__(self, *exc_info):
self.close()


async def create_socket(local_addr=None,
remote_addr=None,
packets_queue_max_size=0,
reuse_port=None):
"""Create a UDP socket with given local and remote addresses.

>>> sock = await asyncudp.create_socket(local_addr=('127.0.0.1', 9999))

"""

loop = asyncio.get_running_loop()
transport, protocol = await loop.create_datagram_endpoint(
lambda: _SocketProtocol(packets_queue_max_size),
local_addr=local_addr,
remote_addr=remote_addr,
reuse_port=reuse_port)

return Socket(transport, protocol)
1 change: 1 addition & 0 deletions vendor/asyncudp/asyncudp/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.10.0'
Loading
Loading