From 4200cc234529de66ed625dc49b4966eb783a7efa Mon Sep 17 00:00:00 2001 From: Jan Segre Date: Fri, 25 Oct 2024 15:51:40 +0200 Subject: [PATCH] chore: remove the limited support there was for Windows --- .github/workflows/main.yml | 2 +- hathor/cli/main.py | 5 ++--- hathor/cli/run_node.py | 13 +++++++------ hathor/cli/top.py | 4 ++-- hathor/reactor/reactor.py | 5 ----- poetry.lock | 4 ++-- pyproject.toml | 3 +-- tests/conftest.py | 5 ----- tests/p2p/test_connections.py | 5 ----- tests/resources/test_profiler.py | 3 --- tests/tx/test_prometheus.py | 4 ---- 11 files changed, 15 insertions(+), 38 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 54293da10..fd0c39948 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,7 +25,7 @@ jobs: full_matrix = { 'python': ['3.10', '3.11', '3.12'], # available OS's: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on - 'os': ['ubuntu-22.04', 'macos-12', 'windows-2022'], + 'os': ['ubuntu-22.04', 'macos-12'], } # this is the fastest one: reduced_matrix = { diff --git a/hathor/cli/main.py b/hathor/cli/main.py index 6a597745b..41e77ad05 100644 --- a/hathor/cli/main.py +++ b/hathor/cli/main.py @@ -58,6 +58,7 @@ def __init__(self) -> None: shell, side_dag, stratum_mining, + top, twin_tx, tx_generator, wallet, @@ -70,9 +71,7 @@ def __init__(self) -> None: self.add_cmd('mining', 'run_stratum_miner', stratum_mining, 'Run a mining process (running node required)') self.add_cmd('hathor', 'run_node', run_node, 'Run a node') self.add_cmd('hathor', 'gen_peer_id', peer_id, 'Generate a new random peer-id') - if sys.platform != 'win32': - from . import top - self.add_cmd('hathor', 'top', top, 'CPU profiler viewer') + self.add_cmd('hathor', 'top', top, 'CPU profiler viewer') self.add_cmd('side-dag', 'run_node_with_side_dag', side_dag, 'Run a side-dag') self.add_cmd('side-dag', 'gen_poa_keys', generate_poa_keys, 'Generate a private/public key pair and its ' 'address to be used in Proof-of-Authority') diff --git a/hathor/cli/run_node.py b/hathor/cli/run_node.py index 9dbc3005c..9498194ab 100644 --- a/hathor/cli/run_node.py +++ b/hathor/cli/run_node.py @@ -165,7 +165,10 @@ def create_parser(cls) -> ArgumentParser: return parser def prepare(self, *, register_resources: bool = True) -> None: + import resource + from setproctitle import setproctitle + setproctitle('{}hathor-core'.format(self._args.procname_prefix)) if self._args.recursion_limit: @@ -173,12 +176,10 @@ def prepare(self, *, register_resources: bool = True) -> None: else: sys.setrecursionlimit(5000) - if sys.platform != 'win32': - import resource - (nofile_soft, _) = resource.getrlimit(resource.RLIMIT_NOFILE) - if nofile_soft < 256: - print('Maximum number of open file descriptors is too low. Minimum required is 256.') - sys.exit(-2) + (nofile_soft, _) = resource.getrlimit(resource.RLIMIT_NOFILE) + if nofile_soft < 256: + print('Maximum number of open file descriptors is too low. Minimum required is 256.') + sys.exit(-2) self.check_unsafe_arguments() self.check_python_version() diff --git a/hathor/cli/top.py b/hathor/cli/top.py index 4adfac8f3..bae913709 100644 --- a/hathor/cli/top.py +++ b/hathor/cli/top.py @@ -24,8 +24,8 @@ from math import floor from typing import Any, Callable, Optional -# XXX: as annoying as it is, a simple `if: raise` is not enough, but putting the whole module inside works -if sys.platform != 'win32': +# XXX: support for Windows removed, this should be un-indented +if True: import curses import curses.ascii diff --git a/hathor/reactor/reactor.py b/hathor/reactor/reactor.py index b1ff7e4d7..b92c80062 100644 --- a/hathor/reactor/reactor.py +++ b/hathor/reactor/reactor.py @@ -55,15 +55,10 @@ def initialize_global_reactor(*, use_asyncio_reactor: bool = False) -> ReactorPr if use_asyncio_reactor: import asyncio - import sys from twisted.internet import asyncioreactor from twisted.internet.error import ReactorAlreadyInstalledError - if sys.platform == 'win32': - # See: https://docs.twistedmatrix.com/en/twisted-22.10.0/api/twisted.internet.asyncioreactor.AsyncioSelectorReactor.html # noqa: E501 - asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) - try: asyncioreactor.install(asyncio.get_event_loop()) except ReactorAlreadyInstalledError as e: diff --git a/poetry.lock b/poetry.lock index 5782686ae..2ae3ad105 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand. [[package]] name = "aiohappyeyeballs" @@ -2486,4 +2486,4 @@ sentry = ["sentry-sdk", "structlog-sentry"] [metadata] lock-version = "2.0" python-versions = ">=3.10,<4" -content-hash = "cbdab9a3fa79583a3fb818013dc26a7c4dbcc78a5d832f59239334128718c37a" +content-hash = "05a728b943ae8b639bbb369f400bb7ed5b6c0c5205abaf355194c7168b4798c7" diff --git a/pyproject.toml b/pyproject.toml index 70fa83eed..67415b6b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,13 +64,12 @@ mnemonic = "~0.20" prometheus_client = "~0.15.0" pyopenssl = "=24.2.1" pycoin = "~0.92.20230326" -pywin32 = {version = "306", markers = "sys_platform == 'win32'"} requests = "=2.32.3" service_identity = "~21.1.0" pexpect = "~4.8.0" intervaltree = "~3.1.0" structlog = "~22.3.0" -rocksdb = {git = "https://github.com/hathornetwork/python-rocksdb.git", markers = "sys_platform != 'win32'"} +rocksdb = {git = "https://github.com/hathornetwork/python-rocksdb.git"} aiohttp = "~3.10.3" idna = "~3.4" setproctitle = "^1.3.3" diff --git a/tests/conftest.py b/tests/conftest.py index 33fb90950..be711c139 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,14 +1,9 @@ import os -import sys from hathor.conf import UNITTESTS_SETTINGS_FILEPATH from hathor.reactor import initialize_global_reactor os.environ['HATHOR_CONFIG_YAML'] = os.environ.get('HATHOR_TEST_CONFIG_YAML', UNITTESTS_SETTINGS_FILEPATH) -if sys.platform == 'win32': - # XXX: because rocksdb isn't available on Windows, we force using memory-storage for tests so most of them can run - os.environ['HATHOR_TEST_MEMORY_STORAGE'] = 'true' - # TODO: We should remove this call from the module level. initialize_global_reactor(use_asyncio_reactor=True) diff --git a/tests/p2p/test_connections.py b/tests/p2p/test_connections.py index a9e33b79f..570424c84 100644 --- a/tests/p2p/test_connections.py +++ b/tests/p2p/test_connections.py @@ -1,14 +1,9 @@ -import sys - -import pytest - from hathor.p2p.entrypoint import Entrypoint from tests import unittest from tests.utils import run_server class ConnectionsTest(unittest.TestCase): - @pytest.mark.skipif(sys.platform == 'win32', reason='run_server is very finicky on Windows') def test_connections(self) -> None: process = run_server() process2 = run_server(listen=8006, status=8086, bootstrap='tcp://127.0.0.1:8005') diff --git a/tests/resources/test_profiler.py b/tests/resources/test_profiler.py index 0004428ea..8dfa5c333 100644 --- a/tests/resources/test_profiler.py +++ b/tests/resources/test_profiler.py @@ -1,10 +1,8 @@ import os import re import shutil -import sys import tempfile -import pytest from twisted.internet.defer import inlineCallbacks from hathor.profiler.resources import ProfilerResource @@ -19,7 +17,6 @@ def setUp(self): super().setUp() self.web = StubSite(ProfilerResource(self.manager)) - @pytest.mark.skipif(sys.platform == 'win32', reason='shutil.rmtree fails on Windows') @inlineCallbacks def test_post(self): # Options diff --git a/tests/tx/test_prometheus.py b/tests/tx/test_prometheus.py index 529b7e48f..5783db6ca 100644 --- a/tests/tx/test_prometheus.py +++ b/tests/tx/test_prometheus.py @@ -1,10 +1,7 @@ import os import shutil -import sys import tempfile -import pytest - from hathor.prometheus import PrometheusMetricsExporter from hathor.simulator.utils import add_new_blocks from tests import unittest @@ -20,7 +17,6 @@ def setUp(self): self.network = 'testnet' self.manager = self.create_peer(self.network, unlock_wallet=True) - @pytest.mark.skipif(sys.platform == 'win32', reason='set_new_metrics fails on Windows') def test_wallet(self): tmpdir = tempfile.mkdtemp() tmpfile = tempfile.NamedTemporaryFile(dir=tmpdir, suffix='.prom', delete=False)