Skip to content

Commit

Permalink
Updated to version to 1.1.7. Added a Helper, to more efficiently find…
Browse files Browse the repository at this point in the history
… the pyproject.toml
  • Loading branch information
Christoph Schmidt committed Aug 8, 2024
1 parent ac54ba9 commit 8aedcb1
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ packages = ["src/ADScopeControl"]

[project]
name = "PyADScopeControl"
version = "1.1.6"
version = "1.1.7"
authors = [
{ name="Christoph Schmidt", email="cschmidt.fs@gmail.com" },
]
Expand Down
20 changes: 20 additions & 0 deletions src/ADScopeControl/Helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# ======================================================================================================================
# EposCMD64.dll is needed, thus, try to copy it
# ======================================================================================================================
import os
import pathlib
import shutil

def get_pyprojecttoml() -> pathlib.Path:
# is found in ../../pyconfig.toml
pytoml_via_git = pathlib.Path(__file__).parent.parent.parent / "pyproject.toml"
# found in ./pyconfig.toml: Copied to the root dir
pytoml_via_pip = pathlib.Path(__file__).parent / "pyproject.toml"

if pytoml_via_git.exists():
#print("pytoml_via_git:", pytoml_via_git)
return pytoml_via_git.resolve().absolute()
elif pytoml_via_pip.exists():
#print("pytoml_via_pip:", pytoml_via_pip)
return pytoml_via_pip.resolve().absolute()

36 changes: 25 additions & 11 deletions src/ADScopeControl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,41 @@
Package Version:
"""


import ctypes
import os
import pathlib
from pathlib import Path

from WidgetCollection.Tools.PyProjectExtractor import extract_pyproject_info

from . import Helpers

# Directly in the repo

pytoml = pathlib.Path(__file__).parent.parent.parent
if not (pytoml / "pyproject.toml").exists():
# if installed via pip
pytoml = pathlib.Path(__file__)
# ======================================================================================================================
# The pyconfig.toml file is needed, to get the metadata. Depending on the installation method (pip or git) the file
# is found in different places.
# ======================================================================================================================
pytoml = Helpers.get_pyprojecttoml()

__version__ = extract_pyproject_info(pytoml,"version")
__author__ = extract_pyproject_info(pytoml,"author")
__description__ = extract_pyproject_info(pytoml,"description")
__license__ = extract_pyproject_info(pytoml,"license")
__url__ = extract_pyproject_info(pytoml,"url")

def try_and_set(func, *args, **kwargs):
try:
return func(*args, **kwargs)
except Exception as e:
print(f"Error reading '{args[1]}' from {pathlib.Path(args[0])}: {e}")
return "unknown"


__rootdir__ = os.path.dirname(os.path.realpath(__file__))
__version__ = try_and_set(extract_pyproject_info, pytoml.parent, "version")
__author__ = try_and_set(extract_pyproject_info, pytoml.parent, "author")
__description__ = try_and_set(extract_pyproject_info, pytoml.parent, "description")
__license__ = try_and_set(extract_pyproject_info, pytoml.parent, "license")
__url__ = try_and_set(extract_pyproject_info, pytoml.parent, "url")
# For correctly display the icon in the taskbar
myappid = f'agentsmith29.ADScopeControl.{__version__}' # arbitrary string

myappid = f'agentsmith29.ADScopeControl.{__version__}'
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

from .CaptDeviceConfig import CaptDeviceConfig as Config
Expand Down

0 comments on commit 8aedcb1

Please sign in to comment.