From f56d65daaae5e5727b830c72f6621e4db362b7ff Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Sun, 1 Sep 2024 07:06:02 -0700 Subject: [PATCH] Migrate CI from Azure Pipelines to GitHub Actions * Add --quiet option * First pass on github workflow for CI * Comment out the 2nd job for now * Changes and tweaks from what I learned in a test project * We also need to run the dox command * Set PYTHONUNBUFFERED in the workflow * Copy sip.h when the siplib is (re)created, instead of later during the build * generate version modules in cmd_sdist too * More fixes for building an sdist in a clean folder * install gettext * sudo * Add build-wheels job * add apt update * Explicitly install libunwind-dev to workaround a package dependency bug * Split the generate and the sdist step into 2 steps. * fixes for building sdist on Windows, and also enable some additional MSVC info when building * Use ilammy/msvc-dev-cmd to set up MSVC * Comment out some no longer needed debug prints * Add remaining matrix entries * Uninstall wxPython at the end of the test, turn off fail-fast. * uninstall --yes * Add builds for Python 3.12 and 3.13 * Pin setuptools to < 74 on Windows due to removal of setuptools.msvc * Remove Azure pipelines * Try building on macOS x86 (not ARM) * Update actions versions to non-deprecated ones * Use macOS 13 (-large images seem to not be available on free accounts) * avoid using -latest to avoid surprises later * fix typo * Remove checkout step from matrix (shouldn't be needed?) * Revert "Remove checkout step from matrix (shouldn't be needed?)" This reverts commit 385ef5c832fafcc97ed6040a9662c86bb934e76f. --------- Co-authored-by: Scott Talbert --- .azure/ci-linux-job.yml | 72 ------------ .azure/ci-macos-job.yml | 67 ----------- .azure/ci-windows-job.yml | 109 ------------------ .github/workflows/ci-build.yml | 197 +++++++++++++++++++++++++++++++++ .gitignore | 1 + build.py | 88 ++++++++++----- buildtools/build_wxwidgets.py | 8 +- buildtools/config.py | 16 +++ wscript | 22 +--- 9 files changed, 281 insertions(+), 299 deletions(-) delete mode 100644 .azure/ci-linux-job.yml delete mode 100644 .azure/ci-macos-job.yml delete mode 100644 .azure/ci-windows-job.yml create mode 100644 .github/workflows/ci-build.yml diff --git a/.azure/ci-linux-job.yml b/.azure/ci-linux-job.yml deleted file mode 100644 index 6d6e7134..00000000 --- a/.azure/ci-linux-job.yml +++ /dev/null @@ -1,72 +0,0 @@ -jobs: -- job: Linux_CI - timeoutInMinutes: 90 - displayName: 'Linux CI' - pool: - vmImage: 'Ubuntu 20.04' - strategy: - matrix: - Py38: - python.version: '3.8' - Py39: - python.version: '3.9' - Py310: - python.version: '3.10' - Py311: - python.version: '3.11' - Py312: - python.version: '3.12' - - variables: - PYTHONUNBUFFERED: '1' - CCACHE_DIR: $(Pipeline.Workspace)/ccache - - steps: - - checkout: self - submodules: recursive - - - task: UsePythonVersion@0 - inputs: - versionSpec: '$(python.version)' - - - script: | - sudo apt-get update - sudo apt-get install -y build-essential ccache - sudo apt-get install -y libgtk-3-dev libjpeg-dev libtiff-dev \ - libsdl2-dev libgstreamer-plugins-base1.0-dev libnotify-dev \ - libsm-dev libwebkit2gtk-4.0-dev libxtst-dev libexpat1-dev \ - libgl1-mesa-dev libglu1-mesa-dev libcurl4-openssl-dev \ - libgstreamer-plugins-bad1.0-dev - echo "##vso[task.prependpath]/usr/lib/ccache" - displayName: 'Install deb package requirements & setup ccache' - - - task: Cache@2 - inputs: - key: 'ccache | "$(Agent.OS)" | "$(python.version)" | "$(Build.BuildNumber)"' - path: $(CCACHE_DIR) - restoreKeys: | - ccache | "$(Agent.OS)" | "$(python.version)" - displayName: ccache - - - script: | - python -m pip install -U pip setuptools wheel - python -m pip install -r requirements.txt - displayName: 'Install Python dependencies' - - - script: | - python build.py --jobs=4 build_wx - displayName: 'build wxWidgets' - - - script: | - python build.py dox etg --nodoc sip - displayName: 'generate code' - - - script: | - python build.py --jobs=4 build_py - displayName: 'build wxPython' - - - script: | - python build.py bdist_wheel - python -m pip install dist/wxPython-*.whl - python -c "import wx; print(wx.version());" - displayName: 'build wheel and test install' diff --git a/.azure/ci-macos-job.yml b/.azure/ci-macos-job.yml deleted file mode 100644 index 478b0182..00000000 --- a/.azure/ci-macos-job.yml +++ /dev/null @@ -1,67 +0,0 @@ -jobs: -- job: MacOS_CI - timeoutInMinutes: 120 - displayName: 'MacOS CI' - pool: - vmImage: 'macOS-12' - strategy: - matrix: - Py38: - python.version: '3.8' - Py39: - python.version: '3.9' - Py310: - python.version: '3.10' - Py311: - python.version: '3.11' - Py312: - python.version: '3.12' - - variables: - PYTHONUNBUFFERED: '1' - CCACHE_DIR: $(Pipeline.Workspace)/ccache - - steps: - - checkout: self - submodules: recursive - - - task: UsePythonVersion@0 - inputs: - versionSpec: '$(python.version)' - - - script: | - brew install ccache - echo "##vso[task.prependpath]/usr/local/opt/ccache/libexec" - displayName: 'Install brew package requirements & setup ccache' - - - task: Cache@2 - inputs: - key: 'ccache | "$(Agent.OS)" | "$(python.version)" | "$(Build.BuildNumber)"' - path: $(CCACHE_DIR) - restoreKeys: | - ccache | "$(Agent.OS)" | "$(python.version)" - displayName: ccache - - - script: | - python -m pip install -U setuptools wheel - python -m pip install -r requirements.txt - displayName: 'Install Python dependencies' - - - script: | - xcode-select --print-path - python build.py --jobs=4 build_wx - displayName: 'build wxWidgets' - - - script: | - python build.py dox etg --nodoc sip - displayName: 'generate code' - - - script: | - python build.py --jobs=4 build_py - displayName: 'build wxPython' - - - script: | - python build.py bdist_wheel - python -m pip install dist/wxPython-*.whl - python -c "import wx; print(wx.version());" - displayName: 'build wheel and test install' diff --git a/.azure/ci-windows-job.yml b/.azure/ci-windows-job.yml deleted file mode 100644 index 0508112c..00000000 --- a/.azure/ci-windows-job.yml +++ /dev/null @@ -1,109 +0,0 @@ -jobs: -- job: Windows_CI - timeoutInMinutes: 90 - displayName: 'Windows CI' - pool: - vmImage: 'windows-2022' - strategy: - matrix: - Py38_x86: - python.version: '3.8' - python.arch: x86 - addToPath: true - Py39_x86: - python.version: '3.9' - python.arch: x86 - addToPath: true - Py310_x86: - python.version: '3.10' - python.arch: x86 - addToPath: true - Py311_x86: - python.version: '3.11' - python.arch: x86 - addToPath: true - Py312_x86: - python.version: '3.12' - python.arch: x86 - addToPath: true - - Py38_x64: - python.version: '3.8' - python.arch: x64 - addToPath: true - Py39_x64: - python.version: '3.9' - python.arch: x64 - addToPath: true - Py310_x64: - python.version: '3.10' - python.arch: x64 - addToPath: true - Py311_x64: - python.version: '3.11' - python.arch: x64 - addToPath: true - Py312_x64: - python.version: '3.12' - python.arch: x64 - addToPath: true - - - variables: {'PYTHONUNBUFFERED': '1'} - - steps: - - checkout: self - submodules: recursive - - - task: UsePythonVersion@0 - inputs: - versionSpec: '$(python.version)' - architecture: '$(python.arch)' - - - bash: | - which python - python -c "import sys; print(sys.version); print(sys.prefix)" - # check what Pythons are available - ls -al /c/hostedtoolcache/windows/Python - displayName: 'Check Python' - - - bash: | - curl -O https://bootstrap.pypa.io/get-pip.py - python get-pip.py - python -m pip install -U setuptools wheel - python -m pip install --prefer-binary -r requirements.txt - displayName: 'Install Python dependencies' - - - bash: | - rm C:/Program\ Files/Microsoft\ Visual\ Studio/2022/Enterprise/VC/Auxiliary/Build/Microsoft.VCToolsVersion.v143.default.* - displayName: 'Remove extra MSVC version' - - - task: BatchScript@1 - displayName: 'Set up vcvarsall' - inputs: - filename: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat' - arguments: $(python.arch) - modifyEnvironment: true - - - bash: | - python build.py --jobs=4 build_wx - displayName: 'build wxWidgets' - - - bash: | - python build.py dox etg --nodoc sip - displayName: 'generate code' - - - bash: | - python build.py --jobs=4 build_py - displayName: 'build wxPython' - - - bash: | - python build.py bdist_wheel - python -m pip install dist/wxPython-*.whl - python -c "import wx; print(wx.version());" - displayName: 'build wheel and test install' - - - task: PublishPipelineArtifact@1 - inputs: - targetPath: dist - artifactName: wxPython-py$(python.version)-win_$(python.arch) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml new file mode 100644 index 00000000..a9e44dce --- /dev/null +++ b/.github/workflows/ci-build.yml @@ -0,0 +1,197 @@ +#--------------------------------------------------------------------------- +# This workflow will build and archive a wxPython source distribution for +# CI. It will start by building a sdist archive first, and then that will be +# used in subsequent jobs on each supported platform and Python version. +#--------------------------------------------------------------------------- + +name: ci-build + +on: + # Trigger on push or PRs targeting the master branch + push: + branches: [ 'master' ] + pull_request: + branches: [ 'master' ] + + # Also allow manual triggering (via web ui) + workflow_dispatch: + +# Cancel the workflow if another instance in the same workflow and PR is triggered +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +defaults: + run: + # always use bash shell, even on windows + shell: bash + +env: + PYTHONUNBUFFERED: 1 + +#--------------------------------------------------------------------------- + +jobs: + # Build a wxPython source archive, and save it as an artifact for use in the + # job that builds the wheels. + build-source-dist: + runs-on: ubuntu-22.04 + + outputs: + VERSION: ${{ steps.generate.outputs.version }} + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + submodules: 'recursive' + fetch-depth: 0 + + - name: Set up Python 3.10 + uses: actions/setup-python@v5 + with: + python-version: '3.10' + cache: 'pip' + + - name: Install dependencies + run: | + sudo apt-get install -y gettext + python -m pip install --upgrade -r requirements.txt + + - name: Generate wrapper code + id: generate + run: | + python build.py setrev dox etg sip --nodoc + VERSION=$(python build.py --quiet version) + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + + - name: Create source distribution (sdist) + run: | + python build.py sdist + + - name: Save sdist as job artifact + uses: actions/upload-artifact@v4 + with: + name: wxPython-source + path: dist/wxPython-${{ steps.generate.outputs.version }}.tar.gz + + +#--------------------------------------------------------------------------- + + # Use pip and the wxPython-source artifact to build a wxPython wheel for every + # supported Python version and architecture. + build-wheels: + # wait for prior job to complete + needs: build-source-dist + strategy: + fail-fast: false + matrix: + os: [ ubuntu-22.04, windows-2022, macos-13 ] + python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12', '3.13-dev' ] + architecture: [ 'x86', 'x64' ] + # Exclude x86 configs on non-Windows OSs + exclude: + - os: ubuntu-22.04 + architecture: x86 + - os: macos-13 + architecture: x86 + + env: + VERSION: ${{ needs.build-source-dist.outputs.VERSION }} + + runs-on: ${{ matrix.os }} + + outputs: + short_name: ${{ steps.init.outputs.short_name }} + canonical_id: ${{ steps.init.outputs.canonical_id }} + + steps: + - name: initialize variables + id: init + run: | + if [ ${{ matrix.os }} == ubuntu-22.04 ]; then + short_name=linux + elif [ ${{ matrix.os }} == macos-13 ]; then + short_name=macos + elif [ ${{ matrix.os }} == windows-2022 ]; then + if [ ${{ matrix.architecture }} == x64 ]; then + short_name=win64 + else + short_name=win32 + fi + fi + echo "short_name=$short_name" >> "$GITHUB_OUTPUT" + echo "canonical_id=$short_name-py${{ matrix.python-version }}-${{ matrix.architecture}}" >> "$GITHUB_OUTPUT" + + - name: Checkout repo + uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: download CI source artifact + uses: actions/download-artifact@v4 + with: + name: wxPython-source + path: dist + + - name: Set up Python ${{ matrix.python-version }}-${{ matrix.architecture }} + uses: actions/setup-python@v5 + with: + python-version: '${{ matrix.python-version }}' + architecture: '${{ matrix.architecture }}' + cache: 'pip' + + - name: Install Python dependencies + run: | + python -m pip install --upgrade -r requirements.txt + + - name: Install Ubuntu dependencies + if: ${{ matrix.os == 'ubuntu-22.04' }} + run: | + sudo apt-get update + sudo apt-get install -y \ + freeglut3-dev \ + libcurl4-openssl-dev \ + libexpat1-dev \ + libgl1-mesa-dev \ + libglu1-mesa-dev \ + libgtk-3-dev \ + libjpeg-dev \ + libnotify-dev \ + libsdl2-dev \ + libsm-dev \ + libtiff-dev \ + libwebkit2gtk-4.0-dev \ + libxtst-dev \ + libunwind-dev \ + libgstreamer1.0-dev \ + libgstreamer-plugins-base1.0-dev + + - name: Setup MSVC + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: '${{ matrix.architecture }}' + + - name: Build the wxPython wheel + run: | + cd dist + pip wheel -v wxPython-${{ env.VERSION }}.tar.gz + + - name: Simple smoke test + run: | + cd dist + pip install wxPython-*.whl + python -c "import wx; print(wx); print(wx.version()); print(wx.PlatformInfo)" + pip uninstall --yes wxPython + + - name: Save wheel as job artifact + uses: actions/upload-artifact@v4 + # Just Windows and MacOS for now, all we care about for Linux at this + # point is that the build was successful. + if: ${{ matrix.os != 'ubuntu-22.04' }} + with: + name: wxPython-wheel-${{ steps.init.outputs.canonical_id }} + path: dist/wxPython-*.whl diff --git a/.gitignore b/.gitignore index 87b935dd..14e46c46 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ mydbstub.py* .cache .vagrant .vscode +.env /build /tmp diff --git a/build.py b/build.py index ac92cc43..7cc97f10 100755 --- a/build.py +++ b/build.py @@ -47,7 +47,7 @@ from buildtools.config import Config, msg, opj, posixjoin, loadETG, etg2sip, fi macSetLoaderNames, \ getVcsRev, runcmd, textfile_open, getSipFiles, \ getVisCVersion, getToolsPlatformName, updateLicenseFiles, \ - TemporaryDirectory, getMSVCInfo + TemporaryDirectory, getMSVCInfo, generateVersionFiles import buildtools.version as version @@ -163,8 +163,9 @@ Usage: ./build.py [command(s)] [options] def main(args): - setPythonVersion(args) setDevModeOptions(args) + options, commands = parseArgs(args) + setPythonVersion(args) os.environ['PYTHONPATH'] = os.environ.get('PYTHONPATH', '') + os.pathsep + phoenixDir() os.environ['PYTHONUNBUFFERED'] = 'yes' @@ -184,8 +185,6 @@ def main(args): usage() sys.exit(1) - options, commands = parseArgs(args) - cfg = Config(noWxConfig=True) msg('cfg.VERSION: %s' % cfg.VERSION) msg('') @@ -454,6 +453,7 @@ def makeOptionParser(): ("regenerate_sysconfig", (False, "Waf uses Python's sysconfig and related tools to configure the build. In some cases that info can be incorrect, so this option regenerates it. Must have write access to Python's lib folder.")), ("no_allmo", (False, "Skip regenerating the wxWidgets message catalogs")), ("no_msedge", (False, "Do not include the MS Edge backend for wx.html2.WebView. (Windows only)")), + ("quiet", (False, "Silence some of the messages from build.py")) ] parser = optparse.OptionParser("build options:") @@ -500,6 +500,10 @@ def parseArgs(args): if options.gtk2: options.gtk3 = False + if options.quiet: + import buildtools.config + buildtools.config.runSilently = True + return options, args @@ -795,6 +799,16 @@ def checkCompiler(quiet=False): arch = 'x64' if PYTHON_ARCH == '64bit' else 'x86' info = getMSVCInfo(PYTHON, arch, set_env=True) + # # Just needed for debugging + # if not quiet: + # msg('MSVCinfo:') + # msg(f' vc_ver: {info.vc_ver}') + # msg(f' vs_ver: {info.vs_ver}') + # msg(f' arch: {info.arch}') + # msg(f' include: {info.include}') + # msg(f' lib: {info.lib}') + # msg(f' libpath: {info.libpath}') + # Make sure there is now a cl.exe on the PATH CL = 'NOT FOUND' for d in os.environ['PATH'].split(os.pathsep): @@ -803,17 +817,16 @@ def checkCompiler(quiet=False): CL = p break if not quiet: - msg(f"CL.exe: {CL}") + msg(f' CL.exe: {CL}') - # Just needed for debugging - # msg('include: ' + info.include) - # msg('lib: ' + info.lib) - # msg('libpath: ' + info.libpath) + # # Just needed for debugging # for d in info.include.split(os.pathsep): # p = pathlib.Path(d, 'tchar.h') # if p.exists(): - # msg('tchar.h: ' + str(p)) + # msg(f' tchar.h: {p}') # break + # else: + # msg('**** tchar.h NOT FOUND!') # NOTE: SIP is now generating code with scoped-enums. Older linux @@ -1082,6 +1095,10 @@ def cmd_docset(options, args): cmd_docset_py(options, args) +def cmd_version(options, args): + cfg = Config() + print(cfg.VERSION) + def cmd_etg(options, args): cmdTimer = CommandTimer('etg') @@ -1411,6 +1428,9 @@ def cmd_sip(options, args): tf.extractall(tmpdir) shutil.move(tf_dir, cfg.SIPINC) + # Copy sip's sip.h for distribution with wxPython's header + copyFile('sip/siplib/sip.h', 'wx/include/wxPython', verbose=True) + def cmd_touch(options, args): cmdTimer = CommandTimer('touch') @@ -1580,18 +1600,20 @@ def cmd_build_wx(options, args): sys.exit(1) if not options.no_allmo: - # Build the wx message catalogs, but first check that there is a msgfmt - # command available - if findCmd('msgfmt') and findCmd('make'): - locale_pwd = pushDir(posixjoin(wxDir(), 'locale')) - print('Building message catalogs in ' + os.getcwd()) - runcmd('make allmo') - del locale_pwd - else: - print("WARNING: msgfmt and/or make commands not found, message catalogs not \n" - " rebuilt. Please install gettext and associated tools.") + make_allmo() +def make_allmo(): + # Build the wx message catalogs, but first check that there is a msgfmt + # command available + if findCmd('msgfmt') and findCmd('make'): + locale_pwd = pushDir(posixjoin(wxDir(), 'locale')) + print('Building message catalogs in ' + os.getcwd()) + runcmd('make allmo') + del locale_pwd + else: + print("WARNING: msgfmt and/or make commands not found, message catalogs not \n" + " rebuilt. Please install gettext and associated tools.") def copyWxDlls(options): if options.no_magic or options.use_syswx: @@ -2138,8 +2160,10 @@ def cmd_sdist(options, args): # Make a place to export everything to PDEST = 'build/sdist' - if not os.path.exists(PDEST): - os.makedirs(PDEST) + if os.path.exists(PDEST): + shutil.rmtree(PDEST) + os.makedirs(PDEST) + TMP = os.path.abspath('build') # and a place to put the final tarball if not os.path.exists('dist'): @@ -2151,7 +2175,11 @@ def cmd_sdist(options, args): if not os.path.exists(dest): os.path.makedirs(dest) pwd = pushDir(root) - runcmd('git archive HEAD | tar -x -C %s' % dest, echoCmd=False) + #runcmd('git archive HEAD | tar -x -C %s' % dest, echoCmd=False) + archive = opj(TMP, 'export.tar') + runcmd('git archive --format=tar -o %s HEAD' % archive) + runcmd('tar -C %s -xf %s' %(dest, archive)) + os.unlink(archive) if os.path.exists('.gitmodules'): with open('.gitmodules', 'rt') as fid: @@ -2163,16 +2191,19 @@ def cmd_sdist(options, args): _archive_submodules('.', os.path.abspath(PDEST)) + generateVersionFiles(cfg) + # copy .py files that need to go into the root wx package dir + for name in ['src/__init__.py', 'src/gizmos.py',]: + copyFile(name, cfg.PKGDIR, verbose=True) + # copy Phoenix's generated code into the archive tree msg('Copying generated files...') - os.mkdir(posixjoin(PDEST, 'sip', 'siplib')) + os.makedirs(posixjoin(PDEST, 'sip', 'siplib'), exist_ok=True) for srcdir in ['cpp', 'gen', 'siplib']: destdir = posixjoin(PDEST, 'sip', srcdir) for name in glob.glob(posixjoin('sip', srcdir, '*')): - try: + if not os.path.isdir(name): copyFile(name, destdir) - except IsADirectoryError: - pass sip_h_dir = posixjoin(cfg.PKGDIR, 'include', 'wxPython') copyFile(posixjoin(sip_h_dir, 'sip.h'), posixjoin(PDEST, sip_h_dir)) for wc in ['*.py', '*.pi', '*.pyi']: @@ -2189,6 +2220,8 @@ def cmd_sdist(options, args): # Copy the locale message catalogs msg('Copying message catalog files...') + if not glob.glob(opj(cfg.WXDIR, 'locale', '*.mo')): + make_allmo() cfg.build_locale_dir(opj(cfg.PKGDIR, 'locale')) shutil.copytree(opj(cfg.PKGDIR, 'locale'), opj(PDEST, cfg.PKGDIR, 'locale')) @@ -2229,6 +2262,7 @@ def cmd_sdist(options, args): msg('Cleaning up...') del pwd + os.chdir(phoenixDir()) shutil.rmtree(PDEST) if options.upload: diff --git a/buildtools/build_wxwidgets.py b/buildtools/build_wxwidgets.py index ea57e19d..973dbc46 100644 --- a/buildtools/build_wxwidgets.py +++ b/buildtools/build_wxwidgets.py @@ -80,13 +80,13 @@ def getWxRelease(wxRoot=None): wxRoot = wxRootDir with open(os.path.join(wxRoot, "configure.in"), "r") as fid: configureText = fid.read() - majorVersion = re.search("wx_major_version_number=(\d+)", configureText).group(1) - minorVersion = re.search("wx_minor_version_number=(\d+)", configureText).group(1) + majorVersion = re.search(r"wx_major_version_number=(\d+)", configureText).group(1) + minorVersion = re.search(r"wx_minor_version_number=(\d+)", configureText).group(1) versionText = "%s.%s" % (majorVersion, minorVersion) if int(minorVersion) % 2: - releaseVersion = re.search("wx_release_number=(\d+)", configureText).group(1) + releaseVersion = re.search(r"wx_release_number=(\d+)", configureText).group(1) versionText += ".%s" % (releaseVersion) return versionText @@ -425,7 +425,7 @@ def main(wxDir, args): setupText = setupText.decode('utf-8') for flag in flags: - setupText, subsMade = re.subn(flag + "\s+?\d", "%s %s" % (flag, flags[flag]), setupText) + setupText, subsMade = re.subn(flag + r"\s+?\d", "%s %s" % (flag, flags[flag]), setupText) if subsMade == 0: print("Flag %s wasn't found in setup.h!" % flag) sys.exit(1) diff --git a/buildtools/config.py b/buildtools/config.py index 4d5df727..94c216ec 100644 --- a/buildtools/config.py +++ b/buildtools/config.py @@ -724,6 +724,22 @@ def getEtgSipCppFiles(etg): def getEtgSipHeaders(etg): return _getSbfValue(etg, 'headers') +def generateVersionFiles(cfg): + # create the package's __version__ module + with open(opj(cfg.PKGDIR, '__version__.py'), 'w') as fid: + fid.write("# This file was generated by wxPython's wscript.\n\n" + "VERSION_STRING = '%(VERSION)s'\n" + "MAJOR_VERSION = %(VER_MAJOR)s\n" + "MINOR_VERSION = %(VER_MINOR)s\n" + "RELEASE_NUMBER = %(VER_RELEASE)s\n" + "BUILD_TYPE = '%(BUILD_TYPE)s'\n\n" + "VERSION = (MAJOR_VERSION, MINOR_VERSION, RELEASE_NUMBER, '%(VER_FLAGS)s')\n" + % cfg.__dict__) + # and one for the demo folder too + with open('demo/version.py', 'w') as fid: + fid.write("# This file was generated by wxPython's wscript.\n\n" + "VERSION_STRING = '%(VERSION)s'\n" + % cfg.__dict__) def findCmd(cmd): """ diff --git a/wscript b/wscript index 67515d72..e26dabbe 100644 --- a/wscript +++ b/wscript @@ -16,7 +16,7 @@ try: except ImportError: from buildtools.backports.textwrap3 import indent -from buildtools.config import Config, runcmd, msg, getMSVCInfo +from buildtools.config import Config, runcmd, msg, getMSVCInfo, generateVersionFiles cfg = Config(True) #----------------------------------------------------------------------------- @@ -537,22 +537,7 @@ def build(bld): # Copy the license files from wxWidgets updateLicenseFiles(cfg) - # create the package's __version__ module - with open(opj(cfg.PKGDIR, '__version__.py'), 'w') as fid: - fid.write("# This file was generated by wxPython's wscript.\n\n" - "VERSION_STRING = '%(VERSION)s'\n" - "MAJOR_VERSION = %(VER_MAJOR)s\n" - "MINOR_VERSION = %(VER_MINOR)s\n" - "RELEASE_NUMBER = %(VER_RELEASE)s\n" - "BUILD_TYPE = '%(BUILD_TYPE)s'\n\n" - "VERSION = (MAJOR_VERSION, MINOR_VERSION, RELEASE_NUMBER, '%(VER_FLAGS)s')\n" - % cfg.__dict__) - # and one for the demo folder too - with open('demo/version.py', 'w') as fid: - fid.write("# This file was generated by wxPython's wscript.\n\n" - "VERSION_STRING = '%(VERSION)s'\n" - % cfg.__dict__) - + generateVersionFiles(cfg) # copy the wx locale message catalogs to the package dir cfg.build_locale_dir(opj(cfg.PKGDIR, 'locale')) @@ -561,9 +546,6 @@ def build(bld): for name in ['src/__init__.py', 'src/gizmos.py',]: copy_file(name, cfg.PKGDIR, update=1, verbose=1) - # Copy sip's sip.h for distribution with wxPython's header - copy_file('sip/siplib/sip.h', 'wx/include/wxPython', update=1, verbose=1) - # Create the build tasks for each of our extension modules. addRelwithdebugFlags(bld, 'siplib') siplib = bld(