Roll my my own bit_length function for Python 2.6 compatibility.
This commit is contained in:
parent
222f551c37
commit
f0edfa6edf
@ -40,7 +40,6 @@
|
|||||||
import time
|
import time
|
||||||
import string
|
import string
|
||||||
import contextlib
|
import contextlib
|
||||||
from urlparse import urlparse
|
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
|
|
||||||
import llnl.util.lock
|
import llnl.util.lock
|
||||||
@ -63,6 +62,7 @@
|
|||||||
import spack.util.web
|
import spack.util.web
|
||||||
|
|
||||||
from spack.stage import Stage, ResourceStage, StageComposite
|
from spack.stage import Stage, ResourceStage, StageComposite
|
||||||
|
from spack.util.crypto import bit_length
|
||||||
from spack.util.environment import dump_environment
|
from spack.util.environment import dump_environment
|
||||||
from spack.util.executable import ProcessError, which
|
from spack.util.executable import ProcessError, which
|
||||||
from spack.version import *
|
from spack.version import *
|
||||||
@ -719,7 +719,7 @@ def prefix_lock(self):
|
|||||||
if prefix not in Package.prefix_locks:
|
if prefix not in Package.prefix_locks:
|
||||||
Package.prefix_locks[prefix] = llnl.util.lock.Lock(
|
Package.prefix_locks[prefix] = llnl.util.lock.Lock(
|
||||||
spack.installed_db.prefix_lock_path,
|
spack.installed_db.prefix_lock_path,
|
||||||
self.spec.dag_hash_bit_prefix(sys.maxsize.bit_length()), 1)
|
self.spec.dag_hash_bit_prefix(bit_length(sys.maxsize)), 1)
|
||||||
|
|
||||||
self._prefix_lock = Package.prefix_locks[prefix]
|
self._prefix_lock = Package.prefix_locks[prefix]
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
import spack.fetch_strategy as fs
|
import spack.fetch_strategy as fs
|
||||||
import spack.error
|
import spack.error
|
||||||
from spack.version import *
|
from spack.version import *
|
||||||
from spack.util.crypto import prefix_bits
|
from spack.util.crypto import prefix_bits, bit_length
|
||||||
|
|
||||||
STAGE_PREFIX = 'spack-stage-'
|
STAGE_PREFIX = 'spack-stage-'
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ def __init__(
|
|||||||
if lock:
|
if lock:
|
||||||
if self.name not in Stage.stage_locks:
|
if self.name not in Stage.stage_locks:
|
||||||
sha1 = hashlib.sha1(self.name).digest()
|
sha1 = hashlib.sha1(self.name).digest()
|
||||||
lock_id = prefix_bits(sha1, sys.maxsize.bit_length())
|
lock_id = prefix_bits(sha1, bit_length(sys.maxsize))
|
||||||
stage_lock_path = join_path(spack.stage_path, '.lock')
|
stage_lock_path = join_path(spack.stage_path, '.lock')
|
||||||
|
|
||||||
Stage.stage_locks[self.name] = llnl.util.lock.Lock(
|
Stage.stage_locks[self.name] = llnl.util.lock.Lock(
|
||||||
|
@ -114,3 +114,10 @@ def prefix_bits(byte_array, bits):
|
|||||||
|
|
||||||
result >>= (n - bits)
|
result >>= (n - bits)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def bit_length(num):
|
||||||
|
"""Number of bits required to represent an integer in binary."""
|
||||||
|
s = bin(num)
|
||||||
|
s = s.lstrip('-0b')
|
||||||
|
return len(s)
|
||||||
|
Loading…
Reference in New Issue
Block a user