Read about our upcoming Code of Conduct on this issue

Commit e8fa31c1 authored by Pierre Augier's avatar Pierre Augier
Browse files

Lock file during compilation

parent af0fc2b34690
......@@ -5,6 +5,12 @@ Future
- :code:`pythran_def` for simple methods (without assignation to attributes
and call of other methods)
0.1.3 (2018-12-04)
------------------
- Lock file during Pythran compilation
- :code:`__name__` and :code:`__doc__` preserved by decorators
0.1.2 (2018-12-03)
------------------
......
......@@ -27,9 +27,13 @@ Note that one can also just write Pythran type-string in type annotations::
def myfunc(a: "float[3, :]", b: float):
...
Note that if you only need one dimension, array types can be defined like
this::
Finally, array types with only one number of dimension can simply be
defined like this::
from fluidpythran import array
from fluidpythran import Array
A = Array[float, "2d"]
A = Array[float, "3d"]
Which has actually the same effect as::
A = "float[:, :, :]"
__version__ = "0.1.2"
__version__ = "0.1.3"
try:
from pyfiglet import figlet_format
......
......@@ -13,6 +13,7 @@ import sys
import logging
from pathlib import Path
import sysconfig
from time import time, sleep
logger = logging.getLogger("pythran_fluid")
logger.setLevel(logging.INFO)
......@@ -27,25 +28,65 @@ def main():
args = sys.argv[1:]
path = Path.cwd() / args[0]
name = args[0]
path = Path.cwd() / name
print(f"Pythranize {path}")
if "-o" in args:
index_output = args.index("-o") + 1
name_out = args[index_output]
name_out_base = name_out.split(".", 1)[0]
else:
name_out = Path(name).with_suffix(ext_suffix).name
name_out_base = name_out.split(".", 1)[0]
if "-o" in args:
name_tmp = name_out_base + ".tmp"
args[index_output] = name_tmp
path_tmp = Path(name_tmp)
path_out = path_tmp.with_suffix(ext_suffix)
else:
path_out = Path(name_out)
name_lock = Path(name_out_base + ".lock")
if name_lock.exists():
# the compilation should be
time_out_lock = 3600 # (s) let's hope it's enough
time_start = time()
while name_lock.exists() and time() - time_start < time_out_lock:
sleep(1)
if time() - time_start >= time_out_lock:
logger.error(f"Remove lock file {name_lock.absolute()}")
name_lock.unlink()
raise TimeoutError(
f"Stop waiting for a lock file to be deleted {name_lock.absolute()}"
)
assert not name_lock.exists()
sleep(1)
if not path_out.exists():
raise RuntimeError(
f"After lock file were deleted, {path_out.absolute()} not created"
)
return
args.insert(0, "pythran")
subprocess.call(args)
name_lock.touch()
try:
subprocess.call(args)
except Exception:
pass
finally:
name_lock.unlink()
path_tmp = Path(name_tmp)
if path_tmp.exists():
path_out = path_tmp.with_suffix(ext_suffix)
if "-o" in args and path_tmp.exists():
path_tmp.rename(path_out)
print(f"file {Path.cwd() / path_out.name} created")
if path_out.exists():
print(f"file {path_out.absolute()} created")
else:
logger.error(
f"file {Path.cwd() / path_tmp.name} has not been created by Pythran"
f"file {path_out.absolute()} has not been created by Pythran"
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment