Skip to content

Commit

Permalink
Merge pull request #6755 from drew2a/refactoring/remove_common_package
Browse files Browse the repository at this point in the history
Remove common package
  • Loading branch information
drew2a authored Feb 4, 2022
2 parents e58b5b6 + 2c2c7ec commit 7a319b1
Show file tree
Hide file tree
Showing 157 changed files with 612 additions and 702 deletions.
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,tribler_common,run_tribler,experiment
application-import-names=tribler_core,tribler_gui,run_tribler,experiment
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,tribler_common,run_tribler
known_first_party=tribler_core,tribler_gui,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
6 changes: 2 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ repos:
files: |
(?x)(
^src/tribler-gui/|
^src/tribler-core/tribler_core/modules/metadata_store/|
^src/tribler-common
^src/tribler-core/tribler_core/modules/metadata_store/
)
types: [file, python]

Expand All @@ -45,8 +44,7 @@ repos:
files: |
(?x)(
^src/tribler-gui/|
^src/tribler-core/|
^src/tribler-common
^src/tribler-core/
)
types: [file, python]

3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ RUN mkdir /requirements
COPY ./src/pyipv8/requirements.txt /requirements/pyipv8-requirements.txt
RUN pip3 install -r /requirements/pyipv8-requirements.txt

COPY ./src/tribler-common/tribler_common/requirements.txt /requirements/common-requirements.txt
RUN pip3 install -r /requirements/common-requirements.txt

COPY ./src/tribler-core/tribler_core/requirements.txt /requirements/core-requirements.txt
RUN pip3 install -r /requirements/core-requirements.txt

Expand Down
2 changes: 1 addition & 1 deletion build/systemd/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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-common:./src/tribler-core
Environment=PYTHONPATH=./src/pyipv8:./src/anydex:./src/tribler-core

WorkingDirectory=/opt/tribler
ExecStartPre=/bin/mkdir -p ${HOME}
Expand Down
2 changes: 1 addition & 1 deletion build/systemd/bandwidth-crawler.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Type=simple
User=crawler
Group=crawler
Restart=always
Environment=PYTHONPATH=./src/pyipv8:./src/tribler-common:./src/tribler-core
Environment=PYTHONPATH=./src/pyipv8:./src/tribler-core
WorkingDirectory=/opt/tribler
ExecStart=/usr/bin/python3 src/tribler-core/run_bandwidth_crawler.py --statedir /var/lib/crawler $EXTRA_CRAWLER_ARGS

Expand Down
8 changes: 3 additions & 5 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,17 @@
tribler_components = [
os.path.join(root_dir, "src", "pyipv8"),
os.path.join(root_dir, "src", "anydex"),
os.path.join(root_dir, "src", "tribler-common"),
os.path.join(root_dir, "src", "tribler-core"),
os.path.join(root_dir, "src", "tribler-gui"),
os.path.join(root_dir, "doc"),
]
for component in tribler_components:
sys.path.append(str(component))

from tribler_common.dependencies import Scope, get_dependencies
from tribler_common.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)) | \
set(get_dependencies(scope=Scope.common)) | {'libtorrent', 'validate'}
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
Expand Down
6 changes: 3 additions & 3 deletions experiment/popularity_community/README.md
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-common,tribler-core} | tr " " :`
export PYTHONPATH=${PYTHONPATH}:`echo ../.. ../../src/{pyipv8,tribler-core} | tr " " :`
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-common,tribler-core} | tr " " :`
export PYTHONPATH=${PYTHONPATH}:`echo ../.. ../../src/{pyipv8,tribler-core} | tr " " :`
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-common,tribler-core} | tr " " :`
export PYTHONPATH=${PYTHONPATH}:`echo ../.. ../../src/{pyipv8,tribler-core} | tr " " :`
python3 analyze_crawled_data.py [-d <sqlite_db_path>] [-f <json_output_file_path>]
[-l <torrent_limit>] [-v]
Expand Down
2 changes: 1 addition & 1 deletion experiment/popularity_community/analyze_crawled_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
### Usage
```
export PYTHONPATH=${PYTHONPATH}:`echo ../.. ../../src/{pyipv8,tribler-common,tribler-core} | tr " " :`
export PYTHONPATH=${PYTHONPATH}:`echo ../.. ../../src/{pyipv8,tribler-core} | tr " " :`
python3 analyze_crawled_data.py [-d <sqlite_db_path>] [-f <json_output_file_path>]
[-l <torrent_limit>] [-v]
Expand Down
2 changes: 1 addition & 1 deletion experiment/popularity_community/crawl_torrents.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""This script crawl first 100 torrens from random nodes in the network.
```
export PYTHONPATH=${PYTHONPATH}:`echo ../.. ../../src/{pyipv8,tribler-common,tribler-core} | tr " " :`
export PYTHONPATH=${PYTHONPATH}:`echo ../.. ../../src/{pyipv8,tribler-core} | tr " " :`
python3 crawl_torrents.py [-t <timeout_in_sec>] [-f <db_file.sqlite>] [-v]
[--peers_count_csv=<csv_file_with_peers_count>]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.black]
line-length = 120
skip-string-normalization = true
include = '(src/tribler-gui|src/tribler-common|src/tribler-core/tribler_core/modules/metadata_store)/.*\.pyi?$'
include = '(src/tribler-core/tribler_core/modules/metadata_store)/.*\.pyi?$'

exclude = '''
/(
Expand Down
4 changes: 1 addition & 3 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@ from` requirements.txt`.

Export to PYTHONPATH the following directories:

* tribler-common
* tribler-core
* tribler-gui

Shortcut for macOS:
```shell script
export PYTHONPATH=${PYTHONPATH}:`echo {pyipv8,tribler-common,tribler-core,tribler-gui} | tr " " :`
export PYTHONPATH=${PYTHONPATH}:`echo {pyipv8,tribler-core,tribler-gui} | tr " " :`
```
Execute:
```
python3 -m pytest tribler-core
python3 -m pytest tribler-common
python3 -m pytest tribler-gui --guitests
```
2 changes: 0 additions & 2 deletions src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
-r tribler-core/tribler_core/requirements.txt
-r tribler-gui/tribler_gui/requirements.txt
-r tribler-common/tribler_common/requirements.txt
2 changes: 1 addition & 1 deletion src/run_tests.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
set PYTHONPATH=%~dp0tribler-core;%~dp0tribler-common
set PYTHONPATH=%~dp0tribler-core
pytest %~dp0tribler-core %*
2 changes: 1 addition & 1 deletion src/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ script_path() {
}

SRC_DIR="$(dirname "$(script_path "$0")")/src"
export PYTHONPATH=$SRC_DIR/tribler-core:$SRC_DIR/tribler-common
export PYTHONPATH=$SRC_DIR/tribler-core
pytest $SRC_DIR/tribler-core "$@"
2 changes: 1 addition & 1 deletion src/run_tribler.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
set PYTHONPATH=%~dp0tribler-core;%~dp0tribler-common;%~dp0tribler-gui;%~dp0pyipv8;%~dp0anydex
set PYTHONPATH=%~dp0tribler-core;%~dp0tribler-gui;%~dp0pyipv8;%~dp0anydex
python run_tribler.py
7 changes: 3 additions & 4 deletions src/run_tribler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
import os
import sys

from tribler_common.sentry_reporter.sentry_reporter import SentryStrategy
from tribler_common.sentry_reporter.sentry_scrubber import SentryScrubber

from tribler_core.components.reporter.exception_handler import default_core_exception_handler
from tribler_core.sentry_reporter.sentry_reporter import SentryStrategy
from tribler_core.sentry_reporter.sentry_scrubber import SentryScrubber

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -67,7 +66,7 @@ def init_boot_logger():
logger.info(f'Run Tribler: {parsed_args}')

# Get root state directory (e.g. from environment variable or from system default)
from tribler_common.osutils import get_root_state_directory
from tribler_core.utilities.osutils import get_root_state_directory

root_state_dir = get_root_state_directory()
logger.info(f'Root state dir: {root_state_dir}')
Expand Down
2 changes: 1 addition & 1 deletion src/seedbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The seedbox consists of two parts:
```
1. Add necessary folders to `PYTHONPATH` (below the bash example)
```shell
export PYTHONPATH=${PYTHONPATH}:`echo ../.. ../{pyipv8,tribler-common,tribler-core} | tr " " :`
export PYTHONPATH=${PYTHONPATH}:`echo ../.. ../{pyipv8,tribler-core} | tr " " :`
```

## Torrent seeding
Expand Down
3 changes: 0 additions & 3 deletions src/tribler-common/tribler_common/__init__.py

This file was deleted.

2 changes: 0 additions & 2 deletions src/tribler-common/tribler_common/requirements.txt

This file was deleted.

114 changes: 0 additions & 114 deletions src/tribler-common/tribler_common/tests/test_utils.py

This file was deleted.

Loading

0 comments on commit 7a319b1

Please sign in to comment.