From 991bab615b38c1cca75c98a6c9ecff4ec7c2d6d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Baz=20Castillo?= Date: Thu, 14 Sep 2023 18:46:32 +0200 Subject: [PATCH] pending things --- .../workflows/mediasoup-client-aiortc.yaml | 43 +++++++++++++++++++ README.md | 30 ++++++++++--- npm-scripts.mjs | 41 +++++++++++------- package-lock.json | 4 +- package.json | 6 ++- src/FakeRTCDataChannel.ts | 2 + src/Handler.ts | 4 ++ worker/handler.py | 1 + worker/setup.py | 6 +-- 9 files changed, 108 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/mediasoup-client-aiortc.yaml diff --git a/.github/workflows/mediasoup-client-aiortc.yaml b/.github/workflows/mediasoup-client-aiortc.yaml new file mode 100644 index 0000000..a3ad737 --- /dev/null +++ b/.github/workflows/mediasoup-client-aiortc.yaml @@ -0,0 +1,43 @@ +name: mediasoup-client-aiortc + +on: [push, pull_request] + +concurrency: + # Cancel a currently running workflow from the same PR, branch or tag when a + # new workflow is triggered. + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + ci: + strategy: + matrix: + # Different Node versions on Ubuntu, the latest Node on other platforms. + ci: + - os: ubuntu-22.04 + node: 16 + - os: macos-12 + node: 18 + runs-on: ${{ matrix.ci.os }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Node.js + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.ci.node }} + + - name: Configure cache + uses: actions/cache@v3 + with: + path: | + ~/.npm + key: ${{ matrix.ci.os }}-node-${{ hashFiles('**/package.json') }} + restore-keys: | + ${{ matrix.ci.os }}-node- + - run: npm ci + - run: npm run lint + - run: npm run test + - run: npm run release:check diff --git a/README.md b/README.md index a87621d..040b9ce 100644 --- a/README.md +++ b/README.md @@ -16,16 +16,16 @@ Once the requirements above are satisfied, install **mediasoup-client-aiortc** w $ npm install --save mediasoup-client-aiortc ``` -The "postinstall" script in `package.json` will install the Python libraries (including **aiortc**) by using `pip3` command. If such a command is not in the `PATH` or has a different name in your system, you can override its location by setting the `PIP3` environment variable: +The "postinstall" script in `package.json` will install the Python libraries (including **aiortc**) by using `pip3` command. If such a command is not in the `PATH` or has a different name in your system, you can override its location by setting the `PIP` environment variable: ```bash $ PIP3=/home/me/bin/pip npm install --save mediasoup-client-aiortc ``` -Once you run your Node.js application, **mediasoup-client-aiortc** will eventually spawn Python processes and communicate with them via `UnixSocket`. This module assumes that there is a `python3` executable in your `PATH` to spawn the Python executable. If not, you can override its location by setting the `PYTHON3` environment variable: +Once you run your Node.js application, **mediasoup-client-aiortc** will eventually spawn Python processes and communicate with them via `UnixSocket`. This module assumes that there is a `python3` executable in your `PATH` to spawn the Python executable. If not, you can override its location by setting the `PYTHON` environment variable: ```bash -$ PYTHON3=/home/me/bin/python-3.7 node my_app.js +$ PYTHON=/home/me/bin/python-3.7 node my_app.js ``` @@ -261,12 +261,30 @@ In order to run `npm run lint` task, the following Python dependencies are requi - `flake8` >= 5.0.4 - `mypy` >= 0.982 -Install them with `pip` command: - ```bash -$ pip3 install flake8==5.0.4 mypy==0.982 +$ npm run install-python-dev-deps ``` +### Issue with Python >= 3.11 + +See https://github.com/versatica/mediasoup-client-aiortc/issues/22. + +As a workaround: + +1. Install `python@3.10`. +2. Make `PYTHON` environment variable point to it: + ```bash + export PYTHON=python3.10 + ``` +3. Make `PIP` environment variable point to `pip@3.10`: + ```bash + export PIP=pip.10 + ``` +4. Install deps: + ```bash + npm ci + ``` + ## Caveats diff --git a/npm-scripts.mjs b/npm-scripts.mjs index b6131b7..b5c776c 100644 --- a/npm-scripts.mjs +++ b/npm-scripts.mjs @@ -63,6 +63,20 @@ async function run() break; } + case 'lint:node': + { + lintNode(); + + break; + } + + case 'lint:python': + { + lintPython(); + + break; + } + case 'test': { buildTypescript(/* force */ false); @@ -186,14 +200,6 @@ function buildTypescript(force = false) executeCmd('tsc'); } -function lint() -{ - logInfo('lint()'); - - lintNode(); - lintPython(); -} - function lintNode() { logInfo('lintNode()'); @@ -205,10 +211,10 @@ function lintPython() { logInfo('lintPython()'); - const PYTHON3 = process.env.PYTHON3 || 'python3'; + const PYTHON = process.env.PYTHON || 'python3'; - executeCmd(`cd worker && ${PYTHON3} -m flake8 && cd ..`); - executeCmd(`cd worker && ${PYTHON3} -m mypy . && cd ..`); + executeCmd(`cd worker && ${PYTHON} -m flake8 && cd ..`); + executeCmd(`cd worker && ${PYTHON} -m mypy . && cd ..`); } function test() @@ -232,18 +238,18 @@ function installPythonDeps() { logInfo('installPythonDeps()'); - const PYP3 = process.env.PIP3 || 'pip3'; + const PIP = process.env.PIP || 'pip3'; - executeCmd(`${PYP3} install --user worker/`); + executeCmd(`${PIP} install --user worker/`); } function installPythonDevDeps() { logInfo('installPythonDevDeps()'); - const PYP3 = process.env.PIP3 || 'pip3'; + const PIP = process.env.PIP || 'pip3'; - executeCmd(`${PYP3} install flake8 mypy`); + executeCmd(`${PIP} install flake8 mypy`); } function checkRelease() @@ -254,7 +260,10 @@ function checkRelease() installPythonDeps(); buildTypescript(/* force */ true); replaceVersion(); - lint(); + lintNode(); + // TODO: Disabled due to + // https://github.com/versatica/mediasoup-client-aiortc/issues/25 + // lintPython(); test(); } diff --git a/package-lock.json b/package-lock.json index 6de25d8..7be932a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mediasoup-client-aiortc", - "version": "3.7.2", + "version": "3.7.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mediasoup-client-aiortc", - "version": "3.7.2", + "version": "3.7.3", "hasInstallScript": true, "license": "ISC", "os": [ diff --git a/package.json b/package.json index ea0d1b0..ee121e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mediasoup-client-aiortc", - "version": "3.7.2", + "version": "3.7.3", "description": "mediasoup-client handler for aiortc Python library", "contributors": [ "José Luis Millán (https://github.com/jmillan)", @@ -29,7 +29,9 @@ "postinstall": "node npm-scripts.mjs postinstall", "typescript:build": "node npm-scripts.mjs typescript:build", "typescript:watch": "node npm-scripts.mjs typescript:watch", - "lint": "node npm-scripts.mjs lint", + "lint": "npm run lint:node && npm run lint:python", + "lint:node": "node npm-scripts.mjs lint:node", + "lint:python": "node npm-scripts.mjs lint:python", "test": "node npm-scripts.mjs test", "coverage": "node npm-scripts.mjs coverage", "release:check": "node npm-scripts.mjs release:check", diff --git a/src/FakeRTCDataChannel.ts b/src/FakeRTCDataChannel.ts index 252b4a7..7a91e7e 100644 --- a/src/FakeRTCDataChannel.ts +++ b/src/FakeRTCDataChannel.ts @@ -20,6 +20,8 @@ export type FakeRTCDataChannelOptions = protocol?: string; }; +// TODO: https://github.com/versatica/mediasoup-client-aiortc/issues/24 +// @ts-ignore export class FakeRTCDataChannel extends EventTarget implements RTCDataChannel { // Internal data. diff --git a/src/Handler.ts b/src/Handler.ts index 9761f60..2a7e5a7 100644 --- a/src/Handler.ts +++ b/src/Handler.ts @@ -742,6 +742,8 @@ export class Handler extends HandlerInterface }; return { + // TODO: https://github.com/versatica/mediasoup-client-aiortc/issues/24 + // @ts-ignore dataChannel, sctpStreamParameters }; @@ -1119,6 +1121,8 @@ export class Handler extends HandlerInterface this.#hasDataChannelMediaSection = true; } + // TODO: https://github.com/versatica/mediasoup-client-aiortc/issues/24 + // @ts-ignore return { dataChannel }; } diff --git a/worker/handler.py b/worker/handler.py index db4e7f8..c4db615 100644 --- a/worker/handler.py +++ b/worker/handler.py @@ -8,6 +8,7 @@ RTCSessionDescription, RTCStatsReport ) +from aiortc import RTCDataChannel # noqa: F401 from channel import Request, Notification, Channel from logger import Logger diff --git a/worker/setup.py b/worker/setup.py index ecfacff..c8526ed 100644 --- a/worker/setup.py +++ b/worker/setup.py @@ -2,12 +2,12 @@ setuptools.setup( name="mediasoup-client-aiortc", - version="3.7.2", + version="3.7.3", description="mediasoup-client handler for aiortc Python library", - url="http://github.com/versatica/mediasoup-client-aiortc", + url="https://github.com/versatica/mediasoup-client-aiortc", author="José Luis Millán Villegas, Iñaki Baz Castillo", author_email="jmillan@aliax.net, ibc@aliax.net", - license="MIT", + license="ISC", packages=setuptools.find_packages(), install_requires=[ "aiortc>=1.3.2",