Skip to content

Commit

Permalink
New MacOS build setup preliminary work.
Browse files Browse the repository at this point in the history
  • Loading branch information
belangeo committed Feb 15, 2023
1 parent 529a373 commit 8b208e0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 34 deletions.
6 changes: 1 addition & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 3,5 @@
"build_linux_debug": "python3 setup.py bdist_wheel --use-jack --debug --fast-compile",
"build_linux_single": "python3 setup.py bdist_wheel --use-jack",
"build_linux_double": "python3 setup.py bdist_wheel --use-jack --use-double",
"install_linux": "python3 -m pip install --user --force-reinstall dist/pyo-*-cp39-cp39-linux_x86_64.whl",
"build_macos_single": "/usr/local/bin/python3.${input:pyMinVersion} setup.py bdist_wheel --use-coreaudio",
"build_macos_double": "/usr/local/bin/python3.${input:pyMinVersion} setup.py bdist_wheel --use-coreaudio --use-double",
"install_macos":
"/usr/local/bin/python3.${input:pyMinVersion} -m pip install --user --force-reinstall dist/pyo-*-cp3${input:pyMinVersion}-cp3${input:pyMinVersion}-macosx*.whl"
"install_linux": "python3 -m pip install --user --force-reinstall dist/pyo-*-cp39-cp39-linux_x86_64.whl"
}
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 91,7 @@
{
"label": "Compile MacOS (single)",
"type": "shell",
"command": "${config:build_macos_single} && ${config:install_macos}",
"command": "/usr/local/bin/python3.${input:pyMinVersion} setup.py bdist_wheel --use-coreaudio && /usr/local/bin/python3.${input:pyMinVersion} -m pip install --user --force-reinstall dist/pyo-*-cp3${input:pyMinVersion}-cp3${input:pyMinVersion}-universal2.whl",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}"
Expand All @@ -108,7 108,7 @@
{
"label": "Compile MacOS (double)",
"type": "shell",
"command": "${config:build_macos_double} && ${config:install_macos}",
"command": "/usr/local/bin/python3.${input:pyMinVersion} setup.py bdist_wheel --use-coreaudio --use-double && /usr/local/bin/python3.${input:pyMinVersion} -m pip install --user --force-reinstall dist/pyo-*-cp3${input:pyMinVersion}-cp3${input:pyMinVersion}-universal2.whl",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}"
Expand Down
66 changes: 39 additions & 27 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 150,9 @@ def get_jack_api():
else:
libraries = ["lo"]

# libsndfile
libraries = ["sndfile"]

# Optional Audio / Midi drivers
if "--use-jack" in sys.argv:
sys.argv.remove("--use-jack")
Expand Down Expand Up @@ -254,7 257,7 @@ def vcpkg_path(root, pkg, triplet):
vcpkg_triplet = os.environ.get("VCPKG_DEFAULT_TRIPLET", "x64-windows")
msys2_mingw_root = os.environ.get("MSYS2_MINGW_ROOT", r"C:\msys64\mingw64")

include_dirs = []
include_dirs = ["include"]
library_dirs = []
binary_dirs = []

Expand All @@ -270,21 273,40 @@ def vcpkg_path(root, pkg, triplet):
library_dirs.append(os.path.join(pkg_dir, "lib"))
if req[2]:
binary_dirs.append(os.path.join(pkg_dir, "bin"))
include_dirs.extend([
os.path.join(msys2_mingw_root, "include"),
"include",
])
include_dirs.append(os.path.join(msys2_mingw_root, "include"))

libraries = ["sndfile"]
macros.append(("MS_WIN64", None))
elif sys.platform == "darwin":
pkgs_3rdpary = {
#package flags: (include, lib, version)
"flac": (False, True, "1.4.2"),
"liblo": (True, True, "0.31"),
"libogg": (False, True, "1.3.5"),
"libsndfile": (True, True, "1.2.0"),
"libvorbis": (False, True, "1.3.7"),
"opus": (False, True, "1.3.1"),
"portaudio": (True, True, "19.7.0"),
"portmidi": (True, True, "2.0.4"),
"lame": (False, True, "3.100")
}

# Intel, brew's packages directory is usually /usr/local/Cellar
brew_packages_root = os.environ.get("BREW_PACKAGES_ROOT", "/opt/homebrew/Cellar")

include_dirs = ["include"]
library_dirs = []

for pkg, req in pkgs_3rdpary.items():
pkg_dir = os.path.join(brew_packages_root, pkg, req[2])
if req[0]:
include_dirs.append(os.path.join(pkg_dir, "include"))
if req[1]:
library_dirs.append(os.path.join(pkg_dir, "lib"))

else:
include_dirs = ["include", "/usr/include", "/usr/local/include"]
if sys.platform == "darwin":
include_dirs.append("/opt/local/include")
else:
libraries = ["rt"]
libraries = ["rt"]
library_dirs = ["/usr/lib", "/usr/local/lib"]
libraries = ["sndfile"]
if build_with_jack_support:
libraries.append("jack")

Expand All @@ -302,22 324,12 @@ def vcpkg_path(root, pkg, triplet):
data_files = ((data_files_dest, dlls),)
elif sys.platform == "darwin":
if "bdist_wheel" in sys.argv:
data_files = [
(
"/pyo",
[
"temp_libs/liblo.7.dylib",
"temp_libs/libportaudio.2.dylib",
"temp_libs/libportmidi.dylib",
"temp_libs/libsndfile.1.dylib",
"temp_libs/libFLAC.12.dylib",
"temp_libs/libvorbisenc.2.dylib",
"temp_libs/libvorbis.0.dylib",
"temp_libs/libogg.0.dylib",
"temp_libs/libopus.0.dylib",
],
)
]
dylibs = []
for bind in library_dirs:
dylibs.extend(glob.glob(os.path.join(bind, "*.dylib")))
dylibs = [dylib for dylib in dylibs if not os.path.islink(dylib)]
dylibs = [dylib for dylib in dylibs if "FLAC " not in dylib and "portaudiocpp" not in dylib]
data_files = (("/pyo", dylibs),)
else:
data_files = []
else:
Expand Down

0 comments on commit 8b208e0

Please sign in to comment.