Example of Python Installation Using C2 Platform's Windows Role

An example of how to install Python 3.13.3 using the C2 Platform’s WinCore collection.

Projects: c2platform/phx/ansible, c2platform.core


Python Virtual Environment using venv

Create:

python -m venv C:\Users\vagrant\venv\ansible

Activate in PowerShell session

C:\Users\vagrant\venv\ansible\Scripts\Activate.ps1
Show me
Microsoft Windows [Version 10.0.20348.707]
(c) Microsoft Corporation. All rights reserved.

C:\Users\vagrant>powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\Users\vagrant> python -m venv C:\Users\vagrant\venv\ansible
PS C:\Users\vagrant> C:\Users\vagrant\venv\ansible\Scripts\Activate.ps1
(ansible) PS C:\Users\vagrant>

Activate in Git Bash

source /c/Users/vagrant/venv/ansible/Scripts/activate
Show me
vagrant@PXD-WIN1 MINGW64 ~
$ ls /c/Users/vagrant/venv/ansible/Scripts/activate
/c/Users/vagrant/venv/ansible/Scripts/activate

Note: directory venv does not need to exist, it is created

source /bin/activate

Activate

Option 1

---
px_git_path: "{{ px_apps_dir }}/Git"
win_resources:
  1_git:
    - name: Download Git
      type: win_get_url
      url: https://www.onknows.com/software/phx/Git-2.49.0-64-bit.exe
      dest: "{{ px_download_temp_dir['path'] }}/Git-2.49.0-64-bit.exe"
      checksum: 307be569ffbfe95de3574874d56494ab
      checksum_algorithm: md5
    - name: Install Git
      type: win_package
      path: "{{ px_download_temp_dir['path'] }}/Git-2.49.0-64-bit.exe"
      arguments: >-
        /VERYSILENT /SUPPRESSMSGBOXES /NORESTART
        /NOCANCEL /SP- /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS
        /LOG="{{ px_apps_dir }}/git-install.log"
        /DIR="{{ px_git_path }}"
        /COMPONENTS="icons,ext\reg\shellhere,assoc,assoc_sh"        
      creates_path: "{{ px_git_path }}"

Option 2

Using

C:> \Scripts\activate.bat

PowerShell

PS C:> \Scripts\Activate.ps1

Additional Information



Last modified May 26, 2025: phx python and python venv PHX-6 (0e3904b)