From d44db1d8ff5add2712746efbdbf24f459a0f1232 Mon Sep 17 00:00:00 2001 From: Joe Denhup Date: Mon, 14 Oct 2024 12:39:10 -0400 Subject: [PATCH 1/2] - Build.bat --- .gitignore | 4 ++ Build.bat | 2 +- Make.bat | 8 +--- setup.py | 89 +++++++++++++++++------------------ src/AutoItLibrary/__init__.py | 4 +- 5 files changed, 50 insertions(+), 57 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b775b80 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +build/** +dist/** +src/robotframework_autoitlibrary.egg-info/** +**/__pycache__/** \ No newline at end of file diff --git a/Build.bat b/Build.bat index 7d41fc5..8a43a37 100755 --- a/Build.bat +++ b/Build.bat @@ -24,7 +24,7 @@ IF EXIST .\dist rmdir /S /Q .\dist IF EXIST .\build rmdir /S /Q .\build call Make.bat -python setup.py sdist --format=zip +python -m build --sdist pause :: :: -------------------------------- End of file -------------------------------- diff --git a/Make.bat b/Make.bat index 01ebe44..2a5a938 100755 --- a/Make.bat +++ b/Make.bat @@ -19,17 +19,11 @@ :: ::------------------------------------------------------------------------------- :: -:: Install the AutoItLibrary on the local PC -:: -python setup.py install :: :: Build the updated documentation before installing again :: -libdoc.py --output doc\AutoItLibrary.html AutoItLibrary -:: -:: Now install the AutoItLibrary on the local PC including the updated documentation +libdoc.exe src\AutoItLibrary doc\AutoItLibrary.html :: -python setup.py install pause :: :: -------------------------------- End of file -------------------------------- diff --git a/setup.py b/setup.py index 8ba0d75..fc7d847 100644 --- a/setup.py +++ b/setup.py @@ -20,8 +20,9 @@ """ __author__ = "Martin Taylor " -from distutils.core import setup -from distutils.sysconfig import get_python_lib +from setuptools import setup +from setuptools.command.install import install +from sysconfig import get_path import sys import os import shutil @@ -45,6 +46,43 @@ methods in this class. """[1:-1] +class InstallCommand(install): + def initialize_options(self): + install.initialize_options(self) + + def finalize_options(self): + install.finalize_options(self) + + def run(self): + RegisterAutoIT() + install.run(self) + +def RegisterAutoIT(): + # + # Install and register AutoItX + # + print("[INF] In RegisterAutoIT with params " + " ".join(str(x) for x in sys.argv)) + + if os.path.isfile(os.path.join(get_path('platlib'), "AutoItLibrary/lib/AutoItX3.dll")) : + print("[INF] Don't think we need to unregister the old one...") + + instDir = os.path.normpath(os.path.join(get_path('platlib'), "AutoItLibrary/lib")) + if not os.path.isdir(instDir) : + os.makedirs(instDir) + instFile = os.path.normpath(os.path.join(instDir, "AutoItX3.dll")) + if "32bit" in platform.architecture()[0] : + print("[INF] Here is from 32bit OS") + shutil.copyfile("3rdPartyTools/AutoIt/AutoItX3.dll", instFile) + else : + shutil.copyfile("3rdPartyTools/AutoIt/lib64/AutoItX3.dll", instFile) + # + # Register the AutoItX COM object + # and make its methods known to Python + # + cmd = r"%SYSTEMROOT%\system32\regsvr32.exe /S " + '\"' + instFile + '\"' + print(cmd) + subprocess.check_call(cmd, shell=True) + def getWin32ComRomingPath(): for dirpath, dirs, files in os.walk(os.getenv('APPDATA')): for filename in files: @@ -56,50 +94,6 @@ def getWin32ComRomingPath(): if __name__ == "__main__": # - # Install the 3rd party packages - # - if sys.argv[1].lower() == "install" : - if os.name == "nt" : - # - # Install and register AutoItX - # - if os.path.isfile(os.path.join(get_python_lib(), "AutoItLibrary/lib/AutoItX3.dll")) : - print("Don't think we need to unregister the old one...") - - instDir = os.path.normpath(os.path.join(get_python_lib(), "AutoItLibrary/lib")) - if not os.path.isdir(instDir) : - os.makedirs(instDir) - instFile = os.path.normpath(os.path.join(instDir, "AutoItX3.dll")) - if "32bit" in platform.architecture()[0] : - print("Here is from 32bit OS") - shutil.copyfile("3rdPartyTools/AutoIt/AutoItX3.dll", instFile) - else : - shutil.copyfile("3rdPartyTools/AutoIt/lib64/AutoItX3.dll", instFile) - # - # Register the AutoItX COM object - # and make its methods known to Python - # - cmd = r"%SYSTEMROOT%\system32\regsvr32.exe /S " + '\"' + instFile + '\"' - print(cmd) - subprocess.check_call(cmd, shell=True) - makepy = os.path.normpath(os.path.join(get_python_lib(), "win32com/client/makepy.py")) - if not os.path.isfile(makepy): - print("[WRN] No win32com in get_python_lib(). Try find in %APPDATA%.") - makepy = getWin32ComRomingPath() - # - # Make sure we have win32com installed - # - if makepy is None: - print("[ERR] AutoItLibrary requires win32com. See http://starship.python.net/crew/mhammond/win32/.") - sys.exit(2) - - cmd = "python \"%s\" \"%s\"" % (makepy, instFile) - print(cmd) - subprocess.check_call(cmd) - else : - print("AutoItLibrary cannot be installed on non-Windows platforms.") - sys.exit(2) - # # Figure out the install path # root_path = os.path.join(os.getenv("HOMEDRIVE")) @@ -122,7 +116,8 @@ def getWin32ComRomingPath(): long_description = DESCRIPTION, package_dir = {'' : "src"}, packages = ["AutoItLibrary"], - install_requires = ['pywin32', 'pillow'], + cmdclass = {'install': InstallCommand}, + install_requires = ['robotframework', 'pywin32', 'pillow'], data_files = [(destPath, ["COPYRIGHT.txt", "LICENSE.txt", diff --git a/src/AutoItLibrary/__init__.py b/src/AutoItLibrary/__init__.py index 35e0ffd..e43f111 100644 --- a/src/AutoItLibrary/__init__.py +++ b/src/AutoItLibrary/__init__.py @@ -60,13 +60,13 @@ class AutoItLibrary(Logger.Logger, Counter.Counter) : documentation for these keywords is available in the AutoItX documentation file: *AutoItX.chm*. This file is installed as part of the installation of *AutoItLibrary* as: - C:\RobotFramework\Extensions\AutoItLibrary\AutoItX.chm + C:\\RobotFramework\\Extensions\\AutoItLibrary\\AutoItX.chm In order to discover the control identifiers in a given Windows GUI, AutoIt provides a standalone tool called the AutoIt Window Info Tool which is installed as part of the installation of *AutoItLibrary* as: - C:\RobotFramework\Extensions\AutoItLibrary\Au3Info.exe + C:\\RobotFramework\\Extensions\\AutoItLibrary\\Au3Info.exe This tool is documented here: http://www.autoitscript.com/autoit3/docs/intro/au3spy.htm """ From bfe15fb896c6018c00434b10f0f59a0a0e1d3db2 Mon Sep 17 00:00:00 2001 From: Joe Denhup Date: Tue, 15 Oct 2024 09:02:17 -0400 Subject: [PATCH 2/2] put back OS check --- setup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.py b/setup.py index fc7d847..dbfcaed 100644 --- a/setup.py +++ b/setup.py @@ -54,6 +54,9 @@ def finalize_options(self): install.finalize_options(self) def run(self): + if os.name != "nt" : + print("AutoItLibrary cannot be installed on non-Windows platforms.") + sys.exit(2) RegisterAutoIT() install.run(self)