Skip to content

Commit d1119d7

Browse files
committedJan 26, 2016
artiq_dir: move out of tools to unlink dependencies
1 parent cbb6033 commit d1119d7

File tree

9 files changed

+19
-11
lines changed

9 files changed

+19
-11
lines changed
 

Diff for: ‎artiq/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
from ._version import get_versions
22
__version__ = get_versions()['version']
33
del get_versions
4+
5+
import os
6+
__artiq_dir__ = os.path.dirname(os.path.abspath(__file__))
7+
del os

Diff for: ‎artiq/coredevice/core.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from pythonparser import diagnostic
44

5+
from artiq import __artiq_dir__ as artiq_dir
6+
57
from artiq.language.core import *
68
from artiq.language.types import *
79
from artiq.language.units import *
@@ -16,7 +18,7 @@
1618

1719
def _render_diagnostic(diagnostic, colored):
1820
def shorten_path(path):
19-
return path.replace(os.path.normpath(os.path.join(__file__, "..", "..")), "<artiq>")
21+
return path.replace(artiq_dir, "<artiq>")
2022
lines = [shorten_path(path) for path in diagnostic.render(colored)]
2123
return "\n".join(lines)
2224

Diff for: ‎artiq/coredevice/exceptions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import re
44
import os
55

6+
from artiq import __artiq_dir__ as artiq_dir
67
from artiq.coredevice.runtime import source_loader
78

89

@@ -36,8 +37,7 @@ def __str__(self):
3637
else:
3738
formatted_address = " (RA=0x{:x})".format(address)
3839

39-
filename = filename.replace(os.path.normpath(os.path.join(os.path.dirname(__file__),
40-
"..")), "<artiq>")
40+
filename = filename.replace(artiq_dir, "<artiq>")
4141
if column == -1:
4242
lines.append(" File \"{file}\", line {line}, in {function}{address}".
4343
format(file=filename, line=line, function=function,

Diff for: ‎artiq/coredevice/runtime.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import os
22

3+
from artiq import __artiq_dir__ as artiq_dir
4+
5+
36
class SourceLoader:
47
def __init__(self, runtime_root):
58
self.runtime_root = runtime_root
@@ -8,5 +11,4 @@ def get_source(self, filename):
811
with open(os.path.join(self.runtime_root, filename)) as f:
912
return f.read()
1013

11-
artiq_root = os.path.join(os.path.dirname(__file__), "..", "..")
12-
source_loader = SourceLoader(os.path.join(artiq_root, "soc", "runtime"))
14+
source_loader = SourceLoader(os.path.join(artiq_dir, "soc", "runtime"))

Diff for: ‎artiq/frontend/artiq_flash.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import tempfile
88

99
import artiq
10+
from artiq import __artiq_dir__ as artiq_dir
1011
from artiq.frontend.bit2bin import bit2bin
1112

1213

@@ -70,7 +71,7 @@ def main():
7071
}[opts.target]
7172

7273
if opts.dir is None:
73-
opts.dir = os.path.join(os.path.dirname(artiq.__file__), "binaries",
74+
opts.dir = os.path.join(artiq_dir, "binaries",
7475
"{}-{}".format(opts.target, opts.adapter))
7576

7677
conv = False

Diff for: ‎artiq/frontend/artiq_gui.py

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from quamash import QEventLoop, QtGui, QtCore
1111
from pyqtgraph import dockarea
1212

13+
from artiq import __artiq_dir__ as artiq_dir
1314
from artiq.tools import *
1415
from artiq.protocols.pc_rpc import AsyncioClient
1516
from artiq.gui.models import ModelSubscriber

Diff for: ‎artiq/gateware/targets/kc705.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from artiq.gateware.soc import AMPSoC
2121
from artiq.gateware import rtio, nist_qc1, nist_clock, nist_qc2
2222
from artiq.gateware.rtio.phy import ttl_simple, ttl_serdes_7series, dds
23-
from artiq.tools import artiq_dir
23+
from artiq import __artiq_dir__ as artiq_dir
2424
from artiq import __version__ as artiq_version
2525

2626

Diff for: ‎artiq/gateware/targets/pipistrello.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from artiq.gateware.soc import AMPSoC
2121
from artiq.gateware import rtio, nist_qc1
2222
from artiq.gateware.rtio.phy import ttl_simple, ttl_serdes_spartan6, dds
23-
from artiq.tools import artiq_dir
23+
from artiq import __artiq_dir__ as artiq_dir
2424
from artiq import __version__ as artiq_version
2525

2626

Diff for: ‎artiq/tools.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from artiq.protocols import pyon
1717

1818

19-
__all__ = ["artiq_dir", "parse_arguments", "elide", "short_format", "file_import",
19+
__all__ = ["parse_arguments", "elide", "short_format", "file_import",
2020
"get_experiment", "verbosity_args", "simple_network_args", "init_logger",
2121
"bind_address_from_args", "atexit_register_coroutine",
2222
"exc_to_warning", "asyncio_wait_or_cancel",
@@ -25,8 +25,6 @@
2525

2626
logger = logging.getLogger(__name__)
2727

28-
artiq_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)))
29-
3028

3129
def parse_arguments(arguments):
3230
d = {}

0 commit comments

Comments
 (0)
Please sign in to comment.