Skip to content

Commit

Permalink
Remove common package
Browse files Browse the repository at this point in the history
  • Loading branch information
drew2a committed Feb 3, 2022
1 parent bf5b2c7 commit c1742a1
Show file tree
Hide file tree
Showing 24 changed files with 23 additions and 42 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
4 changes: 1 addition & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
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"),
Expand All @@ -36,8 +35,7 @@
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: 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
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
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ def get_confirmation(self, exception):
Args:
exception: exception to be sent.
"""
# Prevent importing PyQt globally in tribler-common module.
# pylint: disable=import-outside-toplevel
try:
from PyQt5.QtWidgets import QApplication, QMessageBox
Expand Down
2 changes: 1 addition & 1 deletion src/tribler-core/tribler_core/tests/test_start_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# fmt: off


@patch('tribler_common.logger.load_logger_config', new=MagicMock())
@patch('tribler_core.logger.logger.load_logger_config', new=MagicMock())
@patch('tribler_core.start_core.set_process_priority', new=MagicMock())
@patch('tribler_core.start_core.check_and_enable_code_tracing', new=MagicMock())
@patch('asyncio.get_event_loop', new=MagicMock())
Expand Down
2 changes: 0 additions & 2 deletions src/tribler-core/tribler_core/tests/tools/common.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import binascii

import tribler_common

from tribler_core.utilities.path_util import Path

UBUNTU_1504_INFOHASH = binascii.unhexlify('FC8A15A2FAF2734DBB1DC5F7AFDC5C9BEAEB1F59')
Expand Down
5 changes: 1 addition & 4 deletions src/tribler-core/tribler_core/utilities/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

logger = logging.getLogger(__name__)

Scope = Enum('Scope', 'core gui common')
Scope = Enum('Scope', 'core gui')

# Exceptional pip packages where the name does not match with actual import.
package_to_import_mapping = {
Expand All @@ -33,9 +33,6 @@ def _get_path_to_requirements_txt() -> Optional[Path]:
if scope == Scope.gui:
import tribler_gui
return Path(tribler_gui.__file__).parent / requirements_txt
if scope == Scope.common:
import tribler_common
return Path(tribler_common.__file__).parent / requirements_txt
raise AttributeError(f'Scope is {scope} but should be in {[s for s in Scope]}') # pylint: disable=unnecessary-comprehension

return _get_pip_dependencies(_get_path_to_requirements_txt())
Expand Down
5 changes: 2 additions & 3 deletions src/tribler-gui/tribler_gui/tests/test_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import pytest

import tribler_common
from tribler_core.components.reporter.reported_error import ReportedError
from tribler_core.tests.tools.common import TESTS_DATA_DIR
from tribler_core.utilities.rest_utils import path_to_uri
from tribler_core.sentry_reporter.sentry_reporter import SentryReporter
from tribler_core.components.tag.tag_constants import MIN_TAG_LENGTH
Expand All @@ -31,8 +31,7 @@
from tribler_gui.widgets.torrentfiletreewidget import CHECKBOX_COL

RUN_TRIBLER_PY = Path(tribler_gui.__file__).parent.parent.parent / "run_tribler.py"
COMMON_DATA_DIR = Path(tribler_common.__file__).parent / "data"
TORRENT_WITH_DIRS = COMMON_DATA_DIR / "multi_entries.torrent"
TORRENT_WITH_DIRS = TESTS_DATA_DIR / "multi_entries.torrent"


@pytest.fixture(scope="module")
Expand Down
1 change: 0 additions & 1 deletion src/tribler-gui/tribler_gui/tribler_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ def __init__(

self.tribler_started = False
self.tribler_settings = None
# TODO: move version_id to tribler_common and get core version in the core crash message
self.tribler_version = version_id
self.debug_window = None

Expand Down
2 changes: 1 addition & 1 deletion src/tribler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ UNAME="$(uname -s)"

# Add all required modules to PYTHONPATH
SRC_DIR="$(dirname "$(script_path "$0")")/src"
PYTHONPATH="$PYTHONPATH:"$SRC_DIR/pyipv8":"$SRC_DIR/anydex":"$SRC_DIR/tribler-common":"$SRC_DIR/tribler-core":"$SRC_DIR/tribler-gui""
PYTHONPATH="$PYTHONPATH:"$SRC_DIR/pyipv8":"$SRC_DIR/anydex":"$SRC_DIR/tribler-core":"$SRC_DIR/tribler-gui""
export PYTHONPATH

TRIBLER_SCRIPT=$SRC_DIR/run_tribler.py
Expand Down
2 changes: 0 additions & 2 deletions tribler.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ src_dir = os.path.join(root_dir, "src")

tribler_components = [
os.path.join(src_dir, "pyipv8"),
os.path.join(src_dir, "tribler-common"),
os.path.join(src_dir, "tribler-core"),
os.path.join(src_dir, "tribler-gui"),
]
Expand All @@ -42,7 +41,6 @@ data_to_copy = [
(os.path.join(src_dir, "tribler-gui", "tribler_gui", "qt_resources"), 'qt_resources'),
(os.path.join(src_dir, "tribler-gui", "tribler_gui", "images"), 'images'),
(os.path.join(src_dir, "tribler-gui", "tribler_gui", "i18n"), 'i18n'),
(os.path.join(src_dir, "tribler-common", "tribler_common"), 'tribler_source/tribler_common'),
(os.path.join(src_dir, "tribler-core", "tribler_core"), 'tribler_source/tribler_core'),
(os.path.join(src_dir, "tribler-gui", "tribler_gui"), 'tribler_source/tribler_gui'),
(os.path.join(root_dir, "build", "win", "resources"), 'tribler_source/resources'),
Expand Down

0 comments on commit c1742a1

Please sign in to comment.