Skip to content

Commit

Permalink
chore: remove the limited support there was for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jansegre committed Oct 30, 2024
1 parent 550767b commit 4200cc2
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
5 changes: 2 additions & 3 deletions hathor/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(self) -> None:
shell,
side_dag,
stratum_mining,
top,
twin_tx,
tx_generator,
wallet,
Expand All @@ -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')
Expand Down
13 changes: 7 additions & 6 deletions hathor/cli/run_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,21 @@ 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:
sys.setrecursionlimit(self._args.recursion_limit)
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()
Expand Down
4 changes: 2 additions & 2 deletions hathor/cli/top.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 0 additions & 5 deletions hathor/reactor/reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 0 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 0 additions & 5 deletions tests/p2p/test_connections.py
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
3 changes: 0 additions & 3 deletions tests/resources/test_profiler.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
4 changes: 0 additions & 4 deletions tests/tx/test_prometheus.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 4200cc2

Please sign in to comment.