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
2526import sys
2627import os
2728import shutil
4546methods 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+
4889def getWin32ComRomingPath ():
4990 for dirpath , dirs , files in os .walk (os .getenv ('APPDATA' )):
5091 for filename in files :
@@ -56,50 +97,6 @@ def getWin32ComRomingPath():
5697
5798if __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" ,
0 commit comments