Skip to content

Commit

Permalink
Fixed setup script for Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
belangeo committed Feb 19, 2023
1 parent 4bd158f commit cc3c53d
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 20,7 @@
"""
from setuptools import setup, Extension
from distutils.sysconfig import get_python_lib
import os, sys, subprocess, platform, glob
import os, sys, subprocess, platform, glob, shutil

if sys.platform == "win32":
with open("setup.cfg", "w") as f:
Expand Down Expand Up @@ -321,17 321,13 @@ def vcpkg_path(root, pkg, triplet):
libraries.append("jack")

# Platform-specific data files
dlls = []
data_files = []
if sys.platform == "win32":
if "bdist_wheel" in sys.argv:
data_files_dest = os.path.join("Lib", "site-packages", "pyo")
else:
data_files_dest = "pyo"
dlls = []
for bind in binary_dirs:
dlls.extend(glob.glob(os.path.join(bind, "*.dll")))
dlls = [item for item in dlls if "FLAC " not in item] # Lame: remove this manually
dlls.extend(glob.glob(os.path.join(msys2_mingw_root, "bin", "lib*pthread*.dll")))
data_files = ((data_files_dest, dlls),)
elif sys.platform == "darwin":
if "bdist_wheel" in sys.argv:
dylibs = []
Expand All @@ -340,10 336,6 @@ def vcpkg_path(root, pkg, triplet):
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:
data_files = []

libraries = ["m"]
extra_compile_args = ["-Wno-strict-prototypes", "-Wno-strict-aliasing"] oflag gflag
Expand Down Expand Up @@ -414,6 406,11 @@ def vcpkg_path(root, pkg, triplet):
"Programming Language :: Python :: 3.11",
]

# Copy dlls to package to pyo folder
if sys.platform == "win32":
for dll in dlls:
shutil.copy(dll, "pyo/")

setup(
name="pyo",
author="Olivier Belanger",
Expand All @@ -434,6 431,7 @@ def vcpkg_path(root, pkg, triplet):
zip_safe=False,
packages=packages,
package_data={
"pyo": [os.path.basename(dll) for dll in dlls],
"pyo.lib.snds": soundfiles,
"pyo.editor.styles": [
"Custom",
Expand Down Expand Up @@ -479,3 477,8 @@ def vcpkg_path(root, pkg, triplet):

if sys.platform == "win32" and os.path.isfile("setup.cfg"):
os.remove("setup.cfg")

# Remove packaged dlls from pyo folder
if sys.platform == "win32":
for dll in dlls:
os.remove(os.path.join("pyo", os.path.basename(dll)))

0 comments on commit cc3c53d

Please sign in to comment.