11import sys , os , subprocess , shutil
22
3+ print (sys .platform )
34print (sys .executable )
45rootDir = os .path .dirname (__file__ )
56if not rootDir :
1819qtarchdir = qtarch [qtarch .find ("_" ) + 1 :]
1920
2021# 准备环境
21- pyPathEx = f"C:\\ hostedtoolcache\\ windows\\ Python\\ 3.12.10\\ x64\\ python.exe"
22- pyDir = f"C:\\ hostedtoolcache\\ windows\\ Python\\ { pythonversion } \\ { arch } "
23- pyPath = f"{ pyDir } \\ python.exe"
22+ if sys .platform == "win32" :
23+ pyPathEx = f"C:/hostedtoolcache/windows/Python/3.12.10/x64/python.exe"
24+ pyDir = f"C:/hostedtoolcache/windows/Python/{ pythonversion } /{ arch } "
25+ pyPath = f"{ pyDir } /python.exe"
26+ Qtinstallpath = f"D:/a/PyElaWidgetTools/Qt/{ qtversion } /{ qtarchdir } "
27+ elif sys .platform == "linux" :
28+ pyPathEx = f"/opt/hostedtoolcache/Python/3.12.10/x64/bin/python"
29+ pyDir = f"/opt/hostedtoolcache/Python/{ pythonversion } /{ arch } /bin/python"
30+ pyPath = f"{ pyDir } /python.exe"
31+ Qtinstallpath = f"/home/runner/work/PyElaWidgetTools/Qt/{ qtversion } /{ qtarchdir } "
32+
2433subprocess .run (f"{ pyPath } -m pip install --upgrade pip" )
2534if binding .lower ().startswith ("pyqt" ):
2635 if qtversion .startswith ("6" ):
@@ -48,20 +57,23 @@ def __parsefile(fn, cb):
4857 lambda cml : cml .replace ("add_subdirectory(ElaWidgetToolsExample)" , "" ),
4958)
5059__parsefile (
51- r "..\ ElaWidgetTools\ ElaWidgetTools\ CMakeLists.txt" ,
60+ "../ ElaWidgetTools/ ElaWidgetTools/ CMakeLists.txt" ,
5261 lambda cml : cml .replace ("qt_add_library" , "add_library" ), # qt6.8以上
5362)
5463__parsefile (
55- r "..\ ElaWidgetTools\ ElaWidgetTools\ ElaProperty.h" ,
64+ "../ ElaWidgetTools/ ElaWidgetTools/ ElaProperty.h" ,
5665 lambda cml : cml .replace (
5766 "Q_DECL_EXPORT" ,
5867 "" ,
5968 ).replace ("Q_DECL_IMPORT" , "" ),
6069)
61-
62- archA = ("win32" , "x64" )[arch == "x64" ]
70+ if sys .platform == "win32" :
71+ archA = ("win32" , "x64" )[arch == "x64" ]
72+ flags = f'-G "Visual Studio 17 2022" -A { archA } -T host={ arch } '
73+ else :
74+ flags = ""
6375subprocess .run (
64- f' cmake -DELAWIDGETTOOLS_BUILD_STATIC_LIB=ON ../ElaWidgetTools/CMakeLists.txt -G "Visual Studio 17 2022" -A { archA } -T host= { arch } '
76+ f" cmake -DELAWIDGETTOOLS_BUILD_STATIC_LIB=ON ../ElaWidgetTools/CMakeLists.txt { flags } "
6577)
6678subprocess .run (
6779 f"cmake --build ./ --config Release --target ALL_BUILD -j { os .cpu_count ()} "
@@ -73,17 +85,22 @@ def __parsefile(fn, cb):
7385 subprocess .run (f'python gen_widgets.py { int (qtversion .startswith ("5" ))} ' )
7486 subprocess .run (f'python gen_pyi_from_sip.py { int (qtversion .startswith ("5" ))} ' )
7587 subprocess .run (f"{ pyPath } sip_code_fix.py" )
88+ if sys .platform == "win32" :
89+ qmake = f"{ Qtinstallpath } /bin/qmake.exe"
90+ else :
91+ qmake = f"{ Qtinstallpath } /bin/qmake"
92+
7693 subprocess .run (
77- rf"{ pyDir } \ Scripts\ sip-build --verbose --qmake D:\a\PyElaWidgetTools\Qt\ { qtversion } \ { qtarchdir } \bin\ qmake.exe "
94+ rf"{ pyDir } / Scripts/ sip-build --verbose --qmake { qmake } "
7895 )
7996 # for _dir, _, _fs in os.walk(r"."):
8097 # for _f in _fs:
8198 # print(_dir, _f)
8299 os .chdir (".." )
83100 os .mkdir ("objects" )
84- shutil .copy (r "pyqt\ build\ ElaWidgetTools\ ElaWidgetTools.pyd" , "objects" )
85- shutil .copy (r "pyqt\ ElaWidgetTools.pyi" , "objects" )
86- shutil .copytree (r "pyqt\ sip" , "objects/sip" )
101+ shutil .copy ("pyqt/ build/ ElaWidgetTools/ ElaWidgetTools.pyd" , "objects" )
102+ shutil .copy ("pyqt/ ElaWidgetTools.pyi" , "objects" )
103+ shutil .copytree ("pyqt/ sip" , "objects/sip" )
87104
88105elif binding .lower ().startswith ("pyside" ):
89106 cwd = os .getcwd ()
@@ -102,30 +119,29 @@ def __parsefile(fn, cb):
102119 os .chdir ("pyside6" )
103120
104121 subprocess .run (
105- f'python gen_xml.py { os .path .abspath ("../../ElaWidgetTools/ElaWidgetTools" ).replace ("\\ " , "/" )} D:/a/PyElaWidgetTools/Qt/ { qtversion } / { qtarchdir } { pyDir . replace ( " \\ " , "/" ) } '
122+ f'python gen_xml.py { os .path .abspath ("../../ElaWidgetTools/ElaWidgetTools" ).replace ("\\ " , "/" )} { Qtinstallpath } { pyDir } '
106123 )
107124
108- archA = ("win32" , "x64" )[arch == "x64" ]
109125 subprocess .run (
110- f'cmake -DMY_QT_INSTALL=D:/a/PyElaWidgetTools/Qt/ { qtversion } / { qtarchdir } -DMY_PYTHON_INSTALL_PATH={ pyDir .replace ("\\ " , "/" )} -DELA_LIB_PATH={ os .path .abspath ("../ElaWidgetTools/Release/ElaWidgetTools.lib" ).replace ("\\ " , "/" )} -DELA_INCLUDE_PATH={ os .path .abspath ("../../ElaWidgetTools/ElaWidgetTools" ).replace ("\\ " , "/" )} ./CMakeLists.txt -G "Visual Studio 17 2022" -A { archA } -T host= { arch } '
126+ f'cmake -DMY_QT_INSTALL={ Qtinstallpath } -DMY_PYTHON_INSTALL_PATH={ pyDir .replace ("\\ " , "/" )} -DELA_LIB_PATH={ os .path .abspath ("../ElaWidgetTools/Release/ElaWidgetTools.lib" ).replace ("\\ " , "/" )} -DELA_INCLUDE_PATH={ os .path .abspath ("../../ElaWidgetTools/ElaWidgetTools" ).replace ("\\ " , "/" )} ./CMakeLists.txt { flags } '
111127 )
112128 subprocess .run (
113129 f"cmake --build ./ --config Release --target ALL_BUILD -j { os .cpu_count ()} "
114130 )
115131
116132 os .chdir (".." )
117133 os .mkdir ("objects" )
118- shutil .copy (r "pyside6\ Release\ ElaWidgetTools.pyd" , "objects" )
119- shutil .copy (pyipath + r"\ ElaWidgetTools.pyi" , "objects" )
134+ shutil .copy ("pyside6/ Release/ ElaWidgetTools.pyd" , "objects" )
135+ shutil .copy (pyipath + "/ ElaWidgetTools.pyi" , "objects" )
120136
121137dirname = f"{ binding } ElaWidgetTools"
122- os .mkdir (rf "wheel\ { dirname } " )
123- shutil .copy (r "objects\ ElaWidgetTools.pyd" , rf "wheel\ { dirname } " )
124- shutil .copy (r "objects\ ElaWidgetTools.pyi" , rf "wheel\ { dirname } " )
138+ os .mkdir (f "wheel/ { dirname } " )
139+ shutil .copy ("objects/ ElaWidgetTools.pyd" , f "wheel/ { dirname } " )
140+ shutil .copy ("objects/ ElaWidgetTools.pyi" , f "wheel/ { dirname } " )
125141
126- with open (r "wheel\ __init__.py" , "r" ) as ff :
142+ with open ("wheel/ __init__.py" , "r" ) as ff :
127143 init = ff .read ()
128- with open (rf "wheel\ { dirname } \ __init__.py" , "w" ) as ff :
144+ with open (f "wheel/ { dirname } / __init__.py" , "w" ) as ff :
129145 ff .write (f"from { binding } import QtCore, QtWidgets, QtGui\n " + init )
130146
131147#
0 commit comments