"AttributeError: cython_sources" when installing Docker Compose on ARM images

During testing of multi-arch images for GitLab at gitlab-org/build/CNG#522 (closed), the following error was encountered for Docker compose installation on ARM:

Error
fatal: [multi-arch-test-haproxy-internal-1]: FAILED! => changed=false 
  cmd:
  - /usr/bin/pip3
  - install
  - docker-compose
  msg: |-
    stdout: Collecting docker-compose
      Downloading docker_compose-1.29.2-py2.py3-none-any.whl (114 kB)
         ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 114.8/114.8 KB 3.0 MB/s eta 0:00:00
    Requirement already satisfied: distro<2,>=1.5.0 in /usr/lib/python3/dist-packages (from docker-compose) (1.7.0)
    Collecting websocket-client<1,>=0.32.0
      Downloading websocket_client-0.59.0-py2.py3-none-any.whl (67 kB)
         ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 67.2/67.2 KB 10.8 MB/s eta 0:00:00
    Collecting docopt<1,>=0.6.1
      Downloading docopt-0.6.2.tar.gz (25 kB)
      Preparing metadata (setup.py): started
      Preparing metadata (setup.py): finished with status 'done'
    Collecting dockerpty<1,>=0.4.1
      Downloading dockerpty-0.4.1.tar.gz (13 kB)
      Preparing metadata (setup.py): started
      Preparing metadata (setup.py): finished with status 'done'
    Requirement already satisfied: docker[ssh]>=5 in /usr/local/lib/python3.10/dist-packages (from docker-compose) (5.0.3)
    Collecting PyYAML<6,>=3.10
      Downloading PyYAML-5.4.1.tar.gz (175 kB)
         ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 175.1/175.1 KB 10.2 MB/s eta 0:00:00
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Getting requirements to build wheel: started
      Getting requirements to build wheel: finished with status 'error'
  
    :stderr:   error: subprocess-exited-with-error
  
      × Getting requirements to build wheel did not run successfully.
exit code: 1
      ╰─> [43 lines of output]
          running egg_info
          Traceback (most recent call last):
            File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
              main()
            File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
              json_out['return_val'] = hook(**hook_input['kwargs'])
            File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
              return hook(config_settings)
            File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 162, in get_requires_for_build_wheel
              return self._get_build_requires(
            File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 143, in _get_build_requires
              self.run_setup()
            File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 158, in run_setup
              exec(compile(code, __file__, 'exec'), locals())
            File "setup.py", line 271, in <module>
              setup(
            File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 153, in setup
              return distutils.core.setup(**attrs)
            File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 148, in setup
              return run_commands(dist)
            File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 163, in run_commands
              dist.run_commands()
            File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 967, in run_commands
              self.run_command(cmd)
            File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 986, in run_command
              cmd_obj.run()
            File "/usr/lib/python3/dist-packages/setuptools/command/egg_info.py", line 299, in run
              self.find_sources()
            File "/usr/lib/python3/dist-packages/setuptools/command/egg_info.py", line 306, in find_sources
              mm.run()
            File "/usr/lib/python3/dist-packages/setuptools/command/egg_info.py", line 541, in run
              self.add_defaults()
            File "/usr/lib/python3/dist-packages/setuptools/command/egg_info.py", line 578, in add_defaults
              sdist.add_defaults(self)
            File "/usr/lib/python3/dist-packages/setuptools/_distutils/command/sdist.py", line 228, in add_defaults
              self._add_defaults_ext()
            File "/usr/lib/python3/dist-packages/setuptools/_distutils/command/sdist.py", line 312, in _add_defaults_ext
              self.filelist.extend(build_ext.get_source_files())
            File "setup.py", line 201, in get_source_files
              self.cython_sources(ext.sources, ext)
            File "/usr/lib/python3/dist-packages/setuptools/_distutils/cmd.py", line 103, in __getattr__
              raise AttributeError(attr)
          AttributeError: cython_sources
          [end of output]
  
      note: This error originates from a subprocess, and is likely not a problem with pip.
    error: subprocess-exited-with-error
  
    × Getting requirements to build wheel did not run successfully.
exit code: 1
    ╰─> See above for output.
  
    note: This error originates from a subprocess, and is likely not a problem with pip.

Related dicsussion from other users having installation errors at https://stackoverflow.com/questions/76708329/docker-compose-no-longer-building-image-attributeerror-cython-sources. Dased on discussions there PyYAML>6.0.1 should have fixed the issue however on upgrading the package manually I still had the same error with pip3 install docker-compose.

Running the following workaround on HAproxy internal resolved the issue

pip3 install "cython<3.0.0" wheel && pip3 install pyyaml==5.4.1 --no-build-isolation
pip3 install docker-compose

The goal is to investigate the error further and if there is any change needed for GET.

Environment.tf file
module "gitlab_ref_arch_gcp" {
  source = "../../modules/gitlab_ref_arch_gcp"

  prefix = var.prefix
  project = var.project
  machine_image = "ubuntu-2204-lts-arm64"

  # 3k Hybrid - k8s Node Pools
  webservice_node_pool_count = 2
  webservice_node_pool_machine_type = "t2a-standard-16"

  sidekiq_node_pool_count = 3
  sidekiq_node_pool_machine_type = "t2a-standard-4"

  supporting_node_pool_count = 2
  supporting_node_pool_machine_type = "t2a-standard-2"

  # 3k
  consul_node_count = 3
  consul_machine_type = "t2a-standard-2"

  gitaly_node_count = 3
  gitaly_machine_type = "t2a-standard-4"

  praefect_node_count = 3
  praefect_machine_type = "t2a-standard-2"

  praefect_postgres_node_count = 1
  praefect_postgres_machine_type = "t2a-standard-2"

  haproxy_internal_node_count = 1
  haproxy_internal_machine_type = "t2a-standard-2"

  pgbouncer_node_count = 3
  pgbouncer_machine_type = "t2a-standard-2"

  postgres_node_count = 3
  postgres_machine_type = "t2a-standard-2"

  redis_node_count = 3
  redis_machine_type = "t2a-standard-2"
}

output "gitlab_ref_arch_gcp" {
  value = module.gitlab_ref_arch_gcp
}