From 0e3b869e73193ff0b9a0bbcc75947396debcdd3a Mon Sep 17 00:00:00 2001 From: AndyTitu Date: Wed, 13 Mar 2024 13:24:31 +0100 Subject: [PATCH] Use the github approach --- sdk/onepassword/__init__.py | 1 + sdk/onepassword/core.py | 30 ++++++++---------------------- sdk/pyproject.toml | 8 ++++++++ sdk/setup.py | 6 +----- 4 files changed, 18 insertions(+), 27 deletions(-) create mode 100644 sdk/pyproject.toml diff --git a/sdk/onepassword/__init__.py b/sdk/onepassword/__init__.py index e69de29..fe39ab1 100644 --- a/sdk/onepassword/__init__.py +++ b/sdk/onepassword/__init__.py @@ -0,0 +1 @@ +import onepassword.client \ No newline at end of file diff --git a/sdk/onepassword/core.py b/sdk/onepassword/core.py index b12080a..890a613 100644 --- a/sdk/onepassword/core.py +++ b/sdk/onepassword/core.py @@ -1,29 +1,15 @@ import json import importlib.util +import platform -def import_core(platform_specific_package): - if (spec := importlib.util.find_spec(platform_specific_package)) is not None: - module = importlib.util.module_from_spec(spec) - spec.loader.exec_module(module) - return module - return None - -potential_dependencies = [ - "sdk_core_linux_amd64.op_uniffi_core", - "sdk_core_mac_arm64.op_uniffi_core" -] - -core = None - -for dep in potential_dependencies: - try: - core = import_core(dep) - if core is not None: - break - except ModuleNotFoundError: - continue - +def import_core(): + lib_name = "sdk_core_{}_{}".format(platform.system().lower(), platform.machine()) + spec = importlib.util.find_spec(lib_name) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module +core = import_core() # InitClient creates a client instance in the current core module and returns its unique ID. async def _init_client(client_config): diff --git a/sdk/pyproject.toml b/sdk/pyproject.toml new file mode 100644 index 0000000..d0e6f80 --- /dev/null +++ b/sdk/pyproject.toml @@ -0,0 +1,8 @@ +[build-system] +requires = ["setuptools"] + +[project] +dependencies = [ + 'sdk_core_darwin_arm64 @ git+ssh://github.com/1password/onepassword-sdk-python@andi/packaging&subdirectory=lib/op_uniffi_core_mac_arm64; platform_system=="Darwin" and platform_machine=="arm64"', + 'sdk_core_linux_amd64 @ git+ssh://github.com/1password/onepassword-sdk-python@andi/packaging&subdirectory=lib/op_uniffi_core_linux_amd64; platform_system=="Linux" and platform_machine=="x86_64"', +] \ No newline at end of file diff --git a/sdk/setup.py b/sdk/setup.py index 1ba1c8f..73ebffc 100644 --- a/sdk/setup.py +++ b/sdk/setup.py @@ -2,13 +2,9 @@ setup( name='onepassword', - version='0.1.0', + version='0.1.0-beta.1', packages=find_packages(), author='1Password', description="The 1Password Python SDK offers programmatic read access to your secrets in 1Password in an interface native to Python.", url='https://github.com/1Password/onepassword-sdk-python', - install_requires=[ - "sdk_core_mac_arm64; platform_system=='Darwin' and platform_machine=='arm64'", - "sdk_core_linux_amd64; platform_system=='Linux' and platform_machine=='x86_64'", - ], ) \ No newline at end of file