diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index 62cf16296..78f73c5fa 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -40,6 +40,7 @@ from ..mesonlib import (
     ExecutableSerialisation
 )
 
+from ..linkers.linkers import AIXDynamicLinker
 if T.TYPE_CHECKING:
     from .._typing import ImmutableListProtocol
     from ..arglist import CompilerArgs
@@ -339,6 +340,10 @@ class Backend:
         # On all other platforms, we link to the library directly.
         if isinstance(target, build.SharedLibrary):
             link_lib = target.get_import_filename() or target.get_filename()
+            # In AIX, if we archive .so, the blibpath must link to archived shared library otherwise to the .so file.
+            if mesonlib.is_aix():
+                if target.aix_so_archive == True and not isinstance(target, build.SharedModule):
+                    link_lib = AIXDynamicLinker.get_archive_name(self, link_lib)
             return os.path.join(self.get_target_dir(target), link_lib)
         elif isinstance(target, build.StaticLibrary):
             return os.path.join(self.get_target_dir(target), target.get_filename())
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 03f33d613..44504e9fb 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1057,9 +1057,10 @@ class NinjaBackend(backends.Backend):
         self.add_build(elem)
         #In AIX, we archive shared libraries. If the instance is a shared library, we add a command to archive the shared library
         #object and create the build element.
-        if isinstance(target, build.SharedLibrary) and self.environment.machines[target.for_machine].is_aix():
-            elem = NinjaBuildElement(self.all_outputs, linker.get_archive_name(outname), 'AIX_LINKER', [outname])
-            self.add_build(elem)
+        if isinstance(target, build.SharedLibrary) and not isinstance(target, build.SharedModule) and self.environment.machines[target.for_machine].is_aix():
+            if target.aix_so_archive == True:
+                elem = NinjaBuildElement(self.all_outputs, linker.get_archive_name(outname), 'AIX_LINKER', [outname])
+                self.add_build(elem)
 
     def should_use_dyndeps_for_target(self, target: 'build.BuildTarget') -> bool:
         if mesonlib.version_compare(self.ninja_version, '<1.10.0'):
@@ -2391,13 +2392,13 @@ class NinjaBackend(backends.Backend):
 
                 options = self._rsp_options(compiler)
                 self.add_rule(NinjaRule(rule, command, args, description, **options, extra=pool))
-            if self.environment.machines[for_machine].is_aix():
-                rule = 'AIX_LINKER{}'.format(self.get_rule_suffix(for_machine))
-                description = 'Archiving AIX shared library'
-                cmdlist = compiler.get_command_to_archive_shlib()
-                args = []
-                options = {}
-                self.add_rule(NinjaRule(rule, cmdlist, args, description, **options, extra=None))
+        if self.environment.machines[for_machine].is_aix():
+            rule = 'AIX_LINKER{}'.format(self.get_rule_suffix(for_machine))
+            description = 'Archiving AIX shared library'
+            cmdlist = compiler.get_command_to_archive_shlib()
+            args = []
+            options = {}
+            self.add_rule(NinjaRule(rule, cmdlist, args, description, **options, extra=None))
 
         args = self.environment.get_build_command() + \
             ['--internal',
@@ -3494,11 +3495,6 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
         else:
             dependencies = target.get_dependencies()
         internal = self.build_target_link_arguments(linker, dependencies)
-        #In AIX since shared libraries are archived the dependencies must
-        #depend on .a file with the .so and not directly on the .so file.
-        if self.environment.machines[target.for_machine].is_aix():
-            for i, val in enumerate(internal):
-                internal[i] = linker.get_archive_name(val)
         commands += internal
         # Only non-static built targets need link args and link dependencies
         if not isinstance(target, build.StaticLibrary):
@@ -3703,8 +3699,8 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
                 # Add the first output of each target to the 'all' target so that
                 # they are all built
                 #Add archive file if shared library in AIX for build all.
-                if isinstance(t, build.SharedLibrary):
-                    if self.environment.machines[t.for_machine].is_aix():
+                if isinstance(t, build.SharedLibrary) and not isinstance(t, build.SharedModule):
+                    if self.environment.machines[t.for_machine].is_aix() and t.aix_so_archive == True:
                         linker, stdlib_args = self.determine_linker_and_stdlib_args(t)
                         t.get_outputs()[0] = linker.get_archive_name(t.get_outputs()[0])
                 targetlist.append(os.path.join(self.get_target_dir(t), t.get_outputs()[0]))
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 8fed78531..cac5632a7 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -2117,6 +2117,9 @@ class SharedLibrary(BuildTarget):
 
     typename = 'shared library'
 
+    # Used by AIX to decide whether to archive shared library or not.
+    aix_so_archive = True
+
     def __init__(
             self,
             name: str,
@@ -2140,6 +2143,7 @@ class SharedLibrary(BuildTarget):
         self.debug_filename = None
         # Use by the pkgconfig module
         self.shared_library_only = False
+
         super().__init__(name, subdir, subproject, for_machine, sources, structured_sources, objects,
                          environment, compilers, kwargs)
 
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py
index 0d397b23e..30f7de119 100644
--- a/mesonbuild/minstall.py
+++ b/mesonbuild/minstall.py
@@ -716,7 +716,7 @@ class Installer:
             # install the archive in which the shared library exists. The below code does the same.
             # We change the .so files having lt_version or so_version to archive file install.
             if is_aix():
-                if '.so' in t.fname:
+                if not os.path.exists(t.fname) and '.so' in t.fname:
                     t.fname = re.sub('[.][a]([.]?([0-9]+))*([.]?([a-z]+))*', '.a', t.fname.replace('.so', '.a'))
             if not self.should_install(t):
                 continue
--- ./mesonbuild/modules/python.py_orig	2023-10-13 01:35:02.796195708 +0000
+++ ./mesonbuild/modules/python.py	2023-10-13 01:37:21.932328009 +0000
@@ -20,7 +20,7 @@
 from .. import mesonlib
 from .. import mlog
 from ..coredata import UserFeatureOption
-from ..build import known_shmod_kwargs
+from ..build import known_shmod_kwargs, SharedLibrary
 from ..dependencies import NotFoundDependency
 from ..dependencies.detect import get_dep_identifier, find_external_dependency
 from ..dependencies.python import BasicPythonExternalProgram, python_factory, _PythonDependencyBase
@@ -173,6 +173,11 @@
                 (self.is_pypy or mesonlib.version_compare(self.version, '>=3.9')):
             kwargs['gnu_symbol_visibility'] = 'inlineshidden'
 
+        # In AIX if we are using a extension module, this means a python module does not
+        # require a archived shared library due to dlopen mechanism of python. Hence do not archive.
+        if mesonlib.is_aix():
+            SharedLibrary.aix_so_archive = False
+
         return self.interpreter.func_shared_module(None, args, kwargs)
 
     def _dependency_method_impl(self, kwargs: TYPE_kwargs) -> Dependency:
--- ./mesonbuild/compilers/compilers.py_orig	2023-11-09 03:22:43.427185097 +0000
+++ ./mesonbuild/compilers/compilers.py	2023-11-09 03:23:22.197196644 +0000
@@ -945,6 +945,8 @@
         return self.linker.get_archive_name(filename)
 
     def get_command_to_archive_shlib(self) -> T.List[str]:
+        if not self.linker:
+            return []
         return self.linker.get_command_to_archive_shlib()
 
     def thread_flags(self, env: 'Environment') -> T.List[str]:
