Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create setup.py and fix building wheel #7935

Merged
merged 6 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions MANIFEST.in
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
3 changes: 3 additions & 0 deletions pyproject.toml
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"
79 changes: 79 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import os
import re
import shutil
from pathlib import Path

from setuptools import setup, find_packages

# Copy src/run_tribler.py --> src/tribler/run.py to make it accessible in entry_points scripts.
shutil.copy("src/run_tribler.py", "src/tribler/run.py")


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.")


version_file = os.path.join('src', 'tribler', 'core', 'version.py')
version = read_version_from_file(version_file)


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),
}


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="[email protected]",
url="https://www.tribler.org",
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",
"License :: OSI Approved :: GPL-3.0 license",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Internet :: File Sharing",
"Topic :: Security :: Cryptography",
"Operating System :: OS Independent",
],
)
6 changes: 5 additions & 1 deletion src/run_tribler.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def init_boot_logger():
logging.basicConfig(level=logging.INFO, stream=sys.stdout)


if __name__ == "__main__":
def main():
init_boot_logger()

parsed_args = RunTriblerArgsParser().parse_args()
Expand Down Expand Up @@ -112,3 +112,7 @@ def init_boot_logger():

init_sentry_reporter(gui_sentry_reporter)
run_gui(api_port, api_key, root_state_dir, parsed_args)


if __name__ == "__main__":
main()
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Loading