diff --git a/build.py b/build.py index c0e6daf..55b7c48 100644 --- a/build.py +++ b/build.py @@ -26,7 +26,7 @@ #local files import utils -def buildheader(release, filepath , pyiver="None"): +def buildheader(release, filepath , pyiver="None", winever=None): lines = [ "Building PS3GameUpdateDownloader", "Build script arguments: "+str(sys.argv[1:]), "Version: "+release["version"], @@ -35,10 +35,12 @@ def buildheader(release, filepath , pyiver="None"): ] if pyiver != "None": lines.append(f"Python version: Python {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}{sys.version_info.releaselevel} ({platform.python_implementation()})") - lines.append("Platform: "+platform.system()+" "+platform.architecture()[0]) - if platform.system() == "Linux": + lines.append(f"Platform: {platform.system()} {platform.architecture()[0]}") + if platform.system() == "Windows" and winever is not None: + lines.append(f"Built on Wine Version: {winever}") + elif platform.system() == "Linux": lines.append(f"LibC: {platform.libc_ver()[0]} {platform.libc_ver()[1]}") - lines.append("PyInstaller version: "+pyiver) + lines.append(f"PyInstaller version: {pyiver}") lines.append("PyInstaller Output:") with Prepender(filepath) as filehandle: filehandle.write_lines(lines) @@ -184,6 +186,7 @@ def __exit__(self, type, value, traceback): parser.add_argument("-z", "--zip", action="store_true", help="pack the build to a .zip file") parser.add_argument("--docker", action="store_true", help='copy build zip to "./docker_output", requires --zip') parser.add_argument("--githash", action="store", help="gives git commit hash to build script(mostly useful for docker builds)") +parser.add_argument("--winever", action="store", help="gives wine version to build script(mostly useful for docker builds)") args = parser.parse_args() #constants @@ -198,6 +201,7 @@ def __exit__(self, type, value, traceback): dockerdir = os.path.abspath("./docker_output") mainpyifile = "main_ps3gud.py" updaterpyifile = "updater.py" +winever = None #get data from release.json with open("release.json", "r", encoding="utf8") as f: release = json.loads(f.read()) @@ -230,6 +234,8 @@ def __exit__(self, type, value, traceback): if os.path.exists(dockerdir) == False: os.makedirs(dockerdir) +if args.winever is not None: + winever = args.winever #auto config for build suffix = "" @@ -390,7 +396,7 @@ def __exit__(self, type, value, traceback): print(f"copying data to '{builddir}'") copyData(builddir, locdirname, imagedirname) #write header to buildlog - buildheader(release, buildlog, pyiver=PyInstaller.__init__.__version__) + buildheader(release, buildlog, pyiver=PyInstaller.__init__.__version__, winever=winever) #save commitid saveCommitId(release, builddir) #validate & minify json files @@ -458,7 +464,7 @@ def __exit__(self, type, value, traceback): print(f"copying data to '{builddir}'") copyData(builddir, locdirname, imagedirname, debug=True) #write header to buildlog - buildheader(release, buildlog, pyiver=PyInstaller.__init__.__version__) + buildheader(release, buildlog, pyiver=PyInstaller.__init__.__version__, winever=winever) #save commitid saveCommitId(release, builddir) #validate json files diff --git a/dockerfiles/build-linux-win32.dockerfile b/dockerfiles/build-linux-win32.dockerfile index 9c0f91a..347a254 100644 --- a/dockerfiles/build-linux-win32.dockerfile +++ b/dockerfiles/build-linux-win32.dockerfile @@ -9,13 +9,13 @@ VOLUME /code/docker_output RUN apt update -y && apt install wget xvfb git -y # installing python RUN wget -O /tmp/python-$PYVER.exe https://www.python.org/ftp/python/$PYVER/python-$PYVER.exe -RUN xvfb-run wine /tmp/python-$PYVER.exe /quiet InstallAllUsers=1 TargetDir=C:\\py32 Include_doc=0 Include_launcher=0 Include_test=0 PrependPath=1 +RUN xvfb-run wine /tmp/python-$PYVER.exe /quiet InstallAllUsers=1 TargetDir=C:\\py Include_doc=0 Include_launcher=0 Include_test=0 PrependPath=1 # hack to bypass missing implementation of CopyFile2 in Wine(needed for python 3.12.0 and above) -RUN sed -i 's/"CopyFile2"/"CopyFile2_xx_invalid_disabled"/' /opt/wineprefix/drive_c/py32/Lib/shutil.py +RUN sed -i 's/"CopyFile2"/"CopyFile2_xx_invalid_disabled"/' /opt/wineprefix/drive_c/py/Lib/shutil.py # copying code COPY . /code # installing pip depencies -RUN wine C:\\py32\\python.exe -m pip install --disable-pip-version-check --no-cache-dir -U wheel pip -RUN wine C:\\py32\\python.exe -m pip install --disable-pip-version-check --no-cache-dir -r requirements.txt -r buildrequirements.txt +RUN wine C:\\py\\python.exe -m pip install --disable-pip-version-check --no-cache-dir -U wheel pip +RUN wine C:\\py\\python.exe -m pip install --disable-pip-version-check --no-cache-dir -r requirements.txt -r buildrequirements.txt # build -CMD ["sh", "-c", "wine 'C://py32//python.exe' build.py --compiled --release --zip --docker --githash $(git rev-parse --short HEAD)"] +CMD ["sh", "-c", "wine 'C://py//python.exe' build.py --compiled --release --zip --docker --githash $(git rev-parse --short HEAD) --winever $(wine --version)"] diff --git a/dockerfiles/build-linux-win64.dockerfile b/dockerfiles/build-linux-win64.dockerfile index df3bd6f..a908a48 100644 --- a/dockerfiles/build-linux-win64.dockerfile +++ b/dockerfiles/build-linux-win64.dockerfile @@ -1,14 +1,21 @@ # setup FROM tobix/pywine:3.12 ENV WINEARCH=win64 +# python version to install +ENV PYVER=3.12.0-amd64 WORKDIR /code VOLUME /code/docker_output # installing depencies -RUN apt update -y && apt install git -y +RUN apt update -y && apt install wget xvfb git -y +# installing python +RUN wget -O /tmp/python-$PYVER.exe https://www.python.org/ftp/python/$PYVER/python-$PYVER.exe +RUN xvfb-run wine /tmp/python-$PYVER.exe /quiet InstallAllUsers=1 TargetDir=C:\\py Include_doc=0 Include_launcher=0 Include_test=0 PrependPath=1 +# hack to bypass missing implementation of CopyFile2 in Wine(needed for python 3.12.0 and above) +RUN sed -i 's/"CopyFile2"/"CopyFile2_xx_invalid_disabled"/' /opt/wineprefix/drive_c/py/Lib/shutil.py # copying code COPY . /code # installing pip depencies -RUN wine python -m pip install --disable-pip-version-check --no-cache-dir -U wheel pip -RUN wine python -m pip install --disable-pip-version-check --no-cache-dir -r requirements.txt -r buildrequirements.txt +RUN wine C:\\py\\python.exe -m pip install --disable-pip-version-check --no-cache-dir -U wheel pip +RUN wine C:\\py\\python.exe -m pip install --disable-pip-version-check --no-cache-dir -r requirements.txt -r buildrequirements.txt # build -CMD ["sh", "-c", "wine python build.py --compiled --release --zip --docker --githash $(git rev-parse --short HEAD)"] +CMD ["sh", "-c", "wine C:\\py\\python.exe build.py --compiled --release --zip --docker --githash $(git rev-parse --short HEAD) --winever $(wine --version)"]