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

Set up py3-only tools/quic and its venv #23075

Merged
merged 3 commits into from
Apr 21, 2020
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
Empty file added tools/quic/__init__.py
Empty file.
13 changes: 13 additions & 0 deletions tools/quic/commands.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"servequic": {
"path": "serve.py",
"script": "run",
"parser": "get_parser",
"py3only": true,
"help": "Start the QUIC server",
"virtualenv": true,
"requirements": [
"requirements.txt"
]
}
}
1 change: 1 addition & 0 deletions tools/quic/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aioquic==0.8.7
28 changes: 28 additions & 0 deletions tools/quic/serve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python3

import argparse
import sys


def get_parser():
parser = argparse.ArgumentParser()
parser.add_argument("--verbose", action="store_true", default=False,
help="turn on verbose logging")
return parser


def run(venv, **kwargs):
# TODO(Hexcles): Replace this with actual implementation.
print(sys.version)
assert sys.version_info.major == 3
import aioquic
print('aioquic: ' + aioquic.__version__)


def main():
kwargs = vars(get_parser().parse_args())
return run(None, **kwargs)


if __name__ == '__main__':
main()
12 changes: 12 additions & 0 deletions tools/third_party/aioquic/.appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
environment:
CIBW_SKIP: cp27-* cp33-* cp34-*
CIBW_TEST_COMMAND: python -m unittest discover -s {project}/tests
install:
- cmd: C:\Python36-x64\python.exe -m pip install cibuildwheel
build_script:
- cmd: C:\Python36-x64\python.exe -m cibuildwheel --output-dir wheelhouse
- ps: >-
if ($env:APPVEYOR_REPO_TAG -eq "true") {
Invoke-Expression "python -m pip install twine"
Invoke-Expression "python -m twine upload --skip-existing wheelhouse/*.whl"
}
1 change: 1 addition & 0 deletions tools/third_party/aioquic/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.bin binary
128 changes: 128 additions & 0 deletions tools/third_party/aioquic/.github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: tests

on: [push, pull_request]

jobs:

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install packages
run: pip install black flake8 isort mypy
- name: Run linters
run: |
flake8 examples src tests
isort -c -df -rc examples src tests
black --check --diff examples src tests
mypy examples src

test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: [3.8, 3.7, 3.6]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python }}
- name: Disable firewall and configure compiler
if: matrix.os == 'macos-latest'
run: |
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off
echo "::set-env name=AIOQUIC_SKIP_TESTS::chacha20"
echo "::set-env name=CFLAGS::-I/usr/local/opt/openssl/include"
echo "::set-env name=LDFLAGS::-L/usr/local/opt/openssl/lib"
- name: Install OpenSSL
if: matrix.os == 'windows-latest'
run: |
choco install openssl --no-progress
echo "::set-env name=CL::/IC:\Progra~1\OpenSSL-Win64\include"
echo "::set-env name=LINK::/LIBPATH:C:\Progra~1\OpenSSL-Win64\lib"
- name: Run tests
run: |
pip install -U pip setuptools wheel
pip install coverage
pip install .
coverage run -m unittest discover -v
coverage xml
shell: bash
- name: Upload coverage report
uses: codecov/codecov-action@v1
if: matrix.python != 'pypy3'
with:
token: ${{ secrets.CODECOV_TOKEN }}

package-source:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Build source package
run: python setup.py sdist
- name: Upload source package
uses: actions/upload-artifact@v1
with:
name: dist
path: dist/

package-wheel:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install nasm
if: matrix.os == 'windows-latest'
run: choco install -y nasm
- name: Install nmake
if: matrix.os == 'windows-latest'
run: |
& "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" modify `
--installPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" `
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --passive --norestart
shell: powershell
- name: Build wheels
env:
CIBW_BEFORE_BUILD: scripts/build-openssl /tmp/vendor
CIBW_BEFORE_BUILD_WINDOWS: scripts\build-openssl.bat C:\cibw\vendor
CIBW_ENVIRONMENT: AIOQUIC_SKIP_TESTS=ipv6,loss CFLAGS=-I/tmp/vendor/include LDFLAGS=-L/tmp/vendor/lib
CIBW_ENVIRONMENT_WINDOWS: AIOQUIC_SKIP_TESTS=ipv6,loss CL="/IC:\cibw\vendor\include" LINK="/LIBPATH:C:\cibw\vendor\lib"
CIBW_SKIP: cp27-* cp33-* cp34-* cp35-* pp27-*
CIBW_TEST_COMMAND: python -m unittest discover -t {project} -s {project}/tests
run: |
pip install cibuildwheel
cibuildwheel --output-dir dist
- name: Upload wheels
uses: actions/upload-artifact@v1
with:
name: dist
path: dist/

publish:
runs-on: ubuntu-latest
needs: [lint, test, package-source, package-wheel]
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v1
with:
name: dist
path: dist/
- name: Publish to PyPI
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
10 changes: 10 additions & 0 deletions tools/third_party/aioquic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.egg-info
*.pyc
*.so
.coverage
.eggs
.mypy_cache
.vscode
/build
/dist
/docs/_build
25 changes: 25 additions & 0 deletions tools/third_party/aioquic/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright (c) 2019 Jeremy Lainé.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of aioquic nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4 changes: 4 additions & 0 deletions tools/third_party/aioquic/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include LICENSE
recursive-include docs *.py *.rst Makefile
recursive-include examples *.html *.py
recursive-include tests *.bin *.pem *.py
164 changes: 164 additions & 0 deletions tools/third_party/aioquic/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
aioquic
=======

|rtd| |pypi-v| |pypi-pyversions| |pypi-l| |tests| |codecov| |black|

.. |rtd| image:: https://readthedocs.org/projects/aioquic/badge/?version=latest
:target: https://aioquic.readthedocs.io/

.. |pypi-v| image:: https://img.shields.io/pypi/v/aioquic.svg
:target: https://pypi.python.org/pypi/aioquic

.. |pypi-pyversions| image:: https://img.shields.io/pypi/pyversions/aioquic.svg
:target: https://pypi.python.org/pypi/aioquic

.. |pypi-l| image:: https://img.shields.io/pypi/l/aioquic.svg
:target: https://pypi.python.org/pypi/aioquic

.. |tests| image:: https://github.com/aiortc/aioquic/workflows/tests/badge.svg
:target: https://github.com/aiortc/aioquic/actions

.. |codecov| image:: https://img.shields.io/codecov/c/github/aiortc/aioquic.svg
:target: https://codecov.io/gh/aiortc/aioquic

.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/python/black

What is ``aioquic``?
--------------------

``aioquic`` is a library for the QUIC network protocol in Python. It features
a minimal TLS 1.3 implementation, a QUIC stack and an HTTP/3 stack.

QUIC standardisation is not finalised yet, but ``aioquic`` closely tracks the
specification drafts and is regularly tested for interoperability against other
`QUIC implementations`_.

To learn more about ``aioquic`` please `read the documentation`_.

Why should I use ``aioquic``?
-----------------------------

``aioquic`` has been designed to be embedded into Python client and server
libraries wishing to support QUIC and / or HTTP/3. The goal is to provide a
common codebase for Python libraries in the hope of avoiding duplicated effort.

Both the QUIC and the HTTP/3 APIs follow the "bring your own I/O" pattern,
leaving actual I/O operations to the API user. This approach has a number of
advantages including making the code testable and allowing integration with
different concurrency models.

Features
--------

- QUIC stack conforming with draft-27
- HTTP/3 stack conforming with draft-27
- minimal TLS 1.3 implementation
- IPv4 and IPv6 support
- connection migration and NAT rebinding
- logging TLS traffic secrets
- logging QUIC events in QLOG format
- HTTP/3 server push support

Requirements
------------

``aioquic`` requires Python 3.6 or better, and the OpenSSL development headers.

Linux
.....

On Debian/Ubuntu run:

.. code-block:: console

$ sudo apt install libssl-dev python3-dev

On Alpine Linux you will also need the following:

.. code-block:: console

$ sudo apt install bsd-compat-headers libffi-dev

OS X
....

On OS X run:

.. code-block:: console

$ brew install openssl

You will need to set some environment variables to link against OpenSSL:

.. code-block:: console

$ export CFLAGS=-I/usr/local/opt/openssl/include
$ export LDFLAGS=-L/usr/local/opt/openssl/lib

Windows
.......

On Windows the easiest way to install OpenSSL is to use `Chocolatey`_.

.. code-block:: console

> choco install openssl

You will need to set some environment variables to link against OpenSSL:

.. code-block:: console

> $Env:CL = "/IC:\Progra~1\OpenSSL-Win64\include"
> $Env:LINK = "/LIBPATH:C:\Progra~1\OpenSSL-Win64\lib"

Running the examples
--------------------

After checking out the code using git you can run:

.. code-block:: console

$ pip install -e .
$ pip install aiofiles asgiref httpbin starlette wsproto

HTTP/3 server
.............

You can run the example server, which handles both HTTP/0.9 and HTTP/3:

.. code-block:: console

$ python examples/http3_server.py --certificate tests/ssl_cert.pem --private-key tests/ssl_key.pem

HTTP/3 client
.............

You can run the example client to perform an HTTP/3 request:

.. code-block:: console

$ python examples/http3_client.py --ca-certs tests/pycacert.pem https://localhost:4433/

Alternatively you can perform an HTTP/0.9 request:

.. code-block:: console

$ python examples/http3_client.py --ca-certs tests/pycacert.pem --legacy-http https://localhost:4433/

You can also open a WebSocket over HTTP/3:

.. code-block:: console

$ python examples/http3_client.py --ca-certs tests/pycacert.pem wss://localhost:4433/ws

License
-------

``aioquic`` is released under the `BSD license`_.

.. _read the documentation: https://aioquic.readthedocs.io/en/latest/
.. _QUIC implementations: https://github.com/quicwg/base-drafts/wiki/Implementations
.. _cryptography: https://cryptography.io/
.. _Chocolatey: https://chocolatey.org/
.. _BSD license: https://aioquic.readthedocs.io/en/latest/license.html
Loading