Skip to content

Commit

Permalink
Removed docs and modified dll loading
Browse files Browse the repository at this point in the history
  • Loading branch information
SayakMukhopadhyay committed Apr 25, 2021
1 parent e35e00d commit 4e208a2
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 303 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ instance/
# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/
doc/_build/

# PyBuilder
target/

Expand Down
4 changes: 2 additions & 2 deletions discordsdk/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Discord:

core: sdk.IDiscordCore = None

def __init__(self, client_id: int, flags: CreateFlags):
def __init__(self, client_id: int, flags: CreateFlags, dll_base_path: str):
self._garbage = []

self._activity_manager = ActivityManager()
Expand Down Expand Up @@ -61,7 +61,7 @@ def __init__(self, client_id: int, flags: CreateFlags):

pointer = ctypes.POINTER(sdk.IDiscordCore)()

result = Result(sdk.DiscordCreate(version, ctypes.pointer(params), ctypes.pointer(pointer)))
result = Result(sdk.build_sdk(dll_base_path)(version, ctypes.pointer(params), ctypes.pointer(pointer)))
if result != Result.ok:
raise get_exception(result)

Expand Down
27 changes: 13 additions & 14 deletions discordsdk/sdk.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import ctypes
import os.path
import sys
import typing as t
from os.path import join
from sys import platform

import sys as _sys

if "sphinx" in _sys.modules:
setattr(_sys, "is_dsdk_doc_run", True)
_is_dsdk_doc_run = hasattr(_sys, "is_dsdk_doc_run") and _sys.is_dsdk_doc_run

if not _is_dsdk_doc_run:
def build_sdk(dll_base_path):
try:
if sys.platform == "darwin":
dll = ctypes.CDLL(os.path.abspath("lib/discord_game_sdk.dylib"))
else:
dll = ctypes.CDLL(os.path.abspath("lib/discord_game_sdk"))
dllPath = "lib/discord_game_sdk.dll"
if platform == "darwin":
dllPath = "lib/discord_game_sdk.dylib"
elif platform == 'linux' or platform == 'linux2':
dllPath = "lib/discord_game_sdk.so"
dll = ctypes.CDLL(join(dll_base_path, dllPath))
except FileNotFoundError:
raise FileNotFoundError("Could not locate Discord's SDK DLLs. Check that they are in the /lib directory relative to the folder that the program is executed from.") # noqa: E501
raise FileNotFoundError(
"Could not locate Discord's SDK DLLs. Check that they are in the /lib directory relative to the folder that the program is executed from.") # noqa: E501

return dll.DiscordCreate

DiscordCreate = dll.DiscordCreate

DiscordClientId = ctypes.c_int64
DiscordVersion = ctypes.c_int32
Expand Down
20 changes: 0 additions & 20 deletions docs/Makefile

This file was deleted.

51 changes: 0 additions & 51 deletions docs/conf.py

This file was deleted.

149 changes: 0 additions & 149 deletions docs/discordsdk.rst

This file was deleted.

20 changes: 0 additions & 20 deletions docs/index.rst

This file was deleted.

35 changes: 0 additions & 35 deletions docs/make.bat

This file was deleted.

7 changes: 0 additions & 7 deletions docs/modules.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/requirements.txt

This file was deleted.

0 comments on commit 4e208a2

Please sign in to comment.