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

Refactoring the folders structure #6803

Merged
merged 14 commits into from
Mar 14, 2022
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ venv**
.github
.pytest**
doc
experiment
scripts
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
max-line-length = 120
select=E901,E999,F821,F822,F823,I100,I101,I201,I202,T001,T002,T003,T004
ignore=E203,W503,C0330
application-import-names=tribler_core,tribler_gui,run_tribler,experiment
application-import-names=tribler,run_tribler
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ dist/
annotations.txt

# Screenshots taken by GUI tests
tribler_gui/screenshots
tribler/gui/screenshots

#venv
venv/
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ combine_as_imports=True
force_sort_within_sections=True
line_length=120
known_future_library=future
known_first_party=tribler_core,tribler_gui,run_tribler
known_first_party=tribler,run_tribler
known_third_party=pony,twisted,six,anydex,ipv8,libtorrent,lz4,PyQt5,zope,aiohttp,psutil,configobj,ipv8_service,asynctest,numpy,networkx,async_timeout,cherrypy,nose,validate,check_os,matplotlib,pyqtgraph,_socket,aiohttp_apispec,marshmallow,PIL,anyio,freezegun,yaml
7 changes: 3 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ repos:
- id: black
files: |
(?x)(
^src/tribler-gui/|
^src/tribler-core/tribler_core/modules/metadata_store/
^src/tribler/gui/
)
types: [file, python]

Expand All @@ -43,8 +42,8 @@ repos:
language: system
files: |
(?x)(
^src/tribler-gui/|
^src/tribler-core/
^src/tribler/gui/|
^src/tribler/core/
)
types: [file, python]

4 changes: 2 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
init-hook='import sys; import os; sys.path.append(os.path.join("src", "pyipv8")); sys.path.append(os.path.join("src", "anydex"))'
init-hook='import sys; import os;'

# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=.git,libnacl,data,.pylint.rc,pyproject.toml
ignore=.git,libnacl,data,.pylint.rc

# Pickle collected data for later comparisons.
persistent=yes
Expand Down
2 changes: 1 addition & 1 deletion .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Path to sources
sonar.sources=.
sonar.exclusions=build/**,doc/**,src/anydex/**,src/pyipv8/**
sonar.exclusions=build/**,doc/**

# Source encoding
sonar.sourceEncoding=UTF-8
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ WORKDIR /home/user
# need to be built every time the source code changes.
# This reduces the docker build time.
RUN mkdir requirements
COPY ./src/tribler-core/tribler_core/requirements.txt requirements/core-requirements.txt
COPY ./requirements-core.txt requirements/core-requirements.txt
RUN pip3 install -r requirements/core-requirements.txt

# Copy the source code and set the working directory
Expand Down
2 changes: 1 addition & 1 deletion build/debian/makedist_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ rm -rf build/debian/tribler/usr/share/tribler
python3 build/update_version_from_git.py

# ----- Install pip dependencies before the build
python3 -m pip install --upgrade -r src/requirements.txt
python3 -m pip install --upgrade -r requirements.txt

python3 -m PyInstaller tribler.spec

Expand Down
2 changes: 1 addition & 1 deletion build/mac/makedist_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export RESOURCES=build/mac/resources

# ----- Build
# ----- Install pip dependencies before the build
python3 -m pip install --upgrade -r src/requirements.txt
python3 -m pip install --upgrade -r requirements.txt

PI=pyinstaller
$PI tribler.spec
Expand Down
4 changes: 2 additions & 2 deletions build/systemd/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Environment=HOME=/var/lib/tunnel_helper/%I
Environment=HELPER_INDEX=%I
Environment=HELPER_BASE=35000
Environment=EXTRA_TUNNEL_ARGS=--
Environment=PYTHONPATH=./src/pyipv8:./src/anydex:./src/tribler-core
Environment=PYTHONPATH=./src

WorkingDirectory=/opt/tribler
ExecStartPre=/bin/mkdir -p ${HOME}
ExecStart=/usr/bin/python3 src/tribler-core/run_tunnel_helper.py $EXTRA_TUNNEL_ARGS
ExecStart=/usr/bin/python3 scripts/exit_node/run_exit_node.py.py $EXTRA_TUNNEL_ARGS

[Install]
WantedBy=multi-user.target
4 changes: 2 additions & 2 deletions build/systemd/bandwidth-crawler.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Type=simple
User=crawler
Group=crawler
Restart=always
Environment=PYTHONPATH=./src/pyipv8:./src/tribler-core
Environment=PYTHONPATH=./src
WorkingDirectory=/opt/tribler
ExecStart=/usr/bin/python3 src/tribler-core/run_bandwidth_crawler.py --statedir /var/lib/crawler $EXTRA_CRAWLER_ARGS
ExecStart=/usr/bin/python3 scripts/bandwidth_crawler/run_bandwidth_crawler.py --statedir /var/lib/crawler $EXTRA_CRAWLER_ARGS

[Install]
WantedBy=multi-user.target
2 changes: 1 addition & 1 deletion build/update_version_from_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def run_command(cmd):
logger.info("Build date: %s", build_date)

logger.info('Writing runtime version info.')
with open(path.join('src', 'tribler-core', 'tribler_core', 'version.py'), 'w') as f:
with open(path.join('src', 'tribler', 'core', 'version.py'), 'w') as f:
f.write(
f'version_id = "{version_id}"{linesep}'
f'build_date = "{build_date}"{linesep}'
Expand Down
2 changes: 1 addition & 1 deletion build/win/makedist_win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ call build\win\clean.bat
REM ----- Build

REM ----- Install pip dependencies before the build
python3 -m pip install --upgrade -r src\requirements.txt
python3 -m pip install --upgrade -r requirements.txt

REM Arno: When adding files here, make sure tribler.nsi actually
REM packs them in the installer .EXE
Expand Down
11 changes: 4 additions & 7 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,19 @@
# pylint: disable=wrong-import-position
root_dir = os.path.abspath(os.path.join(os.path.dirname(__name__), '..'))
tribler_components = [
os.path.join(root_dir, "src", "pyipv8"),
os.path.join(root_dir, "src", "anydex"),
os.path.join(root_dir, "src", "tribler-core"),
os.path.join(root_dir, "src", "tribler-gui"),
os.path.join(root_dir, "src"),
os.path.join(root_dir, "doc"),
]
for component in tribler_components:
sys.path.append(str(component))

from tribler_core.utilities.dependencies import Scope, get_dependencies
from tribler_core.utilities.patch_import import patch_import
from tribler.core.utilities.dependencies import Scope, get_dependencies
from tribler.core.utilities.patch_import import patch_import

modules_to_mock = set(get_dependencies(scope=Scope.core)) | {'libtorrent', 'validate'}

with patch_import(modules=modules_to_mock):
from tribler_core.components.restapi.rest.root_endpoint import RootEndpoint
from tribler.core.components.restapi.rest.root_endpoint import RootEndpoint
add_endpoint = RootEndpoint.add_endpoint
RootEndpoint.add_endpoint = lambda self, path, ep: add_endpoint(self, path, ep) \
if path not in ['/ipv8', '/market', '/wallets'] else None
Expand Down
17 changes: 2 additions & 15 deletions doc/development/development_on_linux.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,9 @@ Install python packages:

.. code-block:: bash

pip3 install --upgrade -r tribler/src/requirements.txt
pip3 install --upgrade -r tribler/requirements.txt


Install py-ipv8 python dependencies:

.. code-block:: bash

pip3 install --upgrade -r tribler/src/pyipv8/requirements.txt

Run Tribler by executing the following commands:

.. code-block:: bash
Expand Down Expand Up @@ -58,14 +52,7 @@ Install python packages:

.. code-block:: bash

pip3 install --upgrade -r tribler/src/requirements.txt


Install py-ipv8 python dependencies

.. code-block:: bash

pip3 install --upgrade -r tribler/src/pyipv8/requirements.txt
pip3 install --upgrade -r tribler/requirements.txt

Run Tribler by executing the following commands:

Expand Down
2 changes: 1 addition & 1 deletion doc/development/development_on_osx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ There are a bunch of other packages that can easily be installed using pip and b
.. code-block:: bash

brew install gmp mpfr libmpc libsodium
cd src && python3 -m pip install -r requirements.txt
python3 -m pip install -r requirements.txt

Tribler
-------
Expand Down
6 changes: 1 addition & 5 deletions doc/development/development_on_windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ Additional Packages
There are some additional packages which should be installed. They can easily be installed using pip:

.. code-block:: bash
cd src
pip install --upgrade -r requirements.txt

cd src/pyipv8
pip install --upgrade -r requirements.txt

Running Tribler
Expand All @@ -72,7 +68,7 @@ Running Tribler
You should now be able to run Tribler from command line. Grab a copy of the Tribler source code and navigate in a command line interface to the source code directory. Start Tribler by executing the Batch script in the ``tribler/src`` directory:

.. code-block:: bash

cd src
tribler.bat

If there are any problems with the guide above, please feel free to fix any errors or `create an issue <https://github.com/Tribler/tribler/issues/new>`_ so we can look into it.
6 changes: 3 additions & 3 deletions doc/extract_swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import yaml

from tribler_core.components.restapi.rest.rest_manager import ApiKeyMiddleware, RESTManager, error_middleware
from tribler_core.components.restapi.rest.root_endpoint import RootEndpoint
from tribler_core.config.tribler_config import TriblerConfig
from tribler.core.components.restapi.rest.rest_manager import ApiKeyMiddleware, RESTManager, error_middleware
from tribler.core.components.restapi.rest.root_endpoint import RootEndpoint
from tribler.core.config.tribler_config import TriblerConfig


async def extract_swagger(destination_fn):
Expand Down
14 changes: 0 additions & 14 deletions pyproject.toml

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-r ../../tribler-core/tribler_core/requirements.txt
-r requirements-core.txt

Pillow==9.0.1
PyQt5==5.15.1
Expand Down
12 changes: 12 additions & 0 deletions scripts/bandwidth_crawler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Bandwidth Crawler

## Requirements

* Export the `src` directory to `PYTHONPATH`
* Install Tribler's requirements from `requirements.txt`

## Execution

```shell
python3 run_bandwidth_crawler.py
```
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
from asyncio import ensure_future, get_event_loop
from pathlib import Path

from tribler_core.components.bandwidth_accounting.bandwidth_accounting_component import BandwidthAccountingComponent
from tribler_core.components.ipv8.ipv8_component import Ipv8Component
from tribler_core.components.key.key_component import KeyComponent
from tribler_core.config.tribler_config import TriblerConfig
from tribler_core.start_core import Session
from tribler.core.components.bandwidth_accounting.bandwidth_accounting_component import BandwidthAccountingComponent
from tribler.core.components.ipv8.ipv8_component import Ipv8Component
from tribler.core.components.key.key_component import KeyComponent
from tribler.core.config.tribler_config import TriblerConfig
from tribler.core.start_core import Session


class PortAction(argparse.Action):
Expand Down
12 changes: 12 additions & 0 deletions scripts/exit_node/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Exit Node

## Requirements

* Export the `src` directory to `PYTHONPATH`
* Install Tribler's requirements from `requirements.txt`

## Execution

```shell
python3 run_exit_node.py
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
from ipv8.messaging.anonymization.tunnel import Circuit
from ipv8.taskmanager import TaskManager

from tribler_core import notifications
from tribler_core.components.bandwidth_accounting.bandwidth_accounting_component import BandwidthAccountingComponent
from tribler_core.components.base import Session
from tribler_core.components.ipv8.ipv8_component import Ipv8Component
from tribler_core.components.key.key_component import KeyComponent
from tribler_core.components.resource_monitor.resource_monitor_component import ResourceMonitorComponent
from tribler_core.components.restapi.restapi_component import RESTComponent
from tribler_core.components.socks_servers.socks_servers_component import SocksServersComponent
from tribler_core.components.tunnel.tunnel_component import TunnelsComponent
from tribler_core.config.tribler_config import TriblerConfig
from tribler_core.utilities.osutils import get_root_state_directory
from tribler_core.utilities.path_util import Path
from tribler.core import notifications
from tribler.core.components.bandwidth_accounting.bandwidth_accounting_component import BandwidthAccountingComponent
from tribler.core.components.base import Session
from tribler.core.components.ipv8.ipv8_component import Ipv8Component
from tribler.core.components.key.key_component import KeyComponent
from tribler.core.components.resource_monitor.resource_monitor_component import ResourceMonitorComponent
from tribler.core.components.restapi.restapi_component import RESTComponent
from tribler.core.components.socks_servers.socks_servers_component import SocksServersComponent
from tribler.core.components.tunnel.tunnel_component import TunnelsComponent
from tribler.core.config.tribler_config import TriblerConfig
from tribler.core.utilities.osutils import get_root_state_directory
from tribler.core.utilities.path_util import Path

logger = logging.getLogger(__name__)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ time_in_sec,total,alive
### Usage

```
export PYTHONPATH=${PYTHONPATH}:`echo ../.. ../../src/{pyipv8,tribler-core} | tr " " :`
export PYTHONPATH=${PYTHONPATH}:../../../src

python3 initial_filling.py [-i <check_interval_in_sec>] [-t <timeout_in_sec>] [-f <output_file.csv>]
```
Expand Down Expand Up @@ -79,7 +79,7 @@ Where:
### Usage

```
export PYTHONPATH=${PYTHONPATH}:`echo ../.. ../../src/{pyipv8,tribler-core} | tr " " :`
export PYTHONPATH=${PYTHONPATH}:../../../src

python3 crawl_torrents.py [-t <timeout_in_sec>] [-f <db_file.sqlite>] [-v]
[--peers_count_csv=<csv_file_with_peers_count>]
Expand Down Expand Up @@ -160,7 +160,7 @@ Where:
### Usage

```
export PYTHONPATH=${PYTHONPATH}:`echo ../.. ../../src/{pyipv8,tribler-core} | tr " " :`
export PYTHONPATH=${PYTHONPATH}:../../../src

python3 analyze_crawled_data.py [-d <sqlite_db_path>] [-f <json_output_file_path>]
[-l <torrent_limit>] [-v]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
### Usage

```
export PYTHONPATH=${PYTHONPATH}:`echo ../.. ../../src/{pyipv8,tribler-core} | tr " " :`
export PYTHONPATH=${PYTHONPATH}:../../../src

python3 analyze_crawled_data.py [-d <sqlite_db_path>] [-f <json_output_file_path>]
[-l <torrent_limit>] [-v]
Expand Down
Loading