libcsound 0.17.2__tar.gz → 0.17.4__tar.gz

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.
Files changed (54) hide show
  1. {libcsound-0.17.2 → libcsound-0.17.4}/.github/workflows/test.yml +36 -0
  2. {libcsound-0.17.2 → libcsound-0.17.4}/MANIFEST.in +1 -0
  3. {libcsound-0.17.2/libcsound.egg-info → libcsound-0.17.4}/PKG-INFO +16 -4
  4. {libcsound-0.17.2 → libcsound-0.17.4}/README.rst +15 -3
  5. {libcsound-0.17.2 → libcsound-0.17.4}/docs/introduction.rst +19 -11
  6. {libcsound-0.17.2 → libcsound-0.17.4}/docs/notebooks/01-Introduction.ipynb +1 -1
  7. {libcsound-0.17.2 → libcsound-0.17.4}/libcsound/__init__.py +3 -2
  8. {libcsound-0.17.2 → libcsound-0.17.4}/libcsound/_dll.py +92 -3
  9. libcsound-0.17.4/libcsound/data/getcsound.ps1 +382 -0
  10. {libcsound-0.17.2 → libcsound-0.17.4}/libcsound/data/getcsound.sh +91 -49
  11. {libcsound-0.17.2 → libcsound-0.17.4/libcsound.egg-info}/PKG-INFO +16 -4
  12. {libcsound-0.17.2 → libcsound-0.17.4}/libcsound.egg-info/SOURCES.txt +3 -1
  13. {libcsound-0.17.2 → libcsound-0.17.4}/pyproject.toml +2 -2
  14. libcsound-0.17.4/test/check-installer-sync.py +95 -0
  15. {libcsound-0.17.2 → libcsound-0.17.4}/test/linux-install-render.py +1 -1
  16. {libcsound-0.17.2 → libcsound-0.17.4}/test/macos-install-render.py +1 -1
  17. libcsound-0.17.4/test/windows-install-render.py +113 -0
  18. libcsound-0.17.2/test/check-installer-sync.py +0 -70
  19. {libcsound-0.17.2 → libcsound-0.17.4}/LICENSE +0 -0
  20. {libcsound-0.17.2 → libcsound-0.17.4}/cmake/csound-custom-macos.cmake +0 -0
  21. {libcsound-0.17.2 → libcsound-0.17.4}/docs/Makefile +0 -0
  22. {libcsound-0.17.2 → libcsound-0.17.4}/docs/_static/custom.css +0 -0
  23. {libcsound-0.17.2 → libcsound-0.17.4}/docs/conf.py +0 -0
  24. {libcsound-0.17.2 → libcsound-0.17.4}/docs/csound6.rst +0 -0
  25. {libcsound-0.17.2 → libcsound-0.17.4}/docs/csound7.rst +0 -0
  26. {libcsound-0.17.2 → libcsound-0.17.4}/docs/index.rst +0 -0
  27. {libcsound-0.17.2 → libcsound-0.17.4}/docs/make.bat +0 -0
  28. {libcsound-0.17.2 → libcsound-0.17.4}/docs/notebooks/02-Threading.ipynb +0 -0
  29. {libcsound-0.17.2 → libcsound-0.17.4}/docs/notebooks/no-queue.png +0 -0
  30. {libcsound-0.17.2 → libcsound-0.17.4}/docs/notebooks/no-queue.wav +0 -0
  31. {libcsound-0.17.2 → libcsound-0.17.4}/docs/notebooks/threading-example1.mp3 +0 -0
  32. {libcsound-0.17.2 → libcsound-0.17.4}/docs/notebooks/threading-example2.mp3 +0 -0
  33. {libcsound-0.17.2 → libcsound-0.17.4}/docs/notebooks/with-queue.wav +0 -0
  34. {libcsound-0.17.2 → libcsound-0.17.4}/docs/notebooks.rst +0 -0
  35. {libcsound-0.17.2 → libcsound-0.17.4}/docs/porting.rst +0 -0
  36. {libcsound-0.17.2 → libcsound-0.17.4}/docs/requirements.txt +0 -0
  37. {libcsound-0.17.2 → libcsound-0.17.4}/libcsound/_util.py +0 -0
  38. {libcsound-0.17.2 → libcsound-0.17.4}/libcsound/api6.py +0 -0
  39. {libcsound-0.17.2 → libcsound-0.17.4}/libcsound/api7.py +0 -0
  40. {libcsound-0.17.2 → libcsound-0.17.4}/libcsound/common.py +0 -0
  41. {libcsound-0.17.2 → libcsound-0.17.4}/libcsound/py.typed +0 -0
  42. {libcsound-0.17.2 → libcsound-0.17.4}/libcsound.egg-info/dependency_links.txt +0 -0
  43. {libcsound-0.17.2 → libcsound-0.17.4}/libcsound.egg-info/requires.txt +0 -0
  44. {libcsound-0.17.2 → libcsound-0.17.4}/libcsound.egg-info/top_level.txt +0 -0
  45. {libcsound-0.17.2 → libcsound-0.17.4}/setup.cfg +0 -0
  46. {libcsound-0.17.2 → libcsound-0.17.4}/test/actions-test1.py +0 -0
  47. {libcsound-0.17.2 → libcsound-0.17.4}/test/actionstest.csd +0 -0
  48. {libcsound-0.17.2 → libcsound-0.17.4}/test/bufferInOut.csd +0 -0
  49. {libcsound-0.17.2 → libcsound-0.17.4}/test/numpfields.csd +0 -0
  50. {libcsound-0.17.2 → libcsound-0.17.4}/test/simple1.csd +0 -0
  51. {libcsound-0.17.2 → libcsound-0.17.4}/test/simple2.csd +0 -0
  52. {libcsound-0.17.2 → libcsound-0.17.4}/test/test-numpfields.py +0 -0
  53. {libcsound-0.17.2 → libcsound-0.17.4}/test/test0.py +0 -0
  54. {libcsound-0.17.2 → libcsound-0.17.4}/test/test1.py +0 -0
@@ -231,3 +231,39 @@ jobs:
231
231
  with:
232
232
  name: macos-install-render-${{ matrix.python-version }}
233
233
  path: test/out.wav
234
+
235
+ windows-autoinstall:
236
+ # Tests the automatic csound installation triggered on import when csound is
237
+ # not present: the bundled getcsound.ps1 resolves the latest csound 7
238
+ # Windows installer from the csound/csound "develop" builds and installs it
239
+ # silently to %ProgramFiles%\Csound7. GitHub-hosted Windows runners are
240
+ # already elevated, so the machine-wide Inno Setup install needs no UAC
241
+ # prompt.
242
+ runs-on: windows-latest
243
+ strategy:
244
+ matrix:
245
+ python-version: ["3.14"]
246
+ fail-fast: false
247
+
248
+ steps:
249
+ - uses: actions/checkout@v3
250
+
251
+ - uses: actions/setup-python@v4
252
+ with:
253
+ python-version: ${{ matrix.python-version }}
254
+
255
+ - name: install from repo
256
+ run: |
257
+ pip install .
258
+
259
+ - name: import libcsound (auto-installs csound) and render offline
260
+ working-directory: test
261
+ env:
262
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
263
+ run: |
264
+ python windows-install-render.py
265
+
266
+ - uses: actions/upload-artifact@v4
267
+ with:
268
+ name: windows-install-render-${{ matrix.python-version }}
269
+ path: test/out.wav
@@ -4,4 +4,5 @@ exclude examples
4
4
  exclude .gitignore
5
5
  prune examples
6
6
  include libcsound/data/getcsound.sh
7
+ include libcsound/data/getcsound.ps1
7
8
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: libcsound
3
- Version: 0.17.2
3
+ Version: 0.17.4
4
4
  Summary: Python bindings to the Csound API, supporting all versions of csound higher or equal to 6.18, including csound 7
5
5
  Author-email: Eduardo Moguillansky <eduardo.moguillansky@gmail.com>
6
6
  License: GNU LESSER GENERAL PUBLIC LICENSE
@@ -536,16 +536,28 @@ Installation
536
536
  Csound
537
537
  ^^^^^^
538
538
 
539
- Csound needs to be installed in the system. See https://github.com/csound/csound/releases
539
+ Csound does not need to be installed manually: when it cannot be found,
540
+ ``libcsound`` installs csound 7 automatically on import, on Linux, macOS and
541
+ Windows (unless ``LIBCSOUND_INSTALL`` is set to ``0`` or ``false``). On macOS
542
+ and Windows the automatic install needs an interactive, elevated session, so in
543
+ non-interactive environments csound must be installed beforehand.
544
+
545
+ To install csound manually instead, use the official installers. See
546
+ https://github.com/csound/csound/releases
540
547
 
541
548
  In Linux / macOS:
542
549
 
543
550
  .. code::
544
551
 
545
- curl -fsSL https://csound-plugins.github.io/installer/install.sh | bash
552
+ curl -fsSL https://csound-plugins.github.io/getcsound.sh | bash
553
+
554
+ In Windows:
555
+
556
+ .. code::
546
557
 
558
+ irm https://csound-plugins.github.io/getcsound.ps1 | iex
547
559
 
548
- This installs the latest version of csound 7.
560
+ This installs the latest version of csound 7.
549
561
 
550
562
 
551
563
  libcsound
@@ -15,16 +15,28 @@ Installation
15
15
  Csound
16
16
  ^^^^^^
17
17
 
18
- Csound needs to be installed in the system. See https://github.com/csound/csound/releases
18
+ Csound does not need to be installed manually: when it cannot be found,
19
+ ``libcsound`` installs csound 7 automatically on import, on Linux, macOS and
20
+ Windows (unless ``LIBCSOUND_INSTALL`` is set to ``0`` or ``false``). On macOS
21
+ and Windows the automatic install needs an interactive, elevated session, so in
22
+ non-interactive environments csound must be installed beforehand.
23
+
24
+ To install csound manually instead, use the official installers. See
25
+ https://github.com/csound/csound/releases
19
26
 
20
27
  In Linux / macOS:
21
28
 
22
29
  .. code::
23
30
 
24
- curl -fsSL https://csound-plugins.github.io/installer/install.sh | bash
31
+ curl -fsSL https://csound-plugins.github.io/getcsound.sh | bash
32
+
33
+ In Windows:
34
+
35
+ .. code::
25
36
 
37
+ irm https://csound-plugins.github.io/getcsound.ps1 | iex
26
38
 
27
- This installs the latest version of csound 7.
39
+ This installs the latest version of csound 7.
28
40
 
29
41
 
30
42
  libcsound
@@ -8,9 +8,10 @@ Quick Start
8
8
 
9
9
  .. note::
10
10
 
11
- *csound* should be installed before these bindings can be used. Any version
12
- >= 6.18 should work. **csound 7** is explicitely supported and is the recommended
13
- version to use. See `installation`_.
11
+ Csound does not need to be installed manually: if it cannot be found it is
12
+ installed automatically on import (see `installation`_). Any version >= 6.18
13
+ can be used. **csound 7** is explicitly supported and is the recommended
14
+ version to use.
14
15
 
15
16
 
16
17
  Rendering in real-time
@@ -127,18 +128,24 @@ Installation
127
128
  Csound
128
129
  ^^^^^^
129
130
 
130
- `libcsound` does not install csound itself. To install csound, see:
131
-
132
- See https://github.com/csound/csound/releases
131
+ When csound cannot be found, ``libcsound`` installs it automatically on import
132
+ (unless ``LIBCSOUND_INSTALL`` is set to ``0`` or ``false``). To install csound
133
+ manually, or when the automatic installation is not possible (on macOS and
134
+ Windows it needs an interactive, elevated session), use the official installers
135
+ or see https://github.com/csound/csound/releases.
133
136
 
134
137
  **Linux / macOS**
135
138
 
136
- For linux csound 7 can be installed via:
137
-
138
- .. code::
139
+ .. code-block:: shell
139
140
 
140
141
  curl -fsSL https://csound-plugins.github.io/getcsound.sh | bash
141
142
 
143
+ **Windows**
144
+
145
+ .. code-block:: shell
146
+
147
+ irm https://csound-plugins.github.io/getcsound.ps1 | iex
148
+
142
149
 
143
150
  Environment variables
144
151
  ^^^^^^^^^^^^^^^^^^^^^
@@ -159,8 +166,9 @@ so the variables below must be set **before** importing ``libcsound``.
159
166
  ``LIBCSOUND_INSTALL``
160
167
  Controls the automatic installation of csound when it cannot be found. Set
161
168
  it to ``0`` or ``false`` to disable this behaviour. Any other value (or
162
- leaving it unset) allows ``libcsound`` to download and install a portable
163
- csound 7 release on Linux/macOS.
169
+ leaving it unset) allows ``libcsound`` to download and install csound 7 on
170
+ Linux, macOS and Windows. On Windows the install is machine-wide and needs
171
+ Administrator rights, so an interactive (or elevated) session is required.
164
172
 
165
173
  ``OPCODE7DIR64``
166
174
  Determines the path where csound looks for plugins. It can contain multiple
@@ -15,7 +15,7 @@
15
15
  "\n",
16
16
  "**libcsound** is a python module wrapping the access to the Csound API using two Python classes: *Csound* and *PerformanceThread*. **libcsound** uses **ctypes** to access C shared libraries. \n",
17
17
  "\n",
18
- "**NB**: csound itself needs to be installed in order to use **libcsound**"
18
+ "**NB**: csound does not need to be installed manually: if it cannot be found, **libcsound** installs it automatically on import (see the installation section of the documentation)."
19
19
  ]
20
20
  },
21
21
  {
@@ -48,8 +48,9 @@ Environment variables
48
48
  ``LIBCSOUND_INSTALL``
49
49
  Controls the automatic installation of csound when it cannot be found. Set
50
50
  it to ``0`` or ``false`` to disable this behaviour. Any other value (or
51
- leaving it unset) allows ``libcsound`` to download and install a portable
52
- csound 7 release on Linux/macOS.
51
+ leaving it unset) allows ``libcsound`` to download and install csound 7 on
52
+ Linux, macOS and Windows. On Windows the install is machine-wide and needs
53
+ Administrator rights, so an interactive (or elevated) session is required.
53
54
 
54
55
  ``OPCODE7DIR64``
55
56
  Determines the path where csound looks for plugins. It can contain multiple
@@ -303,7 +303,9 @@ def _findLibcsoundLinux() -> tuple[ct.CDLL, str] | str:
303
303
  return _format_report(report)
304
304
 
305
305
 
306
- _DEFAULT_WINDOWS_PATHS: tuple[str, ...] = (r"C:\Program Files\csound",
306
+ _DEFAULT_WINDOWS_PATHS: tuple[str, ...] = (r"C:\Program Files\Csound7\bin",
307
+ r"C:\Program Files\Csound7",
308
+ r"C:\Program Files\csound",
307
309
  r"C:\Program Files\csound\bin")
308
310
 
309
311
 
@@ -427,6 +429,9 @@ def csoundDLL(install=True) -> tuple[ct.CDLL, str]:
427
429
  elif sys.platform == 'darwin':
428
430
  _install_csound_macos()
429
431
  return csoundDLL(install=False)
432
+ elif sys.platform.startswith('win'):
433
+ _install_csound_windows()
434
+ return csoundDLL(install=False)
430
435
 
431
436
  if sys.platform in ('linux', 'darwin'):
432
437
  raise ImportError("libcsound not found. It can be installed via:\n"
@@ -436,7 +441,10 @@ def csoundDLL(install=True) -> tuple[ct.CDLL, str]:
436
441
  raise ImportError("Csound library not found. "
437
442
  "Make sure that csound is installed and the directory containing "
438
443
  f"csound64.dll is in the path. PATH='{os.environ.get('PATH')}'\n"
439
- "csound can be installed from https://github.com/csound/csound/releases\n"
444
+ "Csound 7 can be installed automatically, but the installer needs "
445
+ "Administrator rights and an interactive (or elevated) session; "
446
+ "install it manually via:\n"
447
+ " irm https://csound-plugins.github.io/getcsound.ps1 | iex\n"
440
448
  f"Search report:\n{report_text}")
441
449
  else:
442
450
  raise ImportError(f"Did not find csound library in {sys.platform}")
@@ -654,4 +662,85 @@ def _install_csound_macos() -> None:
654
662
  return
655
663
 
656
664
  raise RuntimeError("csound 7 installation failed: "
657
- "CsoundLib64 was not found in /Applications/Csound")
665
+ "CsoundLib64 was not found in /Applications/Csound")
666
+
667
+
668
+ def _install_csound_windows() -> None:
669
+ """Install the latest csound 7 for Windows by running the bundled installer.
670
+
671
+ This runs the bundled copy of the official installer at
672
+ https://csound-plugins.github.io/getcsound.ps1 with Windows PowerShell. The
673
+ installer resolves the latest successful ``csound_builds`` workflow run of
674
+ the ``csound/csound`` repository on the ``develop`` branch, downloads the
675
+ Windows x86_64 Inno Setup package and installs it silently to
676
+ ``%ProgramFiles%\\Csound7``. Windows on ARM64 is not supported yet.
677
+
678
+ The Inno Setup package installs machine-wide and needs Administrator
679
+ rights: when the current session is not elevated the installer triggers a
680
+ UAC prompt, so an interactive (or pre-elevated) session is required. On CI
681
+ runners the session is usually already elevated.
682
+
683
+ After a successful installation the environment variables ``LIBCSOUNDPATH``
684
+ and ``OPCODE7DIR64`` are set to point to the installed library and plugin
685
+ directory, so that the current process can find csound immediately without
686
+ the need to open a new terminal.
687
+
688
+ Raises:
689
+ RuntimeError: if PowerShell or the bundled installer could not be found,
690
+ if the installer failed, or if no csound installation could be
691
+ located after running it.
692
+ """
693
+ import importlib.resources
694
+ import shutil
695
+ import subprocess
696
+
697
+ installer = importlib.resources.files(__package__).joinpath("data", "getcsound.ps1")
698
+ if not installer.is_file():
699
+ raise RuntimeError(f"The bundled installer was not found: {installer}")
700
+
701
+ powershell = shutil.which("powershell") or shutil.which("pwsh")
702
+ if not powershell:
703
+ raise RuntimeError(
704
+ "PowerShell was not found. It is needed to install csound on Windows.\n"
705
+ "Alternatively, csound can be installed manually:\n"
706
+ " irm https://csound-plugins.github.io/getcsound.ps1 | iex"
707
+ )
708
+
709
+ # as_file() yields a real filesystem path, extracting to a temporary file
710
+ # first when the package is loaded from an archive (e.g. a zip).
711
+ with importlib.resources.as_file(installer) as script:
712
+ logger.info("Running bundled installer: %s", script)
713
+ result = subprocess.run(
714
+ [powershell, "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", str(script)]
715
+ )
716
+ if result.returncode != 0:
717
+ raise RuntimeError(
718
+ f"The bundled installer exited with status {result.returncode}\n"
719
+ "The Csound Windows installer installs machine-wide and needs "
720
+ "Administrator rights: run it from an interactive (or elevated) "
721
+ "PowerShell session.\n"
722
+ "Alternatively, csound can be installed manually:\n"
723
+ " irm https://csound-plugins.github.io/getcsound.ps1 | iex"
724
+ )
725
+
726
+ # Make the freshly installed csound available to the current process
727
+ programfiles = (os.environ.get("ProgramW6432")
728
+ or os.environ.get("ProgramFiles")
729
+ or r"C:\Program Files")
730
+ csound_dir = Path(programfiles) / "Csound7"
731
+ bindir = csound_dir / "bin"
732
+ libpath = bindir / "csound64.dll"
733
+ pluginspath = csound_dir / "plugins64"
734
+ if libpath.is_file():
735
+ os.environ["LIBCSOUNDPATH"] = str(libpath.resolve())
736
+ # The machine-wide PATH set by the installer is not visible to this
737
+ # process yet, so add the bin directory here to let csound's dependent
738
+ # DLLs (e.g. libsndfile) be resolved when the library is loaded.
739
+ os.environ["PATH"] = str(bindir.resolve()) + os.pathsep + os.environ.get("PATH", "")
740
+ if pluginspath.is_dir():
741
+ os.environ['OPCODE7DIR64'] = str(pluginspath.resolve())
742
+ logger.info("Csound installed successfully to %s", csound_dir)
743
+ return
744
+
745
+ raise RuntimeError("csound 7 installation failed: csound64.dll was not found in "
746
+ f"'{bindir}'")