MacOS CI upload to pypi fails with a python version error

I used the recommended pypi deployment setting as shown in this page, attempting to build and upload a binary python module build for the macos.

Specifically, the deploy section looks like this

deploy:
  provider: pypi
  username: "__token__"
  distributions: "bdist_wheel"
  password:
    secure: ...

however, when running my CI script, I got the following error

Installing deploy dependencies

Successfully installed dpl-pypi-1.10.16
1 gem installed
2023-08-02 04:32:44 URL:https://bootstrap.pypa.io/get-pip.py [2605506/2605506] -> "-" [1]

ERROR: This script does not work on Python 2.7 The minimum supported Python version is 3.7. Please use https://bootstrap.pypa.io/pip/2.7/get-pip.py instead.
Couldn't install pip, setuptools, twine or wheel.

failed to deploy

I am wondering if anyone has encountered this issue on the default macos image (xcode 9.4).

Another related question is - which folder should the script be run in order for the pypi deployment script to find the binary wheel? currently, the binary wheel is built by cmake and stored under the /pmcx/dist/ folder, where pmcx is the module name, also a folder located inside the top-level of the github repo.

does the deployment script search for the .whl file inside the dist folder? or it assumes other folder names?

here is the build log: Travis CI - Test and Deploy with Confidence

problem solved with the help from a support engineer (Qasim). The solution is to add

  - unlink $(which python)
  - ln -s $(which python3) /usr/local/bin/python
  - unlink $(which pip)
  - ln -s $(which pip3) /usr/local/bin/pip

before the deploy section. it appears that the deploy script can only run on python 3