Skip to content

Commit

Permalink
Move cython logic to separate awlsim_loader module
Browse files Browse the repository at this point in the history
This avoids loader magic issues

Signed-off-by: Michael Buesch <m@bues.ch>
  • Loading branch information
mbuesch committed Nov 8, 2016
1 parent 150d9b0 commit 2d76736
Show file tree
Hide file tree
Showing 25 changed files with 110 additions and 132 deletions.
5 changes: 2 additions & 3 deletions awlsim-client
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
#

from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.common.compat import *

import sys
import getopt

from awlsim.common import *
from awlsim.coreclient import *
from awlsim_loader.common import *
from awlsim_loader.coreclient import *


class TextInterfaceAwlSimClient(AwlSimClient):
Expand Down
7 changes: 3 additions & 4 deletions awlsim-linuxcnc-hal
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@
#

from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.common.compat import *

import sys
import os
import time
import getopt

from awlsim.common import *
from awlsim.coreserver.server import *
from awlsim.coreclient.client import *
from awlsim_loader.common import *
from awlsim_loader.coreserver import *
from awlsim_loader.coreclient import *


class LinuxCNC_NotRunning(Exception):
Expand Down
9 changes: 4 additions & 5 deletions awlsim-server
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@
#

from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.common.compat import *

import sys
import getopt
from socket import AF_INET, AF_INET6

from awlsim.common import *
from awlsim.core import *
from awlsim.coreclient.client import *
from awlsim.coreserver.server import *
from awlsim_loader.common import *
from awlsim_loader.core import *
from awlsim_loader.coreclient import *
from awlsim_loader.coreserver import *


def usage():
Expand Down
5 changes: 2 additions & 3 deletions awlsim-symtab
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
#

from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.common.compat import *

import sys
import getopt

from awlsim.common import *
from awlsim.core.symbolparser import *
from awlsim_loader.common import *
from awlsim_loader.core import *


def usage():
Expand Down
13 changes: 6 additions & 7 deletions awlsim-test
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ import getopt
import traceback
import signal

from awlsim.common import *
from awlsim.core import *
from awlsim.coreclient.client import *
from awlsim_loader.common import *
from awlsim_loader.core import *
from awlsim_loader.coreclient import *
import awlsim_loader.cython_helper as cython_helper


class TestAwlSimClient(AwlSimClient):
Expand Down Expand Up @@ -159,8 +160,7 @@ def assignCpuSpecs(cpuSpecs, projectCpuSpecs):
def run(inputFile):
s = None
try:
import awlsim.cython_helper
if awlsim.cython_helper.shouldUseCython():
if cython_helper.shouldUseCython():
writeStdout("*** Using accelerated CYTHON core "
"(AWLSIM_CYTHON environment variable is set)\n")

Expand Down Expand Up @@ -252,8 +252,7 @@ def runWithServerBackend(inputFile):
client = None
tunnel = None
try:
import awlsim.cython_helper
if awlsim.cython_helper.shouldUseCython():
if cython_helper.shouldUseCython():
printError("The accelerated CYTHON core currently is incompatible "
"with the backend server. Please remove the "
"AWLSIM_CYTHON environment variable.")
Expand Down
25 changes: 15 additions & 10 deletions awlsim/common/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.common.compat import *

import awlsim.cython_helper as __cython

if __cython.shouldUseCython(__name__): #@nocy
#if True: #@cy
try:
from awlsim_cython.common.all_modules import * #<no-cython-patch
except ImportError as e:
__cython.cythonImportError(__name__, str(e))
if not __cython.shouldUseCython(__name__): #@nocy
from awlsim.common.all_modules import * #@nocy
from awlsim.common.blocker import *
from awlsim.common.cpuspecs import *
from awlsim.common.datatypehelpers import *
from awlsim.common.debug import *
from awlsim.common.enumeration import *
from awlsim.common.exceptions import *
from awlsim.common.immutable import *
from awlsim.common.net import *
from awlsim.common.project import *
from awlsim.common.subprocess import *
from awlsim.common.templates import *
from awlsim.common.util import *
from awlsim.common.version import *
from awlsim.common.wordpacker import *
17 changes: 0 additions & 17 deletions awlsim/common/all_modules.py

This file was deleted.

2 changes: 1 addition & 1 deletion awlsim/common/dynamic_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def importModule(moduleName):
Returns the module object.
May raise importError."""

import awlsim.cython_helper as cython_helper
import awlsim_loader.cython_helper as cython_helper
try:
import importlib
except ImportError as e:
Expand Down
16 changes: 6 additions & 10 deletions awlsim/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.common.compat import *

import awlsim.cython_helper as __cython

if __cython.shouldUseCython(__name__): #@nocy
#if True: #@cy
try:
from awlsim_cython.core.all_modules import * #<no-cython-patch
except ImportError as e:
__cython.cythonImportError(__name__, str(e))
if not __cython.shouldUseCython(__name__): #@nocy
from awlsim.core.all_modules import * #@nocy
from awlsim.core.main import *
from awlsim.core.cpu import *
from awlsim.core.hardware import *
from awlsim.core.parser import *
from awlsim.core.util import *
8 changes: 0 additions & 8 deletions awlsim/core/all_modules.py

This file was deleted.

11 changes: 0 additions & 11 deletions awlsim/coreclient/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
from __future__ import division, absolute_import, print_function, unicode_literals

import awlsim.cython_helper as __cython

if __cython.shouldUseCython(__name__): #@nocy
#if True: #@cy
try:
from awlsim_cython.coreclient.all_modules import * #<no-cython-patch
except ImportError as e:
__cython.cythonImportError(__name__, str(e))
if not __cython.shouldUseCython(__name__): #@nocy
from awlsim.coreclient.all_modules import * #@nocy
3 changes: 0 additions & 3 deletions awlsim/coreclient/all_modules.py

This file was deleted.

11 changes: 0 additions & 11 deletions awlsim/coreserver/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
from __future__ import division, absolute_import, print_function, unicode_literals

import awlsim.cython_helper as __cython

if __cython.shouldUseCython(__name__): #@nocy
#if True: #@cy
try:
from awlsim_cython.coreserver.all_modules import * #<no-cython-patch
except ImportError as e:
__cython.cythonImportError(__name__, str(e))
if not __cython.shouldUseCython(__name__): #@nocy
from awlsim.coreserver.all_modules import * #@nocy
3 changes: 0 additions & 3 deletions awlsim/coreserver/all_modules.py

This file was deleted.

9 changes: 4 additions & 5 deletions awlsim/gui/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
#

from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.common.compat import *

from awlsim.common import *
from awlsim.coreclient.client import *
import awlsim.cython_helper
from awlsim_loader.common import *
from awlsim_loader.coreclient import *
import awlsim_loader.cython_helper as cython_helper

import sys
import traceback
Expand All @@ -35,7 +34,7 @@
printError("Please use CPython 2.7 or CPython 3.x")
sys.exit(1)

if awlsim.cython_helper.shouldUseCython():
if cython_helper.shouldUseCython():
print("*** Using accelerated CYTHON core "
"(AWLSIM_CYTHON environment variable is set)")

Expand Down
11 changes: 0 additions & 11 deletions awlsim/library/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
from __future__ import division, absolute_import, print_function, unicode_literals

import awlsim.cython_helper as __cython

if __cython.shouldUseCython(__name__): #@nocy
#if True: #@cy
try:
from awlsim_cython.library.all_modules import * #<no-cython-patch
except ImportError as e:
__cython.cythonImportError(__name__, str(e))
if not __cython.shouldUseCython(__name__): #@nocy
from awlsim.library.all_modules import * #@nocy
15 changes: 6 additions & 9 deletions awlsim/library/iec/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.common.compat import *

import awlsim.cython_helper as __cython
from awlsim.library.iec.iec import *

if __cython.shouldUseCython(__name__): #@nocy
#if True: #@cy
try:
from awlsim_cython.library.iec.all_modules import * #<no-cython-patch
except ImportError as e:
__cython.cythonImportError(__name__, str(e))
if not __cython.shouldUseCython(__name__): #@nocy
from awlsim.library.iec.all_modules import * #@nocy
from awlsim.library.iec.fc4_delete import *
from awlsim.library.iec.fc9_eq_dt import *
from awlsim.library.iec.fc12_ge_dt import *
from awlsim.library.iec.fc21_len import *
9 changes: 0 additions & 9 deletions awlsim/library/iec/all_modules.py

This file was deleted.

2 changes: 0 additions & 2 deletions awlsim/library/all_modules.py → awlsim_loader/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from __future__ import division, absolute_import, print_function, unicode_literals
from awlsim.common.compat import *

15 changes: 15 additions & 0 deletions awlsim_loader/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from __future__ import division, absolute_import, print_function, unicode_literals

import awlsim_loader.cython_helper as __cython

__importmod = "awlsim.common"

if __cython.shouldUseCython(__importmod): #@nocy
#if True: #@cy
__importcymod = __cython.cythonModuleName(__importmod)
try:
exec("from %s import *" % __importcymod)
except ImportError as e:
__cython.cythonImportError(__importcymod, str(e))
if not __cython.shouldUseCython(__importmod): #@nocy
exec("from %s import *" % __importmod) #@nocy
15 changes: 15 additions & 0 deletions awlsim_loader/core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from __future__ import division, absolute_import, print_function, unicode_literals

import awlsim_loader.cython_helper as __cython

__importmod = "awlsim.core"

if __cython.shouldUseCython(__importmod): #@nocy
#if True: #@cy
__importcymod = __cython.cythonModuleName(__importmod)
try:
exec("from %s import *" % __importcymod)
except ImportError as e:
__cython.cythonImportError(__importcymod, str(e))
if not __cython.shouldUseCython(__importmod): #@nocy
exec("from %s import *" % __importmod) #@nocy
15 changes: 15 additions & 0 deletions awlsim_loader/coreclient.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from __future__ import division, absolute_import, print_function, unicode_literals

import awlsim_loader.cython_helper as __cython

__importmod = "awlsim.coreclient.client"

if __cython.shouldUseCython(__importmod): #@nocy
#if True: #@cy
__importcymod = __cython.cythonModuleName(__importmod)
try:
exec("from %s import *" % __importcymod)
except ImportError as e:
__cython.cythonImportError(__importcymod, str(e))
if not __cython.shouldUseCython(__importmod): #@nocy
exec("from %s import *" % __importmod) #@nocy
15 changes: 15 additions & 0 deletions awlsim_loader/coreserver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from __future__ import division, absolute_import, print_function, unicode_literals

import awlsim_loader.cython_helper as __cython

__importmod = "awlsim.coreserver.server"

if __cython.shouldUseCython(__importmod): #@nocy
#if True: #@cy
__importcymod = __cython.cythonModuleName(__importmod)
try:
exec("from %s import *" % __importcymod)
except ImportError as e:
__cython.cythonImportError(__importcymod, str(e))
if not __cython.shouldUseCython(__importmod): #@nocy
exec("from %s import *" % __importmod) #@nocy
File renamed without changes.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def pyCythonPatchLine(line, basicOnly=False):
author_email = "m@bues.ch",
url = "https://bues.ch/a/awlsim",
packages = [ "awlsim",
"awlsim_loader",
"awlsim/common",
"awlsim/core",
"awlsim/core/instructions",
Expand Down

0 comments on commit 2d76736

Please sign in to comment.