Skip to content

Commit

Permalink
fix(build): update mojo files for python 3.12
Browse files Browse the repository at this point in the history
This allows compilation of the mojo project with python 3.12.
* Replace `imp` module with the newer `importlib.util` module that was added in 3.4.
* This allowed for successful builds on my test machines (windows and linux),
* Some reports say that `setuptools` or `distutils` was still missing and is needed to build the natives, I wasn't able to replicate this.

Note: setuptools can can installed as follows: `pip install setuptools` or `py -3 -m pip install setuptools`
  • Loading branch information
thorium-cfx committed Nov 3, 2023
1 parent 4dc24a9 commit 6a02b9a
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 22 deletions.
Expand Up @@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import imp
import importlib
import os.path
import sys

Expand All @@ -17,7 +17,7 @@ def _GetDirAbove(dirname):
return path

try:
imp.find_module("ply")
importlib.util.find_spec("ply")
except ImportError:
sys.path.append(os.path.join(_GetDirAbove("mojo"), "third_party"))
from ply.lex import TOKEN
Expand Down
Expand Up @@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import imp
import importlib
import os.path
import shutil
import sys
Expand All @@ -20,7 +20,7 @@ def _GetDirAbove(dirname):
return path

try:
imp.find_module("mojom")
importlib.util.find_spec("mojom")
except ImportError:
sys.path.append(os.path.join(_GetDirAbove("pylib"), "pylib"))
from mojom import fileutil
Expand Down
Expand Up @@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import imp
import importlib
import os.path
import sys
import unittest
Expand All @@ -18,7 +18,7 @@ def _GetDirAbove(dirname):
return path

try:
imp.find_module("mojom")
importlib.util.find_spec("mojom")
except ImportError:
sys.path.append(os.path.join(_GetDirAbove("pylib"), "pylib"))
from mojom.generate import data
Expand Down
Expand Up @@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import imp
import importlib
import os.path
import sys
import unittest
Expand All @@ -18,7 +18,7 @@ def _GetDirAbove(dirname):
return path

try:
imp.find_module("mojom")
importlib.util.find_spec("mojom")
except ImportError:
sys.path.append(os.path.join(_GetDirAbove("pylib"), "pylib"))
from mojom.generate import generator
Expand Down
Expand Up @@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import imp
import importlib
import os.path
import sys
import unittest
Expand All @@ -18,7 +18,7 @@ def _GetDirAbove(dirname):
return path

try:
imp.find_module("mojom")
importlib.util.find_spec("mojom")
except ImportError:
sys.path.append(os.path.join(_GetDirAbove("pylib"), "pylib"))
from mojom.generate import module as mojom
Expand Down
Expand Up @@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import imp
import importlib
import os.path
import sys
import unittest
Expand All @@ -20,7 +20,7 @@ def _GetDirAbove(dirname):


try:
imp.find_module("mojom")
importlib.util.find_spec("mojom")
except ImportError:
sys.path.append(os.path.join(_GetDirAbove("pylib"), "pylib"))
from mojom.generate import pack
Expand Down
Expand Up @@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import imp
import importlib
import os.path
import sys
import unittest
Expand All @@ -18,7 +18,7 @@ def _GetDirAbove(dirname):
return path

try:
imp.find_module("mojom")
importlib.util.find_spec("mojom")
except ImportError:
sys.path.append(os.path.join(_GetDirAbove("pylib"), "pylib"))
import mojom.parse.ast as ast
Expand Down
Expand Up @@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import imp
import importlib
import os
import sys
import unittest
Expand All @@ -20,7 +20,7 @@ def _GetDirAbove(dirname):


try:
imp.find_module('mojom')
importlib.util.find_spec('mojom')
except ImportError:
sys.path.append(os.path.join(_GetDirAbove('pylib'), 'pylib'))
import mojom.parse.ast as ast
Expand Down
Expand Up @@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import imp
import importlib
import os.path
import sys
import unittest
Expand All @@ -21,7 +21,7 @@ def _GetDirAbove(dirname):
from ply import lex

try:
imp.find_module("mojom")
importlib.util.find_spec("mojom")
except ImportError:
sys.path.append(os.path.join(_GetDirAbove("pylib"), "pylib"))
import mojom.parse.lexer
Expand Down
Expand Up @@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import imp
import importlib
import os.path
import sys
import unittest
Expand All @@ -18,7 +18,7 @@ def _GetDirAbove(dirname):
return path

try:
imp.find_module("mojom")
importlib.util.find_spec("mojom")
except ImportError:
sys.path.append(os.path.join(_GetDirAbove("pylib"), "pylib"))
import mojom.parse.ast as ast
Expand Down
Expand Up @@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import imp
import importlib
import os.path
import sys
import unittest
Expand All @@ -18,7 +18,7 @@ def _GetDirAbove(dirname):
return path

try:
imp.find_module("mojom")
importlib.util.find_spec("mojom")
except ImportError:
sys.path.append(os.path.join(_GetDirAbove("pylib"), "pylib"))
from mojom.parse import ast
Expand Down

0 comments on commit 6a02b9a

Please sign in to comment.