diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000000..9ec6528997c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,92 @@ +name: Build +on: workflow_dispatch +jobs: + build: + strategy: + matrix: + os: [macos-12, ubuntu-latest, windows-latest] + + runs-on: ${{ matrix.os }} + + steps: + - name: Check out SimpleFC repository (Windows) + if: matrix.os == 'windows-latest' + uses: actions/checkout@v4 + with: + repository: mazinsw/SimpleFC + - name: Build SimpleFC NSIS Plugin (Windows) + if: matrix.os == 'windows-latest' + run: | + copy "bin\x86-unicode\SimpleFC.dll" "C:\Program Files (x86)\NSIS\Plugins\x86-unicode\SimpleFC.dll" + - name: Check out nsProcess repository (Windows) + if: matrix.os == 'windows-latest' + uses: actions/checkout@v4 + with: + repository: simdsoft/nsProcess + submodules: 'true' + - name: Add msbuild to PATH (Windows) + if: matrix.os == 'windows-latest' + uses: microsoft/setup-msbuild@v2 + - name: Build nsProcess NSIS Plugin (Windows) + if: matrix.os == 'windows-latest' + run: | + cd nsProcess + msbuild nsProcess.vcxproj /p:PlatformToolset=v143 /p:Configuration="Release UNICODE" + copy "Release UNICODE\nsProcess.dll" "C:\Program Files (x86)\NSIS\Plugins\x86-unicode\nsProcess.dll" + cd ../Include + copy nsProcess.nsh "C:\Program Files (x86)\NSIS\Include\nsProcess.nsh" + - name: Check-out repository + uses: actions/checkout@v4 + with: + submodules: 'true' + fetch-tags: 'true' + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + cache: 'pip' + cache-dependency-path: | + **/requirements-build.txt + - name: Install Dependencies + run: | + pip install --upgrade -r requirements-build.txt + - name: Setup npm + uses: actions/setup-node@v4 + - name: Build npm + run: | + cd src/tribler/ui/ + npm install + npm run build + - name: Determine tag + shell: bash + run: | + git fetch --tags + git for-each-ref --count=1 --sort=-creatordate --format '%(refname)' refs/tags > raw_tag.txt + echo "GITHUB_TAG=$(git name-rev --tags --name-only $(cat raw_tag.txt))" >> $GITHUB_ENV + - name: Build Executables (Ubuntu) + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt-get install -y --allow-downgrades alien cpio=2.13+dfsg-7 devscripts fakeroot gir1.2-gtk-4.0 rpm + ./build/debian/makedist_debian.sh + - name: Build Executables (MacOS-12) + if: matrix.os == 'macos-12' + run: | + ./build/mac/makedist_macos.sh + - uses: actions/cache/restore@v4 + if: matrix.os == 'windows-latest' + id: restore_cache + with: + path: src/libsodium.dll + key: cache_libsodium_dll + - name: Build Executables (Windows) + if: matrix.os == 'windows-latest' + run: | + ./build/win/makedist_win.bat + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ runner.os }} Build + path: | + dist/*.exe + dist/*.dmg + build/debian/*.deb diff --git a/build/debian/makedist_debian.sh b/build/debian/makedist_debian.sh index 70e7f884a05..cc0d6be344b 100755 --- a/build/debian/makedist_debian.sh +++ b/build/debian/makedist_debian.sh @@ -2,53 +2,28 @@ set -x # print all commands set -e # exit when any command fails -LOG_LEVEL=${LOG_LEVEL:-"DEBUG"} - -if [[ ! -d build/debian ]]; then - echo "Please run this script from project root as:\n./build/debian/makedist_debian.sh" -fi - rm -rf build/tribler rm -rf dist/tribler rm -rf build/debian/tribler/usr/share/tribler -if [ ! -z "$VENV" ]; then - echo "Setting venv to $VENV" - source $VENV/bin/activate -else - echo "Creating a new venv" - python3 -m venv build-env - . ./build-env/bin/activate -fi - # ----- Install dependencies before the build -python3 -m pip install --upgrade pip -python3 -m pip install --upgrade -r requirements-build.txt +python3 -m pip install --upgrade PyGObject # ----- Update version -python3 ./build/update_version.py -r . -python3 ./build/debian/update_metainfo.py -r . - -# ----- Build UI -pushd . -cd src/tribler/ui/ -npm install -npm run build -popd +python3 ./build/debian/update_metainfo.py # ----- Build binaries -echo Building Tribler using Cx_Freeze python3 setup.py build # ----- Build dpkg cp -r ./dist/tribler ./build/debian/tribler/usr/share/tribler -TRIBLER_VERSION=$(head -n 1 .TriblerVersion) # read the first line only - # Compose the changelog cd ./build/debian/tribler -dch -v $TRIBLER_VERSION "New release" -dch -v $TRIBLER_VERSION "See https://github.com/Tribler/tribler/releases/tag/$TRIBLER_VERSION for more info" +export DEBEMAIL="info@tribler.org" +export DEBFULLNAME="Tribler" +dch -v $GITHUB_TAG "New release" +dch -v $GITHUB_TAG "See https://github.com/Tribler/tribler/releases/tag/$GITHUB_TAG for more info" dpkg-buildpackage -b -rfakeroot -us -uc diff --git a/build/debian/tribler/debian/changelog b/build/debian/tribler/debian/changelog index b944f3dc060..f5c934425da 100644 --- a/build/debian/tribler/debian/changelog +++ b/build/debian/tribler/debian/changelog @@ -1,20 +1,22 @@ tribler (7.0.0) unstable; urgency=medium - * New release - * See https://github.com/Tribler/tribler/releases/tag/v7.0.0 for more info. + * New release + * See https://github.com/Tribler/tribler/releases/tag/v7.0.0 for more info. + + -- Tribler Thu, 25 Jan 2018 12:31:00 +0100 tribler (6.5.2) unstable; urgency=medium - * New release - * See https://github.com/Tribler/tribler/releases/tag/v6.5.2 for more info. - * See https://github.com/Tribler/tribler/releases/tag/v6.5.1 for more info. + * New release + * See https://github.com/Tribler/tribler/releases/tag/v6.5.2 for more info. + * See https://github.com/Tribler/tribler/releases/tag/v6.5.1 for more info. -- whirm Fri, 13 May 2016 12:04:44 +0200 tribler (6.5.0) unstable; urgency=medium - * New release - * See https://github.com/Tribler/tribler/releases/tag/v6.5.0 for more info. + * New release + * See https://github.com/Tribler/tribler/releases/tag/v6.5.0 for more info. -- whirm Fri, 12 Feb 2016 11:24:43 +0100 diff --git a/build/debian/update_metainfo.py b/build/debian/update_metainfo.py index 114623e154a..b48733c80dc 100644 --- a/build/debian/update_metainfo.py +++ b/build/debian/update_metainfo.py @@ -1,37 +1,12 @@ -import logging -import time -import xml.etree.ElementTree as xml -from argparse import ArgumentParser -from pathlib import Path - -import defusedxml.ElementTree as defxml - -logger = logging.getLogger(__name__) -logging.basicConfig(level=logging.INFO) - - -def parse_arguments(): - parser = ArgumentParser(description='Update Tribler metainfo.xml') - parser.add_argument('-r', '--repo', type=str, help='path to a repository folder', default='.') - return parser.parse_args() - - -if __name__ == '__main__': - arguments = parse_arguments() - - version = Path('.TriblerVersion').read_text().lstrip('v').rstrip('\n') - - release_info = { - 'version': version, - 'date': time.strftime("%Y-%m-%d", time.localtime()) - } - - logger.info(f'Release info: {release_info}') - metainfo_xml = Path(arguments.repo) / 'build/debian/tribler/usr/share/metainfo/org.tribler.Tribler.metainfo.xml' - - xml_dom = defxml.parse(metainfo_xml) - releases = xml_dom.getroot().find('releases') - release = xml.SubElement(releases, 'release', release_info) - - xml_dom.write(metainfo_xml, encoding='utf-8', xml_declaration=True) - logger.info(f'Content of metainfo.xml: {metainfo_xml.read_text()}') +from os import getenv +from time import localtime, strftime +from xml.etree.ElementTree import SubElement, parse + +if __name__ == "__main__": + metainfo_xml = "build/debian/tribler/usr/share/metainfo/org.tribler.Tribler.metainfo.xml" + tree = parse(metainfo_xml) + root = tree.getroot() + releases_tag = root.find("releases") + releases_tag.append(SubElement(releases_tag, "release", {"version": getenv("GITHUB_TAG"), + "date": strftime("%Y-%m-%d", localtime())})) + tree.write(metainfo_xml, encoding="utf-8", xml_declaration=True) diff --git a/build/mac/env.sh b/build/mac/env.sh index fdacb237c10..2f80ff69ca9 100755 --- a/build/mac/env.sh +++ b/build/mac/env.sh @@ -3,28 +3,11 @@ set -x # print all commands set -e # exit when any command fails export APPNAME=Tribler +export DMGNAME="Tribler-$GITHUB_TAG" + export LOG_LEVEL=${LOG_LEVEL:-"DEBUG"} export BUILD_ENV=${BUILD_ENV:-"venv"} -PRE_BUILD_INSTRUCTIONS=$(cat <<-END - git describe --tags | python -c "import sys; print(next(sys.stdin).lstrip('v'))" > .TriblerVersion - git rev-parse HEAD > .TriblerCommit - - export TRIBLER_VERSION=\$(head -n 1 .TriblerVersion) - python3 ./build/update_version.py -r . -END -) - -if [ ! -f .TriblerVersion ]; then - echo "No .TriblerVersion file found, run the following commands:" - echo "$PRE_BUILD_INSTRUCTIONS" - exit 1 -fi - -if [ -e .TriblerVersion ]; then - export DMGNAME="Tribler-$(cat .TriblerVersion)" -fi - # Directories export DIST_DIR=dist export INSTALL_DIR=$DIST_DIR/installdir diff --git a/build/mac/makedist_macos.sh b/build/mac/makedist_macos.sh index 46727beda0a..5fed30ed32d 100755 --- a/build/mac/makedist_macos.sh +++ b/build/mac/makedist_macos.sh @@ -7,27 +7,10 @@ set -e # exit when any command fails source ./build/mac/env.sh -# ----- Clean up -/bin/rm -rf $DIST_DIR - -# ----- Prepare venv & install dependencies before the build - -python3 -m venv "${BUILD_ENV}" -. "${BUILD_ENV}"/bin/activate -python3 -m pip install --upgrade pip -python3 -m pip install --upgrade -r requirements-build.txt - -# ----- Build UI - -pushd . -cd src/tribler/ui/ -npm install -npm run build -rm -rf node_modules -popd +# ----- Clean UI +rm -rf src/tribler/ui/node_modules # ----- Build - pyinstaller tribler.spec --log-level="${LOG_LEVEL}" mkdir -p $INSTALL_DIR diff --git a/build/update_version.py b/build/update_version.py deleted file mode 100644 index 198cca051fb..00000000000 --- a/build/update_version.py +++ /dev/null @@ -1,47 +0,0 @@ -import logging -import os -from argparse import ArgumentParser -from pathlib import Path -from time import ctime - -logger = logging.getLogger(__name__) -logging.basicConfig(level=logging.INFO) - - -def parse_arguments(): - parser = ArgumentParser(description='Update Tribler Version') - parser.add_argument('-r', '--repo', type=str, help='path to a repository folder', default='.') - return parser.parse_args() - - -if __name__ == '__main__': - arguments = parse_arguments() - logger.info(f'Arguments: {arguments}') - - ref_name = Path('.TriblerVersion').read_text().rstrip('\n') - logger.info(f'Tribler tag: {ref_name}') - - commit = Path('.TriblerCommit').read_text().rstrip('\n') - logger.info(f'Git Commit: {commit}') - - build_time = ctime() - logger.info(f'Build time: {build_time}') - - sentry_url = os.environ.get('SENTRY_URL', None) - logger.info(f'Sentry URL (hash): {hash(sentry_url)}') - if sentry_url is None: - logger.critical('Sentry url is not defined. To define sentry url use:' - 'EXPORT SENTRY_URL=\n' - 'If you want to disable sentry, then define the following:' - 'EXPORT SENTRY_URL=') - exit(1) - - version_py = Path(arguments.repo) / 'src/tribler/core/version.py' - logger.info(f'Write info to: {version_py}') - version_py.write_text( - f'version_id = "{ref_name}"\n' - f'build_date = "{build_time}"\n' - f'commit_id = "{commit}"\n' - f'sentry_url = "{sentry_url}"\n' - ) - diff --git a/build/win/build.py b/build/win/build.py index d4b5c80a657..a39a532cda5 100644 --- a/build/win/build.py +++ b/build/win/build.py @@ -57,7 +57,6 @@ def get_freeze_build_options(): included_files = [ ("src/tribler/ui/public", "lib/tribler/ui/public"), ("src/tribler/ui/dist", "lib/tribler/ui/dist"), - ("src/tribler/core", "tribler_source/tribler/core"), ("src/tribler/ui/public", "tribler_source/tribler/ui/public"), ("src/tribler/ui/dist", "tribler_source/tribler/ui/dist"), @@ -91,7 +90,6 @@ def get_freeze_build_options(): if platform.system() == 'Linux': _setup_options["build_exe"]["bin_includes"] = "libffi.so" - app_name = "Tribler" if sys.platform != "linux" else "tribler" app_script = "src/tribler/run.py" app_icon_path = "build/win/resources/tribler.ico" if sys.platform == "win32" else "build/mac/resources/tribler.icns" diff --git a/build/win/clean.bat b/build/win/clean.bat deleted file mode 100644 index 4291d61f156..00000000000 --- a/build/win/clean.bat +++ /dev/null @@ -1,2 +0,0 @@ -rmdir /S /Q dist -del /S /Q *.pyc diff --git a/build/win/makedist_win.bat b/build/win/makedist_win.bat index 4cc22b965eb..72920d0365c 100644 --- a/build/win/makedist_win.bat +++ b/build/win/makedist_win.bat @@ -22,35 +22,8 @@ IF NOT EXIST %NSIS% ( EXIT /b ) -REM ----- Clean up - -call build\win\clean.bat - -REM ----- Prepare venv & install dependencies before the build -if defined VENV ( - call "%VENV%\Scripts\activate.bat" -) else ( - echo VENV environment variable is not set. Skipping. -) - -call python3 -m pip install --upgrade pip -call python3 -m pip install --upgrade -r requirements-build.txt - -REM ----- Build UI -pushd . -cd src/tribler/ui/ -call npm install -call npm run build -popd - REM ----- Build -REM Arno: When adding files here, make sure tribler.nsi actually -REM packs them in the installer .EXE - -ECHO Install pip dependencies for correct py-installer's work -call python3 -m pip install --upgrade -r build\win\requirements.txt - REM Sandip 2024-03-22: Deprecated, we are not using PyInstaller anymore because of issue with False Malware detections. REM %PYTHONHOME%\Scripts\pyinstaller.exe tribler.spec --log-level=%LOG_LEVEL% || exit /b ECHO Building Tribler using Cx_Freeze @@ -64,15 +37,10 @@ REM copy Tribler\Main\Build\Win\tribler.exe.manifest dist\tribler mkdir dist\tribler\tools copy build\win\tools\reset*.bat dist\tribler\tools -REM Laurens, 2016-04-20: Copy the redistributables of 2008, 2012 and 2015 to the install dir -REM Sandip, 2019-10-24: redistributables 2008, 2012 are not necessary anymore -REM copy C:\build\vc_redist_110.exe dist\tribler -copy C:\build\vc_redist_140.exe dist\tribler - REM Copy various libraries required on runtime (libsodium and openssl) -copy C:\build\libsodium.dll dist\tribler\lib +move src\libsodium.dll dist\tribler\lib REM Sandip, 2024-03-26: Some openssl dlls are missing so need to be copied manually. -copy C:\build\openssl\*.dll dist\tribler\lib +copy C:\Program Files\OpenSSL\bin\*.dll dist\tribler\lib @echo Running NSIS @@ -86,7 +54,7 @@ if not defined SKIP_SIGNING_TRIBLER_BINARIES ( signtool.exe sign /f C:\build\certs\certificate.pfx /p "%PASSWORD%" /d "Tribler" /t "http://timestamp.digicert.com" tribler.exe ) :makeinstaller -%NSIS% tribler.nsi || exit /b +%NSIS% /DVERSION=%GITHUB_TAG% tribler.nsi || exit /b move Tribler_*.exe .. cd .. REM Arno: Sign installer diff --git a/build/win/replace_nsi.py b/build/win/replace_nsi.py deleted file mode 100644 index bb35d758c99..00000000000 --- a/build/win/replace_nsi.py +++ /dev/null @@ -1,32 +0,0 @@ -import logging -from argparse import ArgumentParser -from pathlib import Path - -logger = logging.getLogger(__name__) -logging.basicConfig(level=logging.INFO) - - -def parse_arguments(): - parser = ArgumentParser(description='Update Tribler NSI') - parser.add_argument('-r', '--repo', type=str, help='path to a repository folder', default='.') - parser.add_argument('-a', '--architecture', type=str, help='architecture (x86 or x64)', default='x86') - return parser.parse_args() - - -if __name__ == '__main__': - arguments = parse_arguments() - - version = Path('.TriblerVersion').read_text().lstrip('v').rstrip('\n') - tribler_nsi = Path(arguments.repo) / 'build/win/resources/tribler.nsi' - content = tribler_nsi.read_text() - - content = content.replace('__GIT__', version) - if arguments.architecture == 'x64': - content = content.replace('x86', 'x64') - content = content.replace('"32"', '"64"') - content = content.replace('$PROGRAMFILES', '$PROGRAMFILES64') - - tribler_nsi.write_text(content) - - logger.info(f'Content of tribler.nsi: {content}') - diff --git a/build/win/requirements.txt b/build/win/requirements.txt deleted file mode 100644 index 0e568918991..00000000000 --- a/build/win/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ ---no-binary :all: - -typing_extensions==4.2.0 -pydantic==1.9.0 diff --git a/build/win/resources/torrenticon.ico b/build/win/resources/torrenticon.ico new file mode 100644 index 00000000000..aaea20ee79f Binary files /dev/null and b/build/win/resources/torrenticon.ico differ diff --git a/build/win/resources/tribler.nsi b/build/win/resources/tribler.nsi index 447090ce756..f28895f8079 100644 --- a/build/win/resources/tribler.nsi +++ b/build/win/resources/tribler.nsi @@ -1,8 +1,4 @@ !define PRODUCT "Tribler" -; Laurens, 2016-03-14: The __GIT__ string will be replaced by update_version_from_git.py -; with the current version of the build. -!define VERSION "__GIT__" -; Laurens, 2016-03-14: The _x86 will be replaced by _x64 if needed in update_version_from_git.py !define BITVERSION "x86" !include "MUI2.nsh" @@ -68,7 +64,7 @@ BrandingText "${PRODUCT}" ;-------------------------------- ;Modern UI Configuration -!define MUI_ICON "tribler_source\resources\tribler.ico" +!define MUI_ICON "..\..\build\win\resources\tribler.ico" !define MUI_COMPONENTSPAGE_SMALLDESC !define MUI_ABORTWARNING @@ -122,14 +118,16 @@ Section "!Main EXE" SecMain ; ExecWait "$INSTDIR\vc_redist_110.exe /q /norestart" ; Libraries dependant on 2015 are: Python, Qt5 - File vc_redist_140.exe - ExecWait "$INSTDIR\vc_redist_140.exe /q /norestart" + File "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Redist\MSVC\v143\vc_redist.x64.exe" + ExecWait "$INSTDIR\vc_redist.x64.exe /q /norestart" FileOpen $9 "$INSTDIR\tribler.exe.log" w FileWrite $9 "" FileClose $9 - AccessControl::GrantOnFile "$INSTDIR\tribler.exe.log" "(BU)" "FullAccess" - AccessControl::GrantOnFile "$INSTDIR\tribler.exe.log" "(S-1-5-32-545)" "FullAccess" + Exec 'icacls "$INSTDIR\tribler.exe.log" /grant *BU:F' + #AccessControl::GrantOnFile "$INSTDIR\tribler.exe.log" "(BU)" "FullAccess" + Exec 'icacls "$INSTDIR\tribler.exe.log" /grant *S-1-5-32-545:F' + #AccessControl::GrantOnFile "$INSTDIR\tribler.exe.log" "(S-1-5-32-545)" "FullAccess" ; End SetOutPath "$INSTDIR" @@ -179,14 +177,14 @@ Section "Make Default For .torrent" SecDefaultTorrent WriteRegBin HKCR bittorrent EditFlags 00000100 WriteRegStr HKCR "bittorrent\shell" "" open WriteRegStr HKCR "bittorrent\shell\open\command" "" '"$INSTDIR\${PRODUCT}.exe" "%1"' - WriteRegStr HKCR "bittorrent\DefaultIcon" "" "$INSTDIR\Tribler\Main\vwxGUI\images\torrenticon.ico" + WriteRegStr HKCR "bittorrent\DefaultIcon" "" "$INSTDIR\tribler_source\resources\torrenticon.ico" SectionEnd Section "Make Default For magnet://" SecDefaultMagnet WriteRegStr HKCR "magnet" "" "URL: Magnet Link Protocol" WriteRegStr HKCR "magnet" "URL Protocol" "" - WriteRegStr HKCR "magnet\DefaultIcon" "" "$INSTDIR\Tribler\Main\vwxGUI\images\torrenticon.ico" + WriteRegStr HKCR "magnet\DefaultIcon" "" "$INSTDIR\tribler_source\resources\torrenticon.ico" WriteRegStr HKCR "magnet\shell\open\command" "" '"$INSTDIR\${PRODUCT}.exe" "%1"' WriteRegStr HKLM "SOFTWARE\Classes\magnet\shell\open\command" "" '"$INSTDIR\${PRODUCT}.exe" "%1"' SectionEnd @@ -199,9 +197,7 @@ SectionEnd !insertmacro MUI_DESCRIPTION_TEXT ${SecDesk} $(DESC_SecDesk) !insertmacro MUI_DESCRIPTION_TEXT ${SecStart} $(DESC_SecStart) !insertmacro MUI_DESCRIPTION_TEXT ${SecDefaultTorrent} $(DESC_SecDefaultTorrent) -!insertmacro MUI_DESCRIPTION_TEXT ${SecDefaultTStream} $(DESC_SecDefaultTStream) !insertmacro MUI_DESCRIPTION_TEXT ${SecDefaultMagnet} $(DESC_SecDefaultMagnet) -!insertmacro MUI_DESCRIPTION_TEXT ${SecDefaultPpsp} $(DESC_SecDefaultPpsp) !insertmacro MUI_FUNCTION_DESCRIPTION_END ;-------------------------------- diff --git a/requirements-build.txt b/requirements-build.txt index cf088a6f22a..0a9dca929f6 100644 --- a/requirements-build.txt +++ b/requirements-build.txt @@ -1,19 +1,7 @@ -# These are specific versions of the packages that are used for making the build work. -# These are installed before other dependencies. -PyQt5==5.15.10 -PyQt5-sip==12.13.0 -pyqtgraph==0.13.3 - -r requirements.txt -cx_Freeze==7.0.0; sys_platform != 'darwin' -PyInstaller==6.6.0; sys_platform == 'darwin' - -setuptools==65.5.1; sys_platform == 'darwin' -text-unidecode==1.3; sys_platform == 'darwin' - -defusedxml==0.7.1; sys_platform == 'linux2' or sys_platform == 'linux' -markupsafe==2.0.1; sys_platform == 'linux2' or sys_platform == 'linux' -PyGObject==3.44.1; sys_platform == 'linux2' or sys_platform == 'linux' +cx_Freeze; sys_platform != 'darwin' +PyInstaller; sys_platform == 'darwin' -requests==2.31.0 +setuptools +requests diff --git a/setup.py b/setup.py index 2bc3deed6ea..e5e2f1b3ceb 100644 --- a/setup.py +++ b/setup.py @@ -5,26 +5,12 @@ import shutil from pathlib import Path +from packaging.version import Version from setuptools import find_packages from build.win.build import setup, setup_executables, setup_options -def read_version_from_file(file_path: str) -> str: - """ - Get the version from the file at the given file path. - """ - with open(file_path, encoding="utf-8") as file: - file_content = file.read() - # Use regular expression to find the version pattern - version_match = re.search(r"^version_id = ['\"]([^'\"]*)['\"]", file_content, re.M) - if version_match: - version_str = version_match.group(1) - return version_str.split("-")[0] - msg = "Unable to find version string." - raise RuntimeError(msg) - - def read_requirements(file_name: str, directory: str = ".") -> list[str]: """ Read the pip requirements from the given file name in the given directory. @@ -54,19 +40,14 @@ def read_requirements(file_name: str, directory: str = ".") -> list[str]: # See: entry_points={"gui_scripts": ["tribler=tribler.run:main"]} in setup() below. shutil.copy("src/run_tribler.py", "src/tribler/run.py") -# Read the version from the version file: src/tribler/core/version.py -# Note that, for version.py to include the correct version, it should be generated first using git commands. -# For example: -# git describe --tags | python -c "import sys; print(next(sys.stdin).lstrip("v"))" > .TriblerVersion -# git rev-parse HEAD > .TriblerCommit -# Then, the version.py file can be generated using the following command: -# python build/update_version.py -version_file = os.path.join("src", "tribler", "core", "version.py") -version = read_version_from_file(version_file) +# Turn the tag into a sequence of integer values and normalize into a period-separated string. +raw_version = os.getenv("GITHUB_TAG") +version_numbers = [str(value) for value in map(int, re.findall(r"\d+", raw_version))] +version = Version(".".join(version_numbers)) setup( name="tribler", - version=version, + version=str(version), description="Privacy enhanced BitTorrent client with P2P content discovery", long_description=Path("README.rst").read_text(encoding="utf-8"), long_description_content_type="text/x-rst", diff --git a/tribler.spec b/tribler.spec index f5fc58e4321..6d0d7a1ebd6 100644 --- a/tribler.spec +++ b/tribler.spec @@ -1,8 +1,10 @@ # -*- mode: python -*- +from packaging.version import Version + block_cipher = None import imp import os -import pkgutil +import re import shutil import sys @@ -20,9 +22,10 @@ sys.path.append(pyipv8_dir) # Import components that are not imported by the main script import tribler.core.components as known_components -from tribler.core.version import version_id - -version_str = version_id.split('-')[0] +# Turn the tag into a sequence of integer values and normalize into a period-separated string. +raw_version = os.getenv("GITHUB_TAG") +version_numbers = [str(value) for value in map(int, re.findall(r"\d+", raw_version))] +version_str = str(Version(".".join(version_numbers))) # On macOS, we always show the console to prevent the double-dock bug (although the OS does not actually show the console). # See https://github.com/Tribler/tribler/issues/3817