Skip to content

Commit

Permalink
Use the github approach
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyTitu committed Mar 13, 2024
1 parent dbc5577 commit 0e3b869
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 27 deletions.
1 change: 1 addition & 0 deletions sdk/onepassword/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import onepassword.client
30 changes: 8 additions & 22 deletions sdk/onepassword/core.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
8 changes: 8 additions & 0 deletions sdk/pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"',
]
6 changes: 1 addition & 5 deletions sdk/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
],
)

0 comments on commit 0e3b869

Please sign in to comment.