Skip to content

Commit

Permalink
Merge pull request #25 from mbientlab/win_usb
Browse files Browse the repository at this point in the history
Release Win 10 support in binary format
  • Loading branch information
lkasso authored Dec 22, 2021
2 parents 5e18fae + fb1d754 commit b730244
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
24 changes: 18 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ def run(self):
if os.path.isfile(bindings):
os.remove(bindings)

if (platform.system() == 'Linux'):
if (platform.system() == 'Windows'):
dll = os.path.join(dest, "MetaWear.Win32.dll")
if os.path.isfile(dll):
os.remove(dll)
elif (platform.system() == 'Linux'):
for f in os.listdir(dest):
if (f.startswith("libmetawear.so")):
os.remove(os.path.join(dest, f))
Expand All @@ -34,14 +38,20 @@ def _move(src, dest, basename):
def run(self):
cpp_sdk = os.path.join(root, 'MetaWear-SDK-Cpp')
system = platform.system()
dist_dir = os.path.join(cpp_sdk, 'dist', 'release', 'lib', machine)
dist_dir = os.path.join(cpp_sdk, 'dist', 'release', 'lib', "Win32" if machine == "x86" and system == "Windows" else machine)

if os.path.exists(os.path.join(root, '.git')):
status = call(["git", "submodule", "update", "--init"], cwd=root, stderr=STDOUT)
if (status != 0):
raise RuntimeError("Could not init git submodule")

if (system == 'Linux'):
if (system == 'Windows'):
if not os.path.exists(os.path.join(dist_dir, "MetaWear.Win32.dll")):
if (call(["MSBuild.exe", "MetaWear.Win32.vcxproj", "/p:Platform=%s" % machine, "/p:Configuration=Release"], cwd=cpp_sdk, stderr=STDOUT) != 0):
raise RuntimeError("Failed to compile MetaWear.dll")

copy2(os.path.join(dist_dir, "MetaWear.Win32.dll"), dest)
elif (system == 'Linux'):
status = call(["make", "-C", "MetaWear-SDK-Cpp", "OPT_FLAGS=-Wno-strict-aliasing", "-j%d" % (cpu_count())], cwd=root, stderr=STDOUT)
if (status != 0):
raise RuntimeError("Failed to compile C++ SDK")
Expand All @@ -53,11 +63,11 @@ def run(self):
copy2(os.path.join(cpp_sdk, 'bindings', 'python', 'mbientlab', 'metawear', 'cbindings.py'), dest)
build_py.run(self)

so_pkg_data = ['libmetawear.so']
so_pkg_data = ['libmetawear.so'] if platform.system() == 'Linux' else ['MetaWear.Win32.dll']
setup(
name='metawear',
packages=['mbientlab', 'mbientlab.metawear'],
version='1.0.3',
version='1.0.4',
description='Python bindings for the MetaWear C++ SDK by MbientLab',
long_description=open(os.path.join(os.path.dirname(__file__), "README.md")).read(),
package_data={'mbientlab.metawear': so_pkg_data},
Expand All @@ -67,7 +77,8 @@ def run(self):
author_email="[email protected]",
install_requires=[
'warble >= 1.1, < 2.0',
'requests'
'requests',
'pyserial'
],
cmdclass={
'build_py': MetaWearBuild,
Expand All @@ -79,6 +90,7 @@ def run(self):
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Operating System :: POSIX :: Linux',
'Operating System :: Microsoft :: Windows :: Windows 10',
'Programming Language :: Python :: 3',
]
)

0 comments on commit b730244

Please sign in to comment.