mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
setup.py: Remove use of "imp" module
Python 3.12 removed the "imp" module, so replace its use in devlib.
This commit is contained in:
parent
b8bf2abf3b
commit
ea4eccf95d
14
setup.py
14
setup.py
@ -13,11 +13,11 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
import imp
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
import types
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
@ -35,15 +35,25 @@ sys.path.insert(0, os.path.join(devlib_dir, 'core'))
|
|||||||
warnings.filterwarnings('ignore', "Unknown distribution option: 'install_requires'")
|
warnings.filterwarnings('ignore', "Unknown distribution option: 'install_requires'")
|
||||||
warnings.filterwarnings('ignore', "Unknown distribution option: 'extras_require'")
|
warnings.filterwarnings('ignore', "Unknown distribution option: 'extras_require'")
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.remove('MANIFEST')
|
os.remove('MANIFEST')
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def _load_path(filepath):
|
||||||
|
# Not a proper import in many, many ways but does the job for really basic
|
||||||
|
# needs
|
||||||
|
with open(filepath) as f:
|
||||||
|
globals_ = dict(__file__=filepath)
|
||||||
|
exec(f.read(), globals_)
|
||||||
|
return types.SimpleNamespace(**globals_)
|
||||||
|
|
||||||
|
|
||||||
vh_path = os.path.join(devlib_dir, 'utils', 'version.py')
|
vh_path = os.path.join(devlib_dir, 'utils', 'version.py')
|
||||||
# can load this, as it does not have any devlib imports
|
# can load this, as it does not have any devlib imports
|
||||||
version_helper = imp.load_source('version_helper', vh_path)
|
version_helper = _load_path(vh_path)
|
||||||
__version__ = version_helper.get_devlib_version()
|
__version__ = version_helper.get_devlib_version()
|
||||||
commit = version_helper.get_commit()
|
commit = version_helper.get_commit()
|
||||||
if commit:
|
if commit:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user