-
Notifications
You must be signed in to change notification settings - Fork 451
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7959 from xoriole/fix/release-build-7.14
Fix Release build on 7.14 branch
- Loading branch information
Showing
14 changed files
with
236 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
include src/run_tribler.py | ||
include src/tribler/core/components/libtorrent/download_manager/download_config.spec | ||
include src/tribler/core/components/database/category_filter/category.conf | ||
include src/tribler/core/components/database/category_filter/filter_terms.filter | ||
include src/tribler/core/components/database/category_filter/level2.regex | ||
recursive-include src/tribler/gui/qt_resources * | ||
recursive-include src/tribler/gui/i18n * | ||
recursive-include src/tribler/gui/images * | ||
include requirements*.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
""" | ||
This file includes the build configuration for the Tribler. | ||
The exports of this file are used in setup.py to build the executable or wheel package. | ||
There are two build options: | ||
1) setuptools is used to build the wheel package. | ||
To create a wheel package: | ||
python setup.py bdist_wheel | ||
2) Building executable is done using cx_Freeze. | ||
To build an executable: | ||
python setup.py build | ||
To create a distributable package: | ||
python setup.py bdist | ||
To create a distributable package for a specific platform: | ||
python setup.py bdist_mac | ||
python setup.py bdist_win | ||
Building wheel and building executable had to be separated because cx_Freeze does not | ||
support building wheels. Therefore, the build options are separated into two functions | ||
and the appropriate function is called based on the command line arguments. | ||
""" | ||
import sys | ||
|
||
|
||
def get_wheel_build_options(): | ||
from setuptools import setup as _setup # pylint: disable=import-outside-toplevel | ||
_setup_options = {"build_exe": {}} | ||
_setup_executables = None | ||
return _setup, _setup_options, _setup_executables | ||
|
||
|
||
def get_freeze_build_options(): | ||
from cx_Freeze import setup as _setup, Executable # pylint: disable=import-outside-toplevel | ||
|
||
# These packages will be included in the build | ||
sys.path.insert(0, 'src') | ||
included_packages = [ | ||
"aiohttp_apispec", | ||
"sentry_sdk", | ||
"ipv8", | ||
"PIL", | ||
"pkg_resources", | ||
"pydantic", | ||
"pyqtgraph", | ||
"PyQt5.QtTest", | ||
"requests", | ||
"tribler.core", | ||
"tribler.gui", | ||
"faker", | ||
"libtorrent", | ||
"ssl", | ||
] | ||
|
||
# These files will be included in the build | ||
included_files = [ | ||
("src/tribler/gui/qt_resources", "qt_resources"), | ||
("src/tribler/gui/images", "images"), | ||
("src/tribler/gui/i18n", "i18n"), | ||
("src/tribler/core", "tribler_source/tribler/core"), | ||
("src/tribler/gui", "tribler_source/tribler/gui"), | ||
("build/win/resources", "tribler_source/resources"), | ||
] | ||
|
||
# These packages will be excluded from the build | ||
excluded_packages = [ | ||
'wx', | ||
'PyQt4', | ||
'FixTk', | ||
'tcl', | ||
'tk', | ||
'_tkinter', | ||
'tkinter', | ||
'Tkinter', | ||
'matplotlib' | ||
] | ||
|
||
_setup_options = { | ||
"build_exe": { | ||
"packages": included_packages, | ||
"excludes": excluded_packages, | ||
"include_files": included_files, | ||
"include_msvcr": True, | ||
'build_exe': 'dist/tribler' | ||
} | ||
} | ||
|
||
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" | ||
_setup_executables = [ | ||
Executable( | ||
target_name=app_name, | ||
script=app_script, | ||
base="Win32GUI" if sys.platform == "win32" else None, | ||
icon=app_icon_path, | ||
) | ||
] | ||
return _setup, _setup_options, _setup_executables | ||
|
||
|
||
# Based on the command line arguments, get the build options. | ||
# If the command line arguments include 'setup.py' and 'bdist_wheel', | ||
# then the options are for building a wheel package. | ||
# Otherwise, the options are for building an executable (any other). | ||
if {'setup.py', 'bdist_wheel'}.issubset(sys.argv): | ||
setup, setup_options, setup_executables = get_wheel_build_options() | ||
else: | ||
setup, setup_options, setup_executables = get_freeze_build_options() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["setuptools>=61.0"] | ||
build-backend = "setuptools.build_meta" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import os | ||
import re | ||
import shutil | ||
from pathlib import Path | ||
|
||
from setuptools import find_packages | ||
|
||
from build import setup, setup_options, setup_executables | ||
|
||
|
||
def read_version_from_file(file_path): | ||
with open(file_path, "r", 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] | ||
raise RuntimeError("Unable to find version string.") | ||
|
||
|
||
def read_requirements(file_name, directory='.'): | ||
file_path = os.path.join(directory, file_name) | ||
requirements = [] | ||
with open(file_path, 'r', encoding='utf-8') as file: | ||
for line in file: | ||
# Check for a nested requirements file | ||
if line.startswith('-r'): | ||
nested_file = line.split(' ')[1].strip() | ||
requirements += read_requirements(nested_file, directory) | ||
elif not line.startswith('#') and line.strip() != '': | ||
requirements.append(line.strip().split('#')[0].strip()) | ||
return requirements | ||
|
||
|
||
base_dir = os.path.dirname(os.path.abspath(__file__)) | ||
install_requires = read_requirements('requirements-build.txt', base_dir) | ||
extras_require = { | ||
'dev': read_requirements('requirements-test.txt', base_dir), | ||
} | ||
|
||
# Copy src/run_tribler.py --> src/tribler/run.py to make it accessible in entry_points scripts. | ||
# 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) | ||
|
||
setup( | ||
name="tribler", | ||
version=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", | ||
author="Tribler Team", | ||
author_email="info@tribler.org", | ||
url="https://github.com/Tribler/tribler", | ||
keywords='BitTorrent client, file sharing, peer-to-peer, P2P, TOR-like network', | ||
python_requires='>=3.8', | ||
packages=find_packages(where="src"), | ||
package_dir={"": "src"}, | ||
include_package_data=True, | ||
install_requires=install_requires, | ||
extras_require=extras_require, | ||
entry_points={ | ||
"gui_scripts": [ | ||
"tribler=tribler.run:main", | ||
] | ||
}, | ||
classifiers=[ | ||
"Development Status :: 5 - Production/Stable", | ||
"Intended Audience :: Developers", | ||
"Intended Audience :: End Users/Desktop", | ||
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Topic :: Communications :: File Sharing", | ||
"Topic :: Security :: Cryptography", | ||
"Operating System :: OS Independent", | ||
], | ||
options=setup_options, | ||
executables=setup_executables | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.