From: Michael R. Crusoe <crusoe@debian.org>
Subject: Remove use of sys.maxsize
Forwarded: https://github.com/DataBiosphere/toil/pull/3824

Python integers can be larger that sys.maxsize

And on 32-bit machines the use of sys.maxize made is sot that options.maxMemory
sets a limit of 1.99GiB memory available unless overridden;
likewise for options.maxDisk being limited to 1.99GiB disk space available
unless overridden.

The above caused CWLSmallTests.test_workflow_echo_string to fail in Debian on
32-bit systems

--- toil.orig/src/toil/common.py
+++ toil/src/toil/common.py
@@ -20,10 +20,11 @@
 import tempfile
 import time
 import uuid
+import platform
 
 from urllib.parse import urlparse
 from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, _ArgumentGroup
-from typing import Any, Callable, List, Optional, Tuple, Union
+from typing import Any, Callable, List, Literal, Optional, Tuple, Union
 
 import requests
 
@@ -92,7 +93,7 @@
         self.metrics: bool = False
 
         # Parameters to limit service jobs, so preventing deadlock scheduling scenarios
-        self.maxPreemptableServiceJobs: int = sys.maxsize
+        self.maxPreemptableServiceJobs: int = 9223372036854775807 
         self.maxServiceJobs: int = sys.maxsize
         self.deadlockWait: Union[float, int] = 60  # Number of seconds we must be stuck with all services before declaring a deadlock
         self.deadlockCheckInterval: Union[float, int] = 30  # Minimum polling delay for deadlocks
@@ -104,9 +105,9 @@
         self.defaultDisk: int = 2147483648
         self.readGlobalFileMutableByDefault: bool = False
         self.defaultPreemptable: bool = False
-        self.maxCores: int = sys.maxsize
-        self.maxMemory: int = sys.maxsize
-        self.maxDisk: int = sys.maxsize
+        self.maxCores: int = 9223372036854775807
+        self.maxMemory: int = 9223372036854775807
+        self.maxDisk: int = 9223372036854775807
 
         # Retrying/rescuing jobs
         self.retryCount: int = 1
@@ -1393,7 +1394,7 @@
     return d
 
 
-def iC(minValue, maxValue=sys.maxsize):
+def iC(minValue, maxValue=9223372036854775807):
     # Returns function that checks if a given int is in the given half-open interval
     assert isinstance(minValue, int) and isinstance(maxValue, int)
     return lambda x: minValue <= x < maxValue
--- toil.orig/src/toil/cwl/cwltoil.py
+++ toil/src/toil/cwl/cwltoil.py
@@ -1618,7 +1618,7 @@
 
     def __init__(self, cwljob: dict):
         """Store the dictionary of promises for later resolution."""
-        super(ResolveIndirect, self).__init__(cores=1, memory=1024 ^ 2, disk=0)
+        super(ResolveIndirect, self).__init__(cores=1, memory="1GiB", disk="1MiB")
         self.cwljob = cwljob
 
     def run(self, file_store: AbstractFileStore) -> dict:
@@ -1770,7 +1770,7 @@
         conditional: Union[Conditional, None] = None,
     ):
         """Store our context for later evaluation."""
-        super(CWLJobWrapper, self).__init__(cores=1, memory=1024 * 1024, disk=8 * 1024)
+        super(CWLJobWrapper, self).__init__(cores=1, memory="1GiB", disk="1MiB")
         self.cwltool = remove_pickle_problems(tool)
         self.cwljob = cwljob
         self.runtime_context = runtime_context
@@ -2125,7 +2125,7 @@
         conditional: Union[Conditional, None],
     ):
         """Store our context for later execution."""
-        super(CWLScatter, self).__init__(cores=1, memory=100 * 1024 ^ 2, disk=0)
+        super(CWLScatter, self).__init__(cores=1, memory="1GiB", disk="1MiB")
         self.step = step
         self.cwljob = cwljob
         self.runtime_context = runtime_context
@@ -2268,7 +2268,7 @@
         outputs: Union[Mapping, MutableSequence],
     ):
         """Collect our context for later gathering."""
-        super(CWLGather, self).__init__(cores=1, memory=10 * 1024 ^ 2, disk=0)
+        super(CWLGather, self).__init__(cores=1, memory="1GiB", disk="1MiB")
         self.step = step
         self.outputs = outputs
 
@@ -2310,7 +2310,7 @@
 
     def __init__(self, j: "CWLWorkflow", v: dict):
         """Record the workflow and dictionary."""
-        super(SelfJob, self).__init__(cores=1, memory=1024 ^ 2, disk=0)
+        super(SelfJob, self).__init__(cores=1, memory="1GiB", disk="1MiB")
         self.j = j
         self.v = v
 
@@ -2364,7 +2364,7 @@
         conditional: Union[Conditional, None] = None,
     ):
         """Gather our context for later execution."""
-        super(CWLWorkflow, self).__init__(cores=1, memory=100 * 1024 ^ 2, disk=0)
+        super(CWLWorkflow, self).__init__(cores=1, memory="1GiB", disk="1MiB")
         self.cwlwf = cwlwf
         self.cwljob = cwljob
         self.runtime_context = runtime_context
--- toil.orig/src/toil/batchSystems/parasol.py
+++ toil/src/toil/batchSystems/parasol.py
@@ -48,7 +48,7 @@
 
     def __init__(self, config, maxCores, maxMemory, maxDisk):
         super(ParasolBatchSystem, self).__init__(config, maxCores, maxMemory, maxDisk)
-        if maxMemory != sys.maxsize:
+        if maxMemory != 9223372036854775807:
             logger.warning('The Parasol batch system does not support maxMemory.')
         # Keep the name of the results file for the pstat2 command..
         command = config.parasolCommand
--- toil.orig/src/toil/batchSystems/singleMachine.py
+++ toil/src/toil/batchSystems/singleMachine.py
@@ -16,7 +16,6 @@
 import os
 import signal
 import subprocess
-import sys
 import time
 import traceback
 from contextlib import contextmanager
@@ -80,12 +79,12 @@
         # If we don't have up to the limit of the resource (and the resource
         # isn't the inlimited sentinel), warn.
         if maxCores > self.numCores:
-            if maxCores != sys.maxsize:
+            if maxCores != 9223372036854775807:
                 # We have an actually specified limit and not the default
                 log.warning('Not enough cores! User limited to %i but we only have %i.', maxCores, self.numCores)
             maxCores = self.numCores
         if maxMemory > self.physicalMemory:
-            if maxMemory != sys.maxsize:
+            if maxMemory != 9223372036854775807:
                 # We have an actually specified limit and not the default
                 log.warning('Not enough memory! User limited to %i bytes but we only have %i bytes.', maxMemory, self.physicalMemory)
             maxMemory = self.physicalMemory
@@ -93,7 +92,7 @@
         workdir = Toil.getLocalWorkflowDir(config.workflowID, config.workDir)  # config.workDir may be None; this sets a real directory
         self.physicalDisk = toil.physicalDisk(workdir)
         if maxDisk > self.physicalDisk:
-            if maxDisk != sys.maxsize:
+            if maxDisk != 9223372036854775807:
                 # We have an actually specified limit and not the default
                 log.warning('Not enough disk space! User limited to %i bytes but we only have %i bytes.', maxDisk, self.physicalDisk)
             maxDisk = self.physicalDisk
