Skip to content

Commit 670175f

Browse files
committed
add support for shared libs packaging
1 parent efe387e commit 670175f

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

setup.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import sysconfig
33
from setuptools import setup, find_packages
44
from sysconfig import get_platform
5+
6+
import setuptools
57
from version import SDK_VERSION
68
import platform
79
import os
@@ -20,25 +22,13 @@ def finalize_options(self):
2022
except ImportError:
2123
bdist_wheel = None
2224

23-
def get_data_files():
24-
# Specify the destination directory for platform-specific shared libraries
25-
shared_libs = get_shared_library_data_to_include()
26-
data_files = []
27-
28-
# Use sysconfig to get the correct platform-specific site-packages directory
29-
platlib_path = sysconfig.get_paths()["platlib"]
30-
31-
for file_path in shared_libs:
32-
if file_path:
33-
# Add the library file to data_files list with correct platlib path
34-
data_files.append((platlib_path, [file_path]))
35-
36-
return data_files
37-
25+
class BinaryDistribution (setuptools.Distribution):
26+
def has_ext_modules(self):
27+
return True
3828

3929
def get_shared_library_data_to_include():
4030
# Return the correct uniffi C shared library extension for the given platform
41-
include_path = "src/onepassword/lib"
31+
include_path = "lib"
4232
machine_type = os.getenv("PYTHON_MACHINE_PLATFORM") or platform.machine().lower()
4333
if machine_type in ["x86_64", "amd64"]:
4434
include_path = os.path.join(include_path, "x86_64")
@@ -72,6 +62,7 @@ def get_shared_library_data_to_include():
7262
packages=find_packages(
7363
where="src",
7464
),
65+
distclass=BinaryDistribution,
7566
license="MIT",
7667
license_files="LICENSE",
7768
package_dir={"": "src"},
@@ -89,7 +80,7 @@ def get_shared_library_data_to_include():
8980
"License :: OSI Approved :: MIT License",
9081
],
9182
cmdclass={"bdist_wheel": bdist_wheel},
92-
data_files=get_data_files(),
83+
package_data={"": get_shared_library_data_to_include()},
9384
install_requires=[
9485
"pydantic>=2.5", # Minimum Pydantic version to run the Python SDK
9586
],

0 commit comments

Comments
 (0)