Skip to content

Commit bc30624

Browse files
committed
External Release v2024.05.05
- Improve `run_command()` APIs with Python3 and above support - Add basic ICX build configurations - Fix legal headers
1 parent 2a015ba commit bc30624

36 files changed

+643
-573
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
MBUILD USER INFO
22
-----------------
3-
4-
![.github/workflows/ci.yml](https://github.com/intelxed/mbuild/workflows/.github/workflows/ci.yml/badge.svg)
5-
6-
73
See:
84

95
https://intelxed.github.io/

build-doc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
#!/bin/csh
2+
#BEGIN_LEGAL
3+
#
4+
#Copyright (c) 2016 Intel Corporation
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
#END_LEGAL
219

320
seet webdir=/var/www/html/mjcharne/mbuild
421
epydoc -v --simple-term --no-private --html -o epydoc-out --name mbuild --url 'http://mjc.intel.com/mjcharne/mbuild' mbuild/__init__.py

do-dist

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
#!/bin/csh -f
22
#
33
# edit setup.py, set the version number
4+
#BEGIN_LEGAL
5+
#
6+
#Copyright (c) 2016 Intel Corporation
7+
#
8+
# Licensed under the Apache License, Version 2.0 (the "License");
9+
# you may not use this file except in compliance with the License.
10+
# You may obtain a copy of the License at
11+
#
12+
# http://www.apache.org/licenses/LICENSE-2.0
13+
#
14+
# Unless required by applicable law or agreed to in writing, software
15+
# distributed under the License is distributed on an "AS IS" BASIS,
16+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
# See the License for the specific language governing permissions and
18+
# limitations under the License.
19+
#
20+
#END_LEGAL
421
python setup.py sdist --formats=gztar,zip
522
cp dist/* /home/mjcharne/www/mbuild/download
623
make-web-accessible /home/mjcharne/www/mbuild/download

mbuild/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#BEGIN_LEGAL
22
#
3-
#Copyright (c) 2022 Intel Corporation
3+
#Copyright (c) 2024 Intel Corporation
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -112,7 +112,6 @@
112112
from .plan import *
113113
from .arar import *
114114
from .doxygen import doxygen_run, doxygen_args, doxygen_env
115-
from .header_tag import *
116115

117116
__all__ = [ 'base',
118117
'dag',
@@ -123,8 +122,7 @@
123122
'msvs',
124123
'arar',
125124
'doxygen',
126-
'dfs',
127-
'header_tag' ]
125+
'dfs']
128126

129127

130128
import time

mbuild/arar.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Repackage a bunch of static libs as one big static library.
44
#BEGIN_LEGAL
55
#
6-
#Copyright (c) 2016 Intel Corporation
6+
#Copyright (c) 2024 Intel Corporation
77
#
88
# Licensed under the Apache License, Version 2.0 (the "License");
99
# you may not use this file except in compliance with the License.
@@ -62,23 +62,23 @@ def repack(files, ar='ar', target='liball.a', verbose=False):
6262
else:
6363
cmd = "%s x ../%s" % (ar,arg)
6464
if verbose:
65-
uprint(u"EXTRACTING %s" % (cmd))
65+
print(u"EXTRACTING %s" % (cmd))
6666
error= os.system(cmd)
6767
if error:
6868
raise arar_error('Extract failed for command %s' % (cmd))
6969
files = glob.glob('*.o') + doto
7070
local_target = os.path.basename(target)
7171
cmd = "%s rcv %s %s" % (ar, local_target, " ".join(files))
7272
if verbose:
73-
uprint(u"RECOMBINING %s" % (cmd))
73+
print(u"RECOMBINING %s" % (cmd))
7474
error=os.system(cmd)
7575
if error:
7676
raise arar_error('Recombine failed')
7777

7878
os.chdir('..')
7979
os.rename(os.path.join(tdir,local_target), target)
8080
if verbose:
81-
uprint(u"CREATED %s" % (target))
81+
print(u"CREATED %s" % (target))
8282
shutil.rmtree(tdir)
8383

8484

mbuild/base.py

Lines changed: 15 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- python -*-
33
#BEGIN_LEGAL
44
#
5-
#Copyright (c) 2022 Intel Corporation
5+
#Copyright (c) 2024 Intel Corporation
66
#
77
# Licensed under the Apache License, Version 2.0 (the "License");
88
# you may not use this file except in compliance with the License.
@@ -25,16 +25,15 @@
2525
import locale
2626

2727
_MBUILD_ENCODING = locale.getpreferredencoding()
28-
def unicode_encoding():
28+
def unicode_encoding() -> str:
2929
return _MBUILD_ENCODING
3030

3131
PY3 = sys.version_info > (3,)
3232
def is_python3():
33-
global PY3
3433
return PY3
3534

3635
_mbuild_verbose_level = 1
37-
def verbose(level=0):
36+
def verbose(level=0) -> bool:
3837
"""Return True if the configured message level supplied is >= the
3938
level arguement
4039
@param level: int
@@ -57,30 +56,26 @@ def get_verbosity():
5756
global _mbuild_verbose_level
5857
return _mbuild_verbose_level
5958

60-
def bracket(s,m=''):
59+
def bracket(s,m='') -> str:
6160
"""add a bracket around s and append m.
6261
@rtype: string
6362
@return: a bracketed string s and a suffixed message m
6463
"""
65-
n = convert2unicode(m)
66-
return u'[{}] {}'.format(s,n)
64+
return u'[{}] {}'.format(s,m)
6765

6866
def error_msg(s,t):
6967
"""Emit '[s] t' to stderr with a newline"""
70-
sys.stderr.write(u2output(bracket(s,t) + "\n"))
68+
print(bracket(s,t))
7169

7270
def msg(s, pad=''):
7371
"""Emit s to stdout with a newline"""
74-
# someone could pass unicode as pad...
75-
sys.stdout.write(u2output(pad))
76-
sys.stdout.write(u2output(s))
77-
sys.stdout.write("\n")
72+
print(pad, end='')
73+
print(s)
7874

7975
def msgn(s, pad=''):
8076
"""Emit s to stdout without a newline"""
81-
# someone could pass unicode as pad...
82-
sys.stdout.write(u2output(pad))
83-
sys.stdout.write(u2output(s))
77+
print(pad, end='')
78+
print(s, end='')
8479

8580
def msgb(s,t='',pad=''):
8681
"""a bracketed string s sent to stdout, followed by a string t"""
@@ -170,12 +165,12 @@ def check_python_version(maj,minor,fix=0):
170165

171166

172167
try:
173-
if check_python_version(2,7) == False:
174-
die("MBUILD error: Need Python version 2.7 or later.")
168+
if check_python_version(3,8) == False:
169+
die("MBUILD error: Need Python version 3.8 or later.")
175170
except:
176-
die("MBUILD error: Need Python version 2.7 or later.")
171+
die("MBUILD error: Need Python version 3.8 or later.")
177172

178-
import platform # requires python 2.3
173+
import platform
179174
_on_mac = False
180175
_on_native_windows = False
181176
_on_windows = False # cygwin or native windows
@@ -227,28 +222,9 @@ def on_mac():
227222

228223
######
229224

230-
# UNICODE SUPPORT FEATURES for PY2/PY3 co-existence
231-
232-
233-
# unicode string constructors
234-
if PY3:
235-
ustr = str
236-
else:
237-
ustr = unicode # converts its argument to a unicode object
238-
239-
# binary data strings constructors
240-
if PY3:
241-
bstr = bytes
242-
else:
243-
bstr = str
244-
245-
def unicode2bytes(us):
246-
"""convert a unicode object (unicode type in python2 or string type in
247-
python3) to bytes suitable for writing to a file."""
248-
return us.encode(unicode_encoding())
249225

250226
def bytes2unicode(bs):
251-
"""Convert a bytes object or a python2 string to unicode"""
227+
"""Convert a bytes object to unicode"""
252228
return bs.decode(unicode_encoding())
253229

254230
def ensure_string(x):
@@ -269,42 +245,8 @@ def ensure_string(x):
269245
def uappend(lst,s):
270246
"""Make sure s is unicode before adding it to the list lst"""
271247
lst.append(ensure_string(s))
272-
273-
def u2output(s):
274-
"""encode unicode string for output to stderr/stdout, but leave bytes
275-
strings as is. Python3 can print unicode to stdout/stderr if
276-
the locale (LANG env var, etc.) supports it. """
277-
# we don't want to call encode for non-unicode (bytes) strings
278-
# because that can generate *decode* errors. In python3 we are set
279-
# since all strings are unicode and thus it is always safe to call
280-
# encode on them. In python2 we must see if the string is unicode
281-
# or bytes.
282-
283-
# python3 does not allow bytes objects as arguments to
284-
# sys.stdout.write() so we just leave stuff as unicode strings in
285-
# python3. If LANG is not C, that works. If LANG is C, wait for
286-
# python 3.7 in mid June 2018. Or just do not use LANG = C!
287-
global PY3
288-
if not PY3:
289-
if isinstance(s,unicode):
290-
return unicode2bytes(s)
291-
return s
292-
293-
def uprint(s):
294-
"""encode unicode for output and print"""
295-
t = u2output(s)
296-
print(t)
297248

298249
def is_stringish(x):
299-
global PY3
300250
if isinstance(x,bytes) or isinstance(x,str):
301251
return True
302-
# python2 has a type unicode, which does not exist by default in
303-
# python3.
304-
if not PY3:
305-
return isinstance(x,unicode)
306252
return False
307-
308-
def convert2unicode(x):
309-
"""convert an arbitrary x to a unicode string"""
310-
return ustr(x)

0 commit comments

Comments
 (0)