Skip to content

Commit

Permalink
pending things
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Sep 14, 2023
1 parent 6f14ccc commit 991bab6
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 29 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/mediasoup-client-aiortc.yaml
Original file line number Diff line number Diff line change
@@ -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
30 changes: 24 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```


Expand Down Expand Up @@ -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 `[email protected]`:
```bash
export PIP=pip.10
```
4. Install deps:
```bash
npm ci
```


## Caveats

Expand Down
41 changes: 25 additions & 16 deletions npm-scripts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ async function run()
break;
}

case 'lint:node':
{
lintNode();

break;
}

case 'lint:python':
{
lintPython();

break;
}

case 'test':
{
buildTypescript(/* force */ false);
Expand Down Expand Up @@ -186,14 +200,6 @@ function buildTypescript(force = false)
executeCmd('tsc');
}

function lint()
{
logInfo('lint()');

lintNode();
lintPython();
}

function lintNode()
{
logInfo('lintNode()');
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]> (https://github.com/jmillan)",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/FakeRTCDataChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions src/Handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,8 @@ export class Handler extends HandlerInterface
};

return {
// TODO: https://github.com/versatica/mediasoup-client-aiortc/issues/24
// @ts-ignore
dataChannel,
sctpStreamParameters
};
Expand Down Expand Up @@ -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 };
}

Expand Down
1 change: 1 addition & 0 deletions worker/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
RTCSessionDescription,
RTCStatsReport
)
from aiortc import RTCDataChannel # noqa: F401

from channel import Request, Notification, Channel
from logger import Logger
Expand Down
6 changes: 3 additions & 3 deletions worker/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected], [email protected]",
license="MIT",
license="ISC",
packages=setuptools.find_packages(),
install_requires=[
"aiortc>=1.3.2",
Expand Down

0 comments on commit 991bab6

Please sign in to comment.