Skip to content

Commit

Permalink
Add python source build
Browse files Browse the repository at this point in the history
  • Loading branch information
SonicField committed Oct 15, 2024
1 parent 8ba1992 commit 2f5011a
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions .github/actions/build-python-from-source/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,21 @@ runs:
elif [ "${{ runner.os }}" = "macOS" ]; then
brew install openssl readline sqlite3 xz
elif [ "${{ runner.os }}" = "Windows" ]; then
choco install openssl
choco install --quiet openssl
fi
# Do not rebuild python if we do not need to.
- name: Cache the entire checkout and build.
if: "!contains(inputs.python-version, 'alpha')"
uses: actions/cache@v3
id: cpython-cache
with:
path: ${github.workspace}/cpython
key: ${{ runner.os }}-python-${{ inputs.python-version }}-${{ inputs.nogil }}

# Clone the Python source code from the official repository and checkout the specified version.
- name: Checkout Python source code
if: steps.cpython-cache.outputs.cache-hit != 'true'
shell: bash
run: |
git clone https://github.com/python/cpython.git
Expand All @@ -48,21 +58,9 @@ runs:
git checkout ${{ inputs.python-version }}
fi
# Do not rebuild python is we do not need to.
- name: Cache Python built artifacts
if: "!contains(inputs.python-version, 'alpha')"
uses: actions/cache@v3
id: python-cache
with:
path: |
/usr/local/python-${{ inputs.python-version }} (Linux)
${github.workspace}/Python/${{ inputs.python-version }} (Windows)
/usr/local/python-${{ inputs.python-version }} (macOS)
key: ${{ runner.os }}-python-${{ inputs.python-version }}-${{ inputs.nogil }}

# Configure and build Python based on the OS and the 'nogil' input.
- name: Configure and build Python
if: steps.python-cache.outputs.cache-hit != 'true'
if: steps.cpython-cache.outputs.cache-hit != 'true'
shell: bash
run: |
# Do some output to help debugging if things go wrong/
Expand All @@ -89,25 +87,25 @@ runs:
# Use the build script provided for Windows in the Python source.
set CFLAGS=/Ox
set CXXFLAGS=/Ox
./PCbuild/build.bat -e -d $configure_options
./PCbuild/build.bat -e $configure_options
fi
# Install the built Python version.
- name: Install Python
if: steps.python-cache.outputs.cache-hit != 'true'
if: steps.cpython-cache.outputs.cache-hit != 'true'
shell: bash
run: |
cd cpython
if [ "${{ runner.os }}" != "Windows" ]; then
sudo make install
else
# Get the current working directory
cwd=$(pwd)
# Create the installation directory
mkdir -p "${cwd}/Python/${{ inputs.python-version }}"
# Copy the Python executable and necessary DLLs to the installation directory
cp PCbuild/amd64/*.exe "${cwd}/Python/${{ inputs.python-version }}"
cp PCbuild/amd64/*.dll "${cwd}/Python/${{ inputs.python-version }}"
#else
# # Get the current working directory
# cwd=$(pwd)
# # Create the installation directory
# mkdir -p "${cwd}/Python/${{ inputs.python-version }}"
# # Copy the Python executable and necessary DLLs to the installation directory
# cp PCbuild/amd64/*.exe "${cwd}/Python/${{ inputs.python-version }}"
# cp PCbuild/amd64/*.dll "${cwd}/Python/${{ inputs.python-version }}"
fi
# Make sure we use our version of python.
Expand All @@ -120,7 +118,8 @@ runs:
# Find the Python executable and set LOCAL_PYTHON
cd cpython
cwd=$(pwd)
LOCAL_PYTHON=$(find "${cwd}/Python/${{ inputs.python-version }}" -name "python3*_d.exe")
# LOCAL_PYTHON=$(find "${cwd}/Python/${{ inputs.python-version }}" -name "python3*_d.exe")
LOCAL_PYTHON=$(find "${cwd}/PCbuild/amd64/${{ inputs.python-version }}" -name "python3*.exe")
echo "LOCAL_PYTHON=${LOCAL_PYTHON}" >> $GITHUB_ENV
fi
Expand Down

0 comments on commit 2f5011a

Please sign in to comment.