Skip to content

Commit fd6caf2

Browse files
authored
Merge pull request #39 from jjdenhup/fix_python312_and_install
Fixes to work with latest Python versions
2 parents cec2c86 + bfe15fb commit fd6caf2

File tree

5 files changed

+53
-57
lines changed

5 files changed

+53
-57
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build/**
2+
dist/**
3+
src/robotframework_autoitlibrary.egg-info/**
4+
**/__pycache__/**

Build.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
IF EXIST .\dist rmdir /S /Q .\dist
2525
IF EXIST .\build rmdir /S /Q .\build
2626
call Make.bat
27-
python setup.py sdist --format=zip
27+
python -m build --sdist
2828
pause
2929
::
3030
:: -------------------------------- End of file --------------------------------

Make.bat

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,11 @@
1919
::
2020
::-------------------------------------------------------------------------------
2121
::
22-
:: Install the AutoItLibrary on the local PC
23-
::
24-
python setup.py install
2522
::
2623
:: Build the updated documentation before installing again
2724
::
28-
libdoc.py --output doc\AutoItLibrary.html AutoItLibrary
29-
::
30-
:: Now install the AutoItLibrary on the local PC including the updated documentation
25+
libdoc.exe src\AutoItLibrary doc\AutoItLibrary.html
3126
::
32-
python setup.py install
3327
pause
3428
::
3529
:: -------------------------------- End of file --------------------------------

setup.py

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
"""
2121
__author__ = "Martin Taylor <[email protected]>"
2222

23-
from distutils.core import setup
24-
from distutils.sysconfig import get_python_lib
23+
from setuptools import setup
24+
from setuptools.command.install import install
25+
from sysconfig import get_path
2526
import sys
2627
import os
2728
import shutil
@@ -45,6 +46,46 @@
4546
methods in this class.
4647
"""[1:-1]
4748

49+
class InstallCommand(install):
50+
def initialize_options(self):
51+
install.initialize_options(self)
52+
53+
def finalize_options(self):
54+
install.finalize_options(self)
55+
56+
def run(self):
57+
if os.name != "nt" :
58+
print("AutoItLibrary cannot be installed on non-Windows platforms.")
59+
sys.exit(2)
60+
RegisterAutoIT()
61+
install.run(self)
62+
63+
def RegisterAutoIT():
64+
#
65+
# Install and register AutoItX
66+
#
67+
print("[INF] In RegisterAutoIT with params " + " ".join(str(x) for x in sys.argv))
68+
69+
if os.path.isfile(os.path.join(get_path('platlib'), "AutoItLibrary/lib/AutoItX3.dll")) :
70+
print("[INF] Don't think we need to unregister the old one...")
71+
72+
instDir = os.path.normpath(os.path.join(get_path('platlib'), "AutoItLibrary/lib"))
73+
if not os.path.isdir(instDir) :
74+
os.makedirs(instDir)
75+
instFile = os.path.normpath(os.path.join(instDir, "AutoItX3.dll"))
76+
if "32bit" in platform.architecture()[0] :
77+
print("[INF] Here is from 32bit OS")
78+
shutil.copyfile("3rdPartyTools/AutoIt/AutoItX3.dll", instFile)
79+
else :
80+
shutil.copyfile("3rdPartyTools/AutoIt/lib64/AutoItX3.dll", instFile)
81+
#
82+
# Register the AutoItX COM object
83+
# and make its methods known to Python
84+
#
85+
cmd = r"%SYSTEMROOT%\system32\regsvr32.exe /S " + '\"' + instFile + '\"'
86+
print(cmd)
87+
subprocess.check_call(cmd, shell=True)
88+
4889
def getWin32ComRomingPath():
4990
for dirpath, dirs, files in os.walk(os.getenv('APPDATA')):
5091
for filename in files:
@@ -56,50 +97,6 @@ def getWin32ComRomingPath():
5697

5798
if __name__ == "__main__":
5899
#
59-
# Install the 3rd party packages
60-
#
61-
if sys.argv[1].lower() == "install" :
62-
if os.name == "nt" :
63-
#
64-
# Install and register AutoItX
65-
#
66-
if os.path.isfile(os.path.join(get_python_lib(), "AutoItLibrary/lib/AutoItX3.dll")) :
67-
print("Don't think we need to unregister the old one...")
68-
69-
instDir = os.path.normpath(os.path.join(get_python_lib(), "AutoItLibrary/lib"))
70-
if not os.path.isdir(instDir) :
71-
os.makedirs(instDir)
72-
instFile = os.path.normpath(os.path.join(instDir, "AutoItX3.dll"))
73-
if "32bit" in platform.architecture()[0] :
74-
print("Here is from 32bit OS")
75-
shutil.copyfile("3rdPartyTools/AutoIt/AutoItX3.dll", instFile)
76-
else :
77-
shutil.copyfile("3rdPartyTools/AutoIt/lib64/AutoItX3.dll", instFile)
78-
#
79-
# Register the AutoItX COM object
80-
# and make its methods known to Python
81-
#
82-
cmd = r"%SYSTEMROOT%\system32\regsvr32.exe /S " + '\"' + instFile + '\"'
83-
print(cmd)
84-
subprocess.check_call(cmd, shell=True)
85-
makepy = os.path.normpath(os.path.join(get_python_lib(), "win32com/client/makepy.py"))
86-
if not os.path.isfile(makepy):
87-
print("[WRN] No win32com in get_python_lib(). Try find in %APPDATA%.")
88-
makepy = getWin32ComRomingPath()
89-
#
90-
# Make sure we have win32com installed
91-
#
92-
if makepy is None:
93-
print("[ERR] AutoItLibrary requires win32com. See http://starship.python.net/crew/mhammond/win32/.")
94-
sys.exit(2)
95-
96-
cmd = "python \"%s\" \"%s\"" % (makepy, instFile)
97-
print(cmd)
98-
subprocess.check_call(cmd)
99-
else :
100-
print("AutoItLibrary cannot be installed on non-Windows platforms.")
101-
sys.exit(2)
102-
#
103100
# Figure out the install path
104101
#
105102
root_path = os.path.join(os.getenv("HOMEDRIVE"))
@@ -122,7 +119,8 @@ def getWin32ComRomingPath():
122119
long_description = DESCRIPTION,
123120
package_dir = {'' : "src"},
124121
packages = ["AutoItLibrary"],
125-
install_requires = ['pywin32', 'pillow'],
122+
cmdclass = {'install': InstallCommand},
123+
install_requires = ['robotframework', 'pywin32', 'pillow'],
126124
data_files = [(destPath,
127125
["COPYRIGHT.txt",
128126
"LICENSE.txt",

src/AutoItLibrary/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ class AutoItLibrary(Logger.Logger, Counter.Counter) :
6060
documentation for these keywords is available in the AutoItX documentation file:
6161
*AutoItX.chm*. This file is installed as part of the installation of *AutoItLibrary* as:
6262
63-
C:\RobotFramework\Extensions\AutoItLibrary\AutoItX.chm
63+
C:\\RobotFramework\\Extensions\\AutoItLibrary\\AutoItX.chm
6464
6565
In order to discover the control identifiers in a given Windows GUI, AutoIt provides a standalone
6666
tool called the AutoIt Window Info Tool which is installed as part of the installation of
6767
*AutoItLibrary* as:
6868
69-
C:\RobotFramework\Extensions\AutoItLibrary\Au3Info.exe
69+
C:\\RobotFramework\\Extensions\\AutoItLibrary\\Au3Info.exe
7070
7171
This tool is documented here: http://www.autoitscript.com/autoit3/docs/intro/au3spy.htm
7272
"""

0 commit comments

Comments
 (0)