Skip to content

Commit 2a5fa22

Browse files
committed
Correct import issues
Signed-off-by: Matthew Ballance <matt.ballance@gmail.com>
1 parent f69bcfd commit 2a5fa22

File tree

5 files changed

+85
-80
lines changed

5 files changed

+85
-80
lines changed

src/ivpm/setup/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11

2-
from .setup import setup
2+
from .wrapper import setup

src/ivpm/setup/build_ext.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def build_extensions(self):
4545
super().build_extensions()
4646

4747
def build_extension(self, ext):
48-
from ivpm.setup.setup import get_hooks, Phase_BuildPre, Phase_BuildPost, expand_libvars, get_ivpm_ext_name_m
48+
from ivpm.setup.ivpm_data import get_hooks, Phase_BuildPre, Phase_BuildPost, expand_libvars, get_ivpm_ext_name_m
4949
proj_dir = os.getcwd()
5050
print("build_extension: %s" % str(ext))
5151
include_dirs = getattr(ext, 'include_dirs', [])
@@ -82,7 +82,7 @@ def build_extension(self, ext):
8282
return ret
8383

8484
def copy_extensions_to_source(self):
85-
from ivpm.setup.setup import get_hooks, Phase_BuildPre, Phase_BuildPost, expand_libvars, get_ivpm_ext_name_m
85+
from ivpm.setup.ivpm_data import get_hooks, Phase_BuildPre, Phase_BuildPost, expand_libvars, get_ivpm_ext_name_m
8686
""" Like the base class method, but copy libs into proper directory in develop. """
8787
print("copy_extensions_to_source")
8888
for hook in get_hooks(Phase_BuildPre):
@@ -239,7 +239,7 @@ def build_cmake(self, proj_dir):
239239
build_cmd[cmake_build_tool](self, build_dir, env)
240240
install_cmd[cmake_build_tool](self, build_dir, env)
241241

242-
from ivpm.setup.setup import get_ivpm_extdep_data
242+
from ivpm.setup.ivpm_data import get_ivpm_extdep_data
243243
for src,dst in get_ivpm_extdep_data():
244244
shutil.copyfile(src, dst)
245245

src/ivpm/setup/install_lib.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
class InstallLib(_install_lib):
2828

2929
def install(self):
30-
import ivpm.setup.setup as ivpms
31-
from ivpm.setup.setup import get_ivpm_extra_data, get_ivpm_ext_name_m, expand_libvars
30+
from ivpm import setup as ivpms
31+
from ivpm.setup.ivpm_data import get_ivpm_extra_data, get_ivpm_ext_name_m, expand_libvars
3232
# Assume
3333
# May need to install some additional libraries and data
3434
# - data and/or include files to package 'share'
@@ -54,7 +54,7 @@ def install(self):
5454
for p in build_py.packages:
5555
if p in ivpm_extra_data.keys():
5656
for spec in ivpm_extra_data[p]:
57-
src = ivpms.expand_libvars(spec[0])
57+
src = expand_libvars(spec[0])
5858
dst = spec[1]
5959

6060
if os.path.isfile(src):

src/ivpm/setup/ivpm_data.py

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import os
2+
import platform
3+
4+
Phase_SetupPre = "setup.pre"
5+
Phase_SetupPost = "setup.post"
6+
Phase_BuildPre = "build.pre"
7+
Phase_BuildPost = "build.post"
8+
9+
_ivpm_extra_data = {}
10+
_ivpm_extdep_data = []
11+
_ivpm_hooks = {}
12+
_ivpm_ext_name_m = {}
13+
_package_dir = {}
14+
15+
def get_hooks(kind : str):
16+
global _ivpm_hooks
17+
if kind in _ivpm_hooks.keys():
18+
return _ivpm_hooks[kind]
19+
else:
20+
return []
21+
22+
def get_ivpm_extra_data():
23+
global _ivpm_extra_data
24+
return _ivpm_extra_data
25+
26+
def get_ivpm_extdep_data():
27+
global _ivpm_extdep_data
28+
return _ivpm_extdep_data
29+
30+
def get_ivpm_ext_name_m():
31+
global _ivpm_ext_name_m
32+
return _ivpm_ext_name_m
33+
34+
def get_package_dir():
35+
return _package_dir
36+
37+
38+
39+
def expand(subst_m, path):
40+
elems = path.split("/")
41+
42+
# Perform path meta-variable substitution
43+
for i,e in enumerate(elems):
44+
found = True
45+
while found:
46+
found = False
47+
for k in subst_m.keys():
48+
if e.find(k) != -1:
49+
found = True
50+
e = e.replace(k, subst_m[k])
51+
elems[i] = e
52+
return "/".join(elems)
53+
54+
def expand_libvars(src):
55+
libpref = "lib"
56+
dllext = ".so"
57+
if platform.system() == "Windows":
58+
libpref = ""
59+
dllext = ".dll"
60+
elif platform.system() == "Darwin":
61+
libpref = "lib"
62+
dllext = ".dylib"
63+
64+
subst_m = {
65+
"{libdir}" : "lib64" if os.path.isdir(os.path.join("build", "lib64")) else "lib",
66+
"{libpref}" : libpref,
67+
"{dllpref}" : libpref,
68+
"{dllext}" : dllext
69+
}
70+
71+
return expand(subst_m, src)

src/ivpm/setup/setup.py src/ivpm/setup/wrapper.py

+7-73
Original file line numberDiff line numberDiff line change
@@ -29,73 +29,7 @@
2929
import inspect
3030
import platform
3131
from ivpm.pkg_info_rgy import PkgInfoRgy
32-
33-
Phase_SetupPre = "setup.pre"
34-
Phase_SetupPost = "setup.post"
35-
Phase_BuildPre = "build.pre"
36-
Phase_BuildPost = "build.post"
37-
38-
_ivpm_extra_data = {}
39-
_ivpm_extdep_data = []
40-
_ivpm_hooks = {}
41-
_ivpm_ext_name_m = {}
42-
43-
def get_hooks(kind : str):
44-
global _ivpm_hooks
45-
if kind in _ivpm_hooks.keys():
46-
return _ivpm_hooks[kind]
47-
else:
48-
return []
49-
50-
def get_ivpm_extra_data():
51-
global _ivpm_extra_data
52-
return _ivpm_extra_data
53-
54-
def get_ivpm_extdep_data():
55-
global _ivpm_extdep_data
56-
return _ivpm_extdep_data
57-
58-
def get_ivpm_ext_name_m():
59-
global _ivpm_ext_name_m
60-
return _ivpm_ext_name_m
61-
62-
_package_dir = {}
63-
def get_package_dir():
64-
return _package_dir
65-
66-
def expand(subst_m, path):
67-
elems = path.split("/")
68-
69-
# Perform path meta-variable substitution
70-
for i,e in enumerate(elems):
71-
found = True
72-
while found:
73-
found = False
74-
for k in subst_m.keys():
75-
if e.find(k) != -1:
76-
found = True
77-
e = e.replace(k, subst_m[k])
78-
elems[i] = e
79-
return "/".join(elems)
80-
81-
def expand_libvars(src):
82-
libpref = "lib"
83-
dllext = ".so"
84-
if platform.system() == "Windows":
85-
libpref = ""
86-
dllext = ".dll"
87-
elif platform.system() == "Darwin":
88-
libpref = "lib"
89-
dllext = ".dylib"
90-
91-
subst_m = {
92-
"{libdir}" : "lib64" if os.path.isdir(os.path.join("build", "lib64")) else "lib",
93-
"{libpref}" : libpref,
94-
"{dllpref}" : libpref,
95-
"{dllext}" : dllext
96-
}
97-
98-
return expand(subst_m, src)
32+
import ivpm.setup.ivpm_data as idata
9933

10034

10135
def setup(*args, **kwargs):
@@ -113,19 +47,19 @@ def setup(*args, **kwargs):
11347
debug = False
11448

11549
if "ivpm_extra_data" in kwargs.keys():
116-
_ivpm_extra_data = kwargs["ivpm_extra_data"]
50+
idata._ivpm_extra_data = kwargs["ivpm_extra_data"]
11751
kwargs.pop("ivpm_extra_data")
11852

11953
if "ivpm_extdep_data" in kwargs.keys():
120-
_ivpm_extdep_data = kwargs["ivpm_extdep_data"]
54+
idata._ivpm_extdep_data = kwargs["ivpm_extdep_data"]
12155
kwargs.pop("ivpm_extdep_data")
12256

12357
if "ivpm_hooks" in kwargs.keys():
124-
_ivpm_hooks = kwargs["ivpm_hooks"]
58+
idata._ivpm_hooks = kwargs["ivpm_hooks"]
12559
kwargs.pop("ivpm_hooks")
12660

12761
if "ivpm_ext_name_m" in kwargs.keys():
128-
_ivpm_ext_name_m = kwargs["ivpm_ext_name_m"]
62+
idata._ivpm_ext_name_m = kwargs["ivpm_ext_name_m"]
12963
kwargs.pop("ivpm_ext_name_m")
13064

13165
# project_dir = os.path.dirname(os.path.abspath(
@@ -213,12 +147,12 @@ def setup(*args, **kwargs):
213147
if hasattr(ext, "package_deps"):
214148
print("package_deps")
215149

216-
for hook in get_hooks(Phase_SetupPre):
150+
for hook in idata.get_hooks(idata.Phase_SetupPre):
217151
hook(None)
218152

219153
_setup(*args, **kwargs)
220154

221-
for hook in get_hooks(Phase_SetupPost):
155+
for hook in idata.get_hooks(idata.Phase_SetupPost):
222156
hook(None)
223157

224158
def _collect_extdeps(

0 commit comments

Comments
 (0)