ipyaudio 0.1.0.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
__tests__/index.spec.ts
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
3
|
+
|
4
|
+
// Add any needed widget imports here (or from controls)
|
5
|
+
// import {} from '@jupyter-widgets/base';
|
6
|
+
|
7
|
+
import { createTestModel } from './utils';
|
8
|
+
|
9
|
+
import { ExampleModel } from '..';
|
10
|
+
|
11
|
+
describe('Example', () => {
|
12
|
+
describe('ExampleModel', () => {
|
13
|
+
it('should be createable', () => {
|
14
|
+
const model = createTestModel(ExampleModel);
|
15
|
+
expect(model).toBeInstanceOf(ExampleModel);
|
16
|
+
expect(model.get('value')).toEqual('Hello World');
|
17
|
+
});
|
18
|
+
|
19
|
+
it('should be createable with a value', () => {
|
20
|
+
const state = { value: 'Foo Bar!' };
|
21
|
+
const model = createTestModel(ExampleModel, state);
|
22
|
+
expect(model).toBeInstanceOf(ExampleModel);
|
23
|
+
expect(model.get('value')).toEqual('Foo Bar!');
|
24
|
+
});
|
25
|
+
});
|
26
|
+
});
|
__tests__/utils.ts
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
3
|
+
|
4
|
+
import * as widgets from '@jupyter-widgets/base';
|
5
|
+
import * as baseManager from '@jupyter-widgets/base-manager';
|
6
|
+
import * as services from '@jupyterlab/services';
|
7
|
+
|
8
|
+
let numComms = 0;
|
9
|
+
|
10
|
+
export class MockComm implements widgets.IClassicComm {
|
11
|
+
constructor() {
|
12
|
+
this.comm_id = `mock-comm-id-${numComms}`;
|
13
|
+
numComms += 1;
|
14
|
+
}
|
15
|
+
on_close(fn: ((x?: any) => void) | null): void {
|
16
|
+
this._on_close = fn;
|
17
|
+
}
|
18
|
+
on_msg(fn: (x?: any) => void): void {
|
19
|
+
this._on_msg = fn;
|
20
|
+
}
|
21
|
+
_process_msg(msg: services.KernelMessage.ICommMsgMsg): void | Promise<void> {
|
22
|
+
if (this._on_msg) {
|
23
|
+
return this._on_msg(msg);
|
24
|
+
} else {
|
25
|
+
return Promise.resolve();
|
26
|
+
}
|
27
|
+
}
|
28
|
+
close(): string {
|
29
|
+
if (this._on_close) {
|
30
|
+
this._on_close();
|
31
|
+
}
|
32
|
+
return 'dummy';
|
33
|
+
}
|
34
|
+
send(): string {
|
35
|
+
return 'dummy';
|
36
|
+
}
|
37
|
+
|
38
|
+
open(): string {
|
39
|
+
return 'dummy';
|
40
|
+
}
|
41
|
+
|
42
|
+
comm_id: string;
|
43
|
+
target_name = 'dummy';
|
44
|
+
_on_msg: ((x?: any) => void) | null = null;
|
45
|
+
_on_close: ((x?: any) => void) | null = null;
|
46
|
+
}
|
47
|
+
|
48
|
+
export class DummyManager extends baseManager.ManagerBase {
|
49
|
+
constructor() {
|
50
|
+
super();
|
51
|
+
this.el = window.document.createElement('div');
|
52
|
+
}
|
53
|
+
|
54
|
+
display_view(
|
55
|
+
msg: services.KernelMessage.IMessage,
|
56
|
+
view: widgets.DOMWidgetView,
|
57
|
+
options: any
|
58
|
+
) {
|
59
|
+
// TODO: make this a spy
|
60
|
+
// TODO: return an html element
|
61
|
+
return Promise.resolve(view).then((view) => {
|
62
|
+
this.el.appendChild(view.el);
|
63
|
+
view.on('remove', () => console.log('view removed', view));
|
64
|
+
return view.el;
|
65
|
+
});
|
66
|
+
}
|
67
|
+
|
68
|
+
protected loadClass(
|
69
|
+
className: string,
|
70
|
+
moduleName: string,
|
71
|
+
moduleVersion: string
|
72
|
+
): Promise<any> {
|
73
|
+
if (moduleName === '@jupyter-widgets/base') {
|
74
|
+
if ((widgets as any)[className]) {
|
75
|
+
return Promise.resolve((widgets as any)[className]);
|
76
|
+
} else {
|
77
|
+
return Promise.reject(`Cannot find class ${className}`);
|
78
|
+
}
|
79
|
+
} else if (moduleName === 'jupyter-datawidgets') {
|
80
|
+
if (this.testClasses[className]) {
|
81
|
+
return Promise.resolve(this.testClasses[className]);
|
82
|
+
} else {
|
83
|
+
return Promise.reject(`Cannot find class ${className}`);
|
84
|
+
}
|
85
|
+
} else {
|
86
|
+
return Promise.reject(`Cannot find module ${moduleName}`);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
_get_comm_info() {
|
91
|
+
return Promise.resolve({});
|
92
|
+
}
|
93
|
+
|
94
|
+
_create_comm() {
|
95
|
+
return Promise.resolve(new MockComm());
|
96
|
+
}
|
97
|
+
|
98
|
+
el: HTMLElement;
|
99
|
+
|
100
|
+
testClasses: { [key: string]: any } = {};
|
101
|
+
}
|
102
|
+
|
103
|
+
export interface Constructor<T> {
|
104
|
+
new (attributes?: any, options?: any): T;
|
105
|
+
}
|
106
|
+
|
107
|
+
export function createTestModel<T extends widgets.WidgetModel>(
|
108
|
+
constructor: Constructor<T>,
|
109
|
+
attributes?: any
|
110
|
+
): T {
|
111
|
+
const id = widgets.uuid();
|
112
|
+
const widget_manager = new DummyManager();
|
113
|
+
const modelOptions = {
|
114
|
+
widget_manager: widget_manager,
|
115
|
+
model_id: id,
|
116
|
+
};
|
117
|
+
|
118
|
+
return new constructor(attributes, modelOptions);
|
119
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Copyright (c) 2025 Zhendong Peng
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
8
|
+
list of conditions and the following disclaimer.
|
9
|
+
|
10
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
12
|
+
and/or other materials provided with the distribution.
|
13
|
+
|
14
|
+
3. Neither the name of the copyright holder nor the names of its
|
15
|
+
contributors may be used to endorse or promote products derived from
|
16
|
+
this software without specific prior written permission.
|
17
|
+
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
19
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
20
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
21
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
22
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
23
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
24
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
25
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
26
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
27
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -0,0 +1,149 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: ipyaudio
|
3
|
+
Version: 0.1.0.dev0
|
4
|
+
Summary: A Custom Jupyter Widget Library
|
5
|
+
Author-email: Zhendong Peng <pzd17@tsinghua.org.cn>
|
6
|
+
License: Copyright (c) 2025 Zhendong Peng
|
7
|
+
All rights reserved.
|
8
|
+
|
9
|
+
Redistribution and use in source and binary forms, with or without
|
10
|
+
modification, are permitted provided that the following conditions are met:
|
11
|
+
|
12
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
13
|
+
list of conditions and the following disclaimer.
|
14
|
+
|
15
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
16
|
+
this list of conditions and the following disclaimer in the documentation
|
17
|
+
and/or other materials provided with the distribution.
|
18
|
+
|
19
|
+
3. Neither the name of the copyright holder nor the names of its
|
20
|
+
contributors may be used to endorse or promote products derived from
|
21
|
+
this software without specific prior written permission.
|
22
|
+
|
23
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
24
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
25
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
26
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
27
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
28
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
29
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
30
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
31
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
32
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
33
|
+
|
34
|
+
Project-URL: Homepage, https://github.com/pengzhendong/ipyaudio
|
35
|
+
Keywords: IPython,Jupyter,Widgets
|
36
|
+
Classifier: Framework :: Jupyter
|
37
|
+
Classifier: Intended Audience :: Developers
|
38
|
+
Classifier: Intended Audience :: Science/Research
|
39
|
+
Classifier: License :: OSI Approved :: BSD License
|
40
|
+
Classifier: Programming Language :: Python
|
41
|
+
Classifier: Programming Language :: Python :: 3
|
42
|
+
Classifier: Programming Language :: Python :: 3.7
|
43
|
+
Classifier: Programming Language :: Python :: 3.8
|
44
|
+
Classifier: Programming Language :: Python :: 3.9
|
45
|
+
Classifier: Programming Language :: Python :: 3.10
|
46
|
+
Classifier: Programming Language :: Python :: 3.11
|
47
|
+
Classifier: Programming Language :: Python :: 3.12
|
48
|
+
Requires-Python: >=3.9
|
49
|
+
Description-Content-Type: text/markdown
|
50
|
+
License-File: LICENSE.txt
|
51
|
+
Requires-Dist: ipywidgets>=8.0.0
|
52
|
+
Provides-Extra: docs
|
53
|
+
Requires-Dist: jupyter_sphinx; extra == "docs"
|
54
|
+
Requires-Dist: nbsphinx; extra == "docs"
|
55
|
+
Requires-Dist: nbsphinx-link; extra == "docs"
|
56
|
+
Requires-Dist: pypandoc; extra == "docs"
|
57
|
+
Requires-Dist: pytest_check_links; extra == "docs"
|
58
|
+
Requires-Dist: recommonmark; extra == "docs"
|
59
|
+
Requires-Dist: sphinx>=1.5; extra == "docs"
|
60
|
+
Requires-Dist: sphinx_rtd_theme; extra == "docs"
|
61
|
+
Provides-Extra: examples
|
62
|
+
Provides-Extra: test
|
63
|
+
Requires-Dist: nbval; extra == "test"
|
64
|
+
Requires-Dist: pytest-cov; extra == "test"
|
65
|
+
Requires-Dist: pytest>=6.0; extra == "test"
|
66
|
+
|
67
|
+
|
68
|
+
# ipyaudio
|
69
|
+
|
70
|
+
[](https://travis-ci.org/pengzhendong/ipyaudio)
|
71
|
+
[](https://codecov.io/gh/pengzhendong/ipyaudio)
|
72
|
+
|
73
|
+
|
74
|
+
A Custom Jupyter Widget Library
|
75
|
+
|
76
|
+
## Installation
|
77
|
+
|
78
|
+
You can install using `pip`:
|
79
|
+
|
80
|
+
```bash
|
81
|
+
pip install ipyaudio
|
82
|
+
```
|
83
|
+
|
84
|
+
If you are using Jupyter Notebook 5.2 or earlier, you may also need to enable
|
85
|
+
the nbextension:
|
86
|
+
```bash
|
87
|
+
jupyter nbextension enable --py [--sys-prefix|--user|--system] ipyaudio
|
88
|
+
```
|
89
|
+
|
90
|
+
## Development Installation
|
91
|
+
|
92
|
+
Create a dev environment:
|
93
|
+
```bash
|
94
|
+
conda create -n ipyaudio-dev -c conda-forge nodejs python jupyterlab=4.0.11
|
95
|
+
conda activate ipyaudio-dev
|
96
|
+
```
|
97
|
+
|
98
|
+
Install the python. This will also build the TS package.
|
99
|
+
```bash
|
100
|
+
pip install -e ".[test, examples]"
|
101
|
+
```
|
102
|
+
|
103
|
+
When developing your extensions, you need to manually enable your extensions with the
|
104
|
+
notebook / lab frontend. For lab, this is done by the command:
|
105
|
+
|
106
|
+
```
|
107
|
+
jupyter labextension develop --overwrite .
|
108
|
+
jlpm run build
|
109
|
+
```
|
110
|
+
|
111
|
+
For classic notebook, you need to run:
|
112
|
+
|
113
|
+
```
|
114
|
+
jupyter nbextension install --sys-prefix --symlink --overwrite --py ipyaudio
|
115
|
+
jupyter nbextension enable --sys-prefix --py ipyaudio
|
116
|
+
```
|
117
|
+
|
118
|
+
Note that the `--symlink` flag doesn't work on Windows, so you will here have to run
|
119
|
+
the `install` command every time that you rebuild your extension. For certain installations
|
120
|
+
you might also need another flag instead of `--sys-prefix`, but we won't cover the meaning
|
121
|
+
of those flags here.
|
122
|
+
|
123
|
+
### How to see your changes
|
124
|
+
#### Typescript:
|
125
|
+
If you use JupyterLab to develop then you can watch the source directory and run JupyterLab at the same time in different
|
126
|
+
terminals to watch for changes in the extension's source and automatically rebuild the widget.
|
127
|
+
|
128
|
+
```bash
|
129
|
+
# Watch the source directory in one terminal, automatically rebuilding when needed
|
130
|
+
jlpm run watch
|
131
|
+
# Run JupyterLab in another terminal
|
132
|
+
jupyter lab
|
133
|
+
```
|
134
|
+
|
135
|
+
After a change wait for the build to finish and then refresh your browser and the changes should take effect.
|
136
|
+
|
137
|
+
#### Python:
|
138
|
+
If you make a change to the python code then you will need to restart the notebook kernel to have it take effect.
|
139
|
+
|
140
|
+
## Updating the version
|
141
|
+
|
142
|
+
To update the version, install tbump and use it to bump the version.
|
143
|
+
By default it will also create a tag.
|
144
|
+
|
145
|
+
```bash
|
146
|
+
pip install tbump
|
147
|
+
tbump <new-version>
|
148
|
+
```
|
149
|
+
|
@@ -0,0 +1,7 @@
|
|
1
|
+
__tests__/index.spec.ts,sha256=cuDep-5X8lJZtivosDeCo5D6NgguX57dWy8L3YDRnWo,829
|
2
|
+
__tests__/utils.ts,sha256=505Bow1dDsRjgxW5TaQywQX4tNUCKz4g8IRumd73w4I,2909
|
3
|
+
ipyaudio-0.1.0.dev0.dist-info/LICENSE.txt,sha256=-uZ5GSv8HIaOXcLH77MEBajSXj7X8T5N989WfkUFYKc,1498
|
4
|
+
ipyaudio-0.1.0.dev0.dist-info/METADATA,sha256=--f7_jllwPtUkv1nrC-fRF28yPBqE61dSOEO3fVRp_s,5601
|
5
|
+
ipyaudio-0.1.0.dev0.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
6
|
+
ipyaudio-0.1.0.dev0.dist-info/top_level.txt,sha256=ogl6oM0DgCZBVOdY5C6S83CuXc_cgKdnHLgkb741pYU,10
|
7
|
+
ipyaudio-0.1.0.dev0.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
__tests__
|