<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: PChemGuy</title>
    <description>The latest articles on Forem by PChemGuy (@pchemguy).</description>
    <link>https://forem.com/pchemguy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2779444%2Fe9872e27-67f4-42a3-8d1f-20d136a5f12e.jpg</url>
      <title>Forem: PChemGuy</title>
      <link>https://forem.com/pchemguy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/pchemguy"/>
    <language>en</language>
    <item>
      <title>Installing FFCV and Fastxtend on Windows with Micromamba and MSVC</title>
      <dc:creator>PChemGuy</dc:creator>
      <pubDate>Fri, 24 Oct 2025 13:54:20 +0000</pubDate>
      <link>https://forem.com/pchemguy/installing-ffcv-and-fastxtend-on-windows-with-micromamba-and-msvc-5bkd</link>
      <guid>https://forem.com/pchemguy/installing-ffcv-and-fastxtend-on-windows-with-micromamba-and-msvc-5bkd</guid>
      <description>&lt;h1&gt;
  
  
  🧠 TL;DR
&lt;/h1&gt;

&lt;p&gt;This project automates building and installing &lt;a href="https://github.com/libffcv/ffcv" rel="noopener noreferrer"&gt;FFCV&lt;/a&gt; on Windows using Micromamba and MSVC - no preinstalled Python required.&lt;br&gt;&lt;br&gt;
It also serves as a technical exploration of pip/MSVC integration, dependency resolution, and DLL behavior on Windows.&lt;/p&gt;


&lt;h1&gt;
  
  
  🧭 Summary
&lt;/h1&gt;

&lt;p&gt;This project offers a fully automated Windows build pipeline for the FFCV and Fastxtend libraries.&lt;br&gt;&lt;br&gt;
It rebuilds the missing installation logic for native dependencies and configures a clean, reproducible environment using Micromamba and MS Build Tools - all without requiring a preinstalled Python setup.&lt;/p&gt;

&lt;p&gt;The scripts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bootstrap a self-contained, Conda-compatible environment (&lt;code&gt;Anaconda.bat&lt;/code&gt;);&lt;/li&gt;
&lt;li&gt;Automatically fetch and prepare OpenCV, pthreads, and LibJPEG-Turbo;&lt;/li&gt;
&lt;li&gt;Detect and activate the MSVC toolchain (&lt;code&gt;msbuild.bat&lt;/code&gt;);&lt;/li&gt;
&lt;li&gt;Build and install &lt;strong&gt;FFCV&lt;/strong&gt; and &lt;strong&gt;Fastxtend&lt;/strong&gt; directly from PyPI without developer intervention.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The environment targets Windows 10+ with ANSI-color-capable terminals (set &lt;code&gt;NOCOLOR=1&lt;/code&gt; for graceful fallback).&lt;br&gt;&lt;br&gt;
Its modular design emphasizes transparency, reproducibility, and debuggability - valuable not only for building these specific libraries, but also for understanding how Python’s native compilation process behaves on Windows.&lt;/p&gt;

&lt;p&gt;The repository with build scripts is available here:&lt;br&gt;&lt;br&gt;
👉 &lt;a href="https://github.com/pchemguy/FFCVonWindows" rel="noopener noreferrer"&gt;&lt;strong&gt;FFCVonWindows on GitHub&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;


&lt;h1&gt;
  
  
  💡 Motivation
&lt;/h1&gt;

&lt;p&gt;While FFCV and Fastxtend are powerful tools for high-throughput data loading and fastai integration, their Windows installation process has long been underdocumented and partially broken. The upstream build workflow fails to configure native dependencies and does not properly integrate with the MSVC toolchain.&lt;/p&gt;

&lt;p&gt;This project does not claim to “fix” FFCV building bugs - it simply bypasses defective code and makes the process reproducible and inspectable.&lt;br&gt;&lt;br&gt;
The goal was to create a transparent, script-driven environment setup that others could study, adapt, and improve upon.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Personally, I found that stepping through the build process, even when it fails, often teaches more than a successful one-liner installation.&lt;br&gt;&lt;br&gt;
This project came out of that curiosity - understanding why pip, MSVC, and native libraries fail to cooperate under Windows.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h1&gt;
  
  
  ⚡ Quick Start
&lt;/h1&gt;
&lt;h3&gt;
  
  
  🧭 Prerequisites
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Windows 10 or later
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://visualstudio.microsoft.com/visual-cpp-build-tools" rel="noopener noreferrer"&gt;MS Build Tools&lt;/a&gt; (C++ workload)
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;curl&lt;/code&gt; and &lt;code&gt;tar&lt;/code&gt; available in PATH (default on modern Windows)
&lt;/li&gt;
&lt;li&gt;Internet access
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 Tip: set &lt;code&gt;NOCOLOR=1&lt;/code&gt; if your console does not support ANSI colors.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h3&gt;
  
  
  🚀 Installation
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Clone the repository&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/pchemguy/FFCVonWindows.git
cd AIFFCV
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Run the bootstrapper&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;From a clean &lt;code&gt;cmd.exe&lt;/code&gt; shell (no active Python/Conda environment):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;Anaconda.bat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Verify prerequisites (MSVC, GPU, curl/tar);
&lt;/li&gt;
&lt;li&gt;Download and prepare libraries (OpenCV, pthreads, LibJPEG-Turbo);
&lt;/li&gt;
&lt;li&gt;Download Micromamba;
&lt;/li&gt;
&lt;li&gt;Create the environment;
&lt;/li&gt;
&lt;li&gt;Build and install FFCV and Fastxtend from PyPI.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  🎨 Color Convention
&lt;/h1&gt;

&lt;p&gt;Scripts use consistent, minimal ANSI labels (fallback to plain text with &lt;code&gt;NOCOLOR=1&lt;/code&gt;):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Label&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;[WARN]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Major task or subtask banner&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;[INFO]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Progress or diagnostic output&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;[-OK-]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Successful step&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;[ERROR]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Critical failure (aborts execution)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;MS Build Tools Check - Failed&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5gwm76mtvm5rz7kfz46x.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5gwm76mtvm5rz7kfz46x.jpg" width="800" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MS Build Tools Check - Passed&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd7egyfpewlh8pe32c9ov.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd7egyfpewlh8pe32c9ov.jpg" width="800" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Successful Completion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Farmbs4yuyke09cc67fem.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Farmbs4yuyke09cc67fem.jpg" width="800" height="486"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  🗂️ Project Structure
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;File / Directory&lt;/th&gt;
&lt;th&gt;Role&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Anaconda.bat&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Main entry point – orchestrates bootstrap, download, and installation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;conda_far.bat&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Environment activator – prepares MSVC and dependency paths&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;msbuild.bat&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;MSVC detector and activator&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;libs.bat&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Manages native libraries (OpenCV, pthreads, LibJPEG-Turbo)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;pthreads/activate.bat&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Sets pthreads &lt;code&gt;PATH&lt;/code&gt;, &lt;code&gt;LIB&lt;/code&gt;, &lt;code&gt;INCLUDE&lt;/code&gt;, and &lt;code&gt;LINK&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;opencv/activate.bat&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Sets OpenCV environment variables&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;libjpeg-turbo/activate.bat&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Configures Conda-provided LibJPEG-Turbo&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;Anaconda.yml&lt;/code&gt;, &lt;code&gt;Anaconda_bootstrap.yml&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Conda environment definitions&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  🔬 Deep Dive: Why Windows Builds Fail
&lt;/h1&gt;

&lt;p&gt;Building native Python packages on Windows often fails due to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Missing compiler detection (&lt;code&gt;pip&lt;/code&gt; ignoring your &lt;code&gt;PATH&lt;/code&gt;);
&lt;/li&gt;
&lt;li&gt;Inconsistent dependency paths;
&lt;/li&gt;
&lt;li&gt;MSVC ABI mismatches;
&lt;/li&gt;
&lt;li&gt;Windows DLL search order changes since Python 3.8.
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧩 Key Variables
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Variable&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;INCLUDE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;C/C++ header directories&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;LIB&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Import library directories&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;LINK&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Explicit linker targets (e.g., &lt;code&gt;pthreadVC2.lib&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;PATH&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Runtime DLL directories&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Setting these variables correctly before &lt;code&gt;pip install&lt;/code&gt; prevents setup errors due to broken dependency discovery logic.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚙️ The MSVC Detection Trap
&lt;/h2&gt;

&lt;p&gt;A common frustration is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;error: Microsoft Visual C++ 14.0 or greater is required
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even if &lt;code&gt;cl.exe&lt;/code&gt; is in your PATH, &lt;code&gt;pip&lt;/code&gt; and &lt;code&gt;setuptools&lt;/code&gt; may still fail to detect it.&lt;br&gt;&lt;br&gt;
The fix is to set:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;set "DISTUTILS_USE_SDK=1"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This forces &lt;code&gt;setuptools&lt;/code&gt; to trust the already active MSVC environment instead of rerunning its own fragile discovery logic.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 FFCV-Specific Problem
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;setup.py&lt;/code&gt;’s &lt;code&gt;pkgconfig_windows()&lt;/code&gt; function produces invalid dependency configuration.&lt;br&gt;&lt;br&gt;
Rather than modifying upstream code, the scripts predefine correct values via MSVC environment variables before calling &lt;code&gt;pip&lt;/code&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  🔧 Library Integration Summary
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Library&lt;/th&gt;
&lt;th&gt;Version&lt;/th&gt;
&lt;th&gt;Source&lt;/th&gt;
&lt;th&gt;Integration&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;OpenCV&lt;/td&gt;
&lt;td&gt;4.6.0 (VC15)&lt;/td&gt;
&lt;td&gt;Official Release&lt;/td&gt;
&lt;td&gt;External&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;pthreads-win32&lt;/td&gt;
&lt;td&gt;2.9.1&lt;/td&gt;
&lt;td&gt;Sourceware FTP&lt;/td&gt;
&lt;td&gt;External&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LibJPEG-Turbo&lt;/td&gt;
&lt;td&gt;Conda&lt;/td&gt;
&lt;td&gt;Internal&lt;/td&gt;
&lt;td&gt;Provided by Conda&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code&gt;activate.bat&lt;/code&gt; scripts configure the environment as follows:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Variable&lt;/th&gt;
&lt;th&gt;pthreads&lt;/th&gt;
&lt;th&gt;OpenCV&lt;/th&gt;
&lt;th&gt;LibJPEG-Turbo&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;PATH&lt;/td&gt;
&lt;td&gt;pthreads\dll\x64&lt;/td&gt;
&lt;td&gt;opencv\build\x64\vc15\bin&lt;/td&gt;
&lt;td&gt;Anaconda\Library\bin&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;INCLUDE&lt;/td&gt;
&lt;td&gt;pthreads\include&lt;/td&gt;
&lt;td&gt;opencv\build\include&lt;/td&gt;
&lt;td&gt;Anaconda\Library\include&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LIB&lt;/td&gt;
&lt;td&gt;pthreads\lib\x64&lt;/td&gt;
&lt;td&gt;opencv\build\x64\vc15\lib&lt;/td&gt;
&lt;td&gt;Anaconda\Library\lib&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LINK&lt;/td&gt;
&lt;td&gt;pthreadVC2.lib&lt;/td&gt;
&lt;td&gt;opencv_world460.lib&lt;/td&gt;
&lt;td&gt;turbojpeg.lib&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;


&lt;h1&gt;
  
  
  🧩 Diagnosing "DLL load failed"
&lt;/h1&gt;

&lt;p&gt;After successful build, you may still see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ImportError: DLL load failed while importing _libffcv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This does not always mean &lt;code&gt;_libffcv.pyd&lt;/code&gt; is missing - it might mean its dependencies were not found.&lt;/p&gt;

&lt;p&gt;To debug:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;a href="https://github.com/lucasg/Dependencies" rel="noopener noreferrer"&gt;Dependencies&lt;/a&gt; to identify missing DLLs.&lt;/li&gt;
&lt;li&gt;Use &lt;a href="https://learn.microsoft.com/en-us/sysinternals/downloads/procmon" rel="noopener noreferrer"&gt;ProcMon&lt;/a&gt; to trace real-time DLL lookup behavior.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Since Python 3.8, DLL search order is hardened: it no longer checks arbitrary &lt;code&gt;PATH&lt;/code&gt; entries for extension module dependencies.&lt;br&gt;&lt;br&gt;
To comply with this policy, the final installation step copies required DLLs (e.g., &lt;code&gt;opencv_world460.dll&lt;/code&gt;, &lt;code&gt;pthreadVC2.dll&lt;/code&gt;) into &lt;code&gt;Anaconda\Library\bin&lt;/code&gt;, which Python &lt;em&gt;does&lt;/em&gt; trust.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8e16c3os8ajubku11b62.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8e16c3os8ajubku11b62.jpg" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  📚 References
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/libffcv/ffcv" rel="noopener noreferrer"&gt;FFCV GitHub Repository&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/warner-benjamin/fastxtend" rel="noopener noreferrer"&gt;Fastxtend GitHub Repository&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://visualstudio.microsoft.com/visual-cpp-build-tools" rel="noopener noreferrer"&gt;Microsoft Visual C++ Build Tools&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://stackoverflow.com/a/64262038/17472988" rel="noopener noreferrer"&gt;SO: Installing MS Build Tools for pip&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/pchemguy/Field-Notes/blob/main/03-python-env-windows/README.md" rel="noopener noreferrer"&gt;Field Notes: Bootstrapping Python Environments on Windows&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/pchemguy/Field-Notes/blob/main/05-python-pip-msvc/README.md" rel="noopener noreferrer"&gt;Field Notes: Python pip &amp;amp; MSVC Detection Issues&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/lucasg/Dependencies" rel="noopener noreferrer"&gt;Dependencies&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://learn.microsoft.com/en-us/sysinternals/downloads/procmon" rel="noopener noreferrer"&gt;ProcMon (Sysinternals)&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>windows</category>
      <category>python</category>
      <category>msvc</category>
      <category>ffcv</category>
    </item>
    <item>
      <title>Bootstrapping Python on Windows with Micromamba</title>
      <dc:creator>PChemGuy</dc:creator>
      <pubDate>Wed, 08 Oct 2025 11:58:51 +0000</pubDate>
      <link>https://forem.com/pchemguy/bootstrapping-python-on-windows-with-micromamba-4gm4</link>
      <guid>https://forem.com/pchemguy/bootstrapping-python-on-windows-with-micromamba-4gm4</guid>
      <description>&lt;p&gt;Managing Python on Windows can feel like walking through quicksand. Between global installs, conflicting &lt;code&gt;PATH&lt;/code&gt; entries, and "smart" shell hooks that modify your registry, things get messy fast.&lt;/p&gt;

&lt;p&gt;This post documents a cleaner alternative. The workflow uses a standalone tool, &lt;a href="https://github.com/mamba-org/micromamba-releases" rel="noopener noreferrer"&gt;Micromamba&lt;/a&gt;, and a simple batch script to create Conda-based environments that are lightweight, deterministic, and transparent. It avoids shell initialization, activation hooks, and registry pollution entirely.&lt;/p&gt;

&lt;p&gt;The key insight? Don't let Micromamba handle activation or initialization. Just let it do the one thing it excels at: creating environments.&lt;/p&gt;

&lt;p&gt;The result is a simple &lt;code&gt;cmd.exe&lt;/code&gt; workflow that is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;Explicit:&lt;/strong&gt; Every step is clear and inspectable.&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Isolated:&lt;/strong&gt; No registry edits or global state changes.&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Reproducible:&lt;/strong&gt; Build and tear down identical environments every time.&lt;/li&gt;
&lt;li&gt;✅ &lt;strong&gt;Simple:&lt;/strong&gt; No dependency on PowerShell or complex tooling.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  The Core Idea 💡
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;micromamba.exe&lt;/code&gt; once to bootstrap a self-contained environment. For all other tasks - installing packages, activation, etc. - use the standard &lt;code&gt;conda&lt;/code&gt; or &lt;code&gt;mamba&lt;/code&gt; commands that now live &lt;em&gt;inside&lt;/em&gt; that new environment. No shell hooks, no registry edits, no magic.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem with "Smart" Setups
&lt;/h2&gt;

&lt;p&gt;Typical Python setups on Windows rely on a system-wide interpreter and shell-level magic, which introduces several points of failure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Activation depends on inherited &lt;code&gt;PATH&lt;/code&gt; and &lt;code&gt;PYTHONPATH&lt;/code&gt; variables.&lt;/li&gt;
&lt;li&gt;One wrong entry in your &lt;code&gt;PATH&lt;/code&gt; and scripts can silently use the wrong Python interpreter.&lt;/li&gt;
&lt;li&gt;Shell hooks (&lt;code&gt;shell init&lt;/code&gt;) can persist unwanted settings across sessions by modifying the registry.&lt;/li&gt;
&lt;li&gt;Uninstalling often leaves clutter behind.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My approach flips the model by enforcing a stricter, cleaner separation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No global Python installation.&lt;/li&gt;
&lt;li&gt;Each shell session is linked to at most one environment.&lt;/li&gt;
&lt;li&gt;Never switch environments - use clean shell for activation.&lt;/li&gt;
&lt;li&gt;No persistent shell hooks or &lt;code&gt;AutoRun&lt;/code&gt; modifications.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each environment becomes a sealed unit you can create, activate, and destroy with zero side effects.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Right Tool for the Job
&lt;/h2&gt;

&lt;p&gt;Micromamba is a good tool for this workflow. It is a compact, standalone binary perfect for creating Conda environments without needing an existing Python installation.&lt;/p&gt;

&lt;p&gt;However, its shell integration features can be problematic on Windows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The official &lt;code&gt;install.bat&lt;/code&gt; script is broken.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;micromamba shell init&lt;/code&gt; modifies registry &lt;code&gt;AutoRun&lt;/code&gt; entries, affecting every &lt;code&gt;cmd.exe&lt;/code&gt; session.&lt;/li&gt;
&lt;li&gt;It generates scripts with hard-coded absolute paths, making environments less portable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Environment activation via &lt;code&gt;micromamba.exe activate&lt;/code&gt; failed repeatedly even after calling the &lt;code&gt;mamba_hook.bat&lt;/code&gt; script in accordance with the documentation, because &lt;code&gt;mamba_hook.bat&lt;/code&gt; does not set the &lt;code&gt;MAMBA_ROOT_PREFIX&lt;/code&gt; variable.&lt;/p&gt;

&lt;p&gt;I sidestep these issues entirely. Instead of fighting Micromamba's shell management, I do not use it at all. The bootstrap script calls &lt;code&gt;micromamba.exe&lt;/code&gt; only once to build the environment. After that, I can use the robust tools (Mamba and Conda) installed &lt;em&gt;inside&lt;/em&gt; the environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Bootstrap Workflow
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Bootstrap the Environment
&lt;/h3&gt;

&lt;p&gt;Run the bootstrap script from your terminal to create a new, self-contained environment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;&lt;span class="kd"&gt;Micromamba_bootstrap&lt;/span&gt;.bat &lt;span class="kd"&gt;my_env&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;.12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This single command performs several actions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; Downloads the &lt;code&gt;micromamba.exe&lt;/code&gt; binary if it is missing.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;2.&lt;/strong&gt; Creates a new, self-contained environment with Python, Mamba, and Conda via the &lt;code&gt;create&lt;/code&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;&lt;span class="kd"&gt;micromamba&lt;/span&gt;&lt;span class="err"&gt;.exe&lt;/span&gt; &lt;span class="kd"&gt;create&lt;/span&gt; &lt;span class="na"&gt;-p &lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;%ENV_PREFIX%&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="kd"&gt;python&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;.12 &lt;span class="kd"&gt;mamba&lt;/span&gt; &lt;span class="kd"&gt;conda&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3.&lt;/strong&gt; Activates the new environment once to verify its integrity.&lt;/p&gt;

&lt;p&gt;Your new environment is now ready at a path like &lt;code&gt;DRIVE:\path\to\envs\my_env_3_12&lt;/code&gt;, complete with &lt;code&gt;python.exe&lt;/code&gt;, &lt;code&gt;mamba.exe&lt;/code&gt;, and &lt;code&gt;conda.exe&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Use the Environment
&lt;/h3&gt;

&lt;p&gt;With the environment created, you manage it using the standard Mamba or Conda commands from within its &lt;code&gt;condabin&lt;/code&gt; directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;&lt;span class="k"&gt;call&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;%ENV_PREFIX%&lt;/span&gt;&lt;span class="s2"&gt;\condabin\mamba.bat"&lt;/span&gt; &lt;span class="kd"&gt;activate&lt;/span&gt;
&lt;span class="kd"&gt;mamba&lt;/span&gt; &lt;span class="kd"&gt;install&lt;/span&gt; &lt;span class="kd"&gt;numpy&lt;/span&gt; &lt;span class="kd"&gt;scipy&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No tricky commands, no hidden hooks. Just a clean environment that works as expected.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Words
&lt;/h2&gt;

&lt;p&gt;This approach provides a controlled and reproducible method for bootstrapping Python environments on Windows. By keeping the logic explicit and avoiding shell-level modifications, you get a robust setup that is easy to manage, version, and share. You can find the annotated &lt;code&gt;Micromamba_bootstrap.bat&lt;/code&gt; script and additional information in the &lt;a href="https://github.com/pchemguy/Field-Notes/blob/main/03-python-env-windows/README.md" rel="noopener noreferrer"&gt;project's GitHub repository&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>python</category>
      <category>windows</category>
      <category>mamba</category>
    </item>
    <item>
      <title>How I Still Partition My Drives for Streamlined Backup, Migration, and Failure Recovery</title>
      <dc:creator>PChemGuy</dc:creator>
      <pubDate>Thu, 25 Sep 2025 13:06:03 +0000</pubDate>
      <link>https://forem.com/pchemguy/how-i-still-partition-my-drives-for-streamlined-backup-migration-and-failure-recovery-3pj7</link>
      <guid>https://forem.com/pchemguy/how-i-still-partition-my-drives-for-streamlined-backup-migration-and-failure-recovery-3pj7</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;TL;DR&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A single &lt;code&gt;C:&lt;/code&gt; drive mixes disposable Windows system files with your irreplaceable data, making backups and recovery a nightmare.&lt;/li&gt;
&lt;li&gt;This post presents a strategy for partitioning your drive based on "recovery cost" - separating the &lt;strong&gt;System&lt;/strong&gt;, &lt;strong&gt;Programs&lt;/strong&gt;, and &lt;strong&gt;Data&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;By using portable apps and relocating user data, you can decouple your valuable environment from the volatile OS.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The result:&lt;/strong&gt; A resilient Windows workstation that is significantly easier to back up, migrate, and restore after a failure.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;For years, one of the least exciting parts of getting a new computer was the knowledge that my clean Windows installation was temporary. Inevitably, my single &lt;code&gt;C:&lt;/code&gt; drive would become a tangled mix of critical OS files, installed programs, and irreplaceable personal data. This monolithic structure not only made backups complicated, but it also meant that any serious system issue could put everything at risk.&lt;/p&gt;

&lt;p&gt;After one too many time-consuming system recoveries, I decided to develop a more structured approach. While some of these principles might be adaptable to other operating systems, this guide is rooted in my experience with the Windows ecosystem and is tailored to how it manages its system files, applications, and user data.&lt;/p&gt;

&lt;p&gt;The result is a practical blueprint for partitioning that separates the disposable (the OS) from the essential (your software and data). This method has consistently made my backups, future migrations, and failure recovery scenarios significantly more streamlined. It is a strategy I have refined over several PC builds, and it begins with a simple philosophy...&lt;/p&gt;

&lt;h2&gt;
  
  
  The Core Idea: Not All Files are Created Equal
&lt;/h2&gt;

&lt;p&gt;Before we even think about partitions, we need to start by classifying our files. The system I use is based on a simple question: &lt;strong&gt;What is the "recovery cost"?&lt;/strong&gt; In other words, how much time, effort, and money would it take to get a file back if it were suddenly gone?&lt;/p&gt;

&lt;p&gt;Thinking about common risks - like drive failure, accidental damage, or malware - helps clarify a file's true value. By sorting our files into just three categories based on this recovery cost, we can build a storage strategy that protects what is essential while treating what is replaceable with practical efficiency.&lt;/p&gt;

&lt;h3&gt;
  
  
  Category 1: The Disposable OS (Low Recovery Cost)
&lt;/h3&gt;

&lt;p&gt;Think of this category as everything that comes with a fresh Windows installation. This includes the contents of the &lt;code&gt;C:\Windows&lt;/code&gt; directory, drivers, and essential runtimes like the Microsoft VC++ Redistributables or the .NET Framework.&lt;/p&gt;

&lt;p&gt;If your system becomes corrupted or the drive fails, the fix for these files is straightforward: a clean reinstallation. An even faster method is to restore from a baseline image backup - a snapshot of the partition taken right after the initial setup and configuration. In either case, the principle is the same: because these files are fundamentally replaceable, their only recovery cost is the time it takes to restore them. They are critical for operation, but ultimately disposable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Strategy:&lt;/strong&gt; The goal is to contain the core operating system and its coupled programs to a dedicated system partition. This approach considerably simplifies recovery. If you need to reinstall Windows, you can wipe this partition with the understanding that non-portable applications will also need to be reinstalled, but your truly irreplaceable data and portable apps on &lt;em&gt;other&lt;/em&gt; partitions will remain safe and untouched.&lt;/p&gt;

&lt;h3&gt;
  
  
  Category 2: Your Software Environment (Variable Recovery Cost)
&lt;/h3&gt;

&lt;p&gt;This category covers the third-party applications you install: office suites, developer tools, design software, and so on. While you can always reinstall them from an installer, their true recovery cost is not the software itself, but the time spent re-configuring everything. Lost settings, plugins, and custom layouts are what make rebuilding a system so tedious.&lt;/p&gt;

&lt;p&gt;This is why the distinction between a traditional and a &lt;strong&gt;portable application&lt;/strong&gt; is so important. A portable app keeps all its settings in a single folder, making its backup a simple file copy. A traditional installer, in contrast, often scatters files and settings across the system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Strategy:&lt;/strong&gt; Reduce the recovery cost of your software by favoring portable applications whenever possible. By isolating these portable apps on their own partition, you transform your entire software environment into a simple asset that can be backed up and restored just by copying a single folder.&lt;/p&gt;

&lt;h3&gt;
  
  
  Category 3: Your Irreplaceable Data (High Recovery Cost)
&lt;/h3&gt;

&lt;p&gt;This is the most important category, containing everything you have personally created or configured: documents, project files, source code, photos, and critical application settings. Unlike the operating system or your programs, this data is unique and cannot be reinstalled.&lt;/p&gt;

&lt;p&gt;If these files are lost, there is no website to download them from. The only recovery method is a &lt;strong&gt;current and uncompromised backup&lt;/strong&gt;. Their recovery cost is not measured in minutes or hours, but in the potential for permanent loss.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Strategy:&lt;/strong&gt; This data must be kept on its own dedicated partition, completely isolated from the volatile system partition. It requires its own rigorous backup schedule and should never be stored in default Windows folders on the &lt;code&gt;C:&lt;/code&gt; drive.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Blueprint: Structuring Your Workstation
&lt;/h2&gt;

&lt;p&gt;With our three categories defined, we can now move from theory to practice. This section provides the blueprint for structuring a new workstation, covering application management and, most importantly, how to handle the Windows user profile.&lt;/p&gt;

&lt;p&gt;A logical partition scheme works best on a solid hardware foundation. The common best practice is ideal here: use a fast Solid State Drive (SSD) for the operating system and active work, supplemented by a larger Hard Disk Drive (HDD) for bulk storage like archives and media.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Problem with &lt;code&gt;C:\Program Files&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Windows traditionally installs software to its &lt;code&gt;C:\Program Files&lt;/code&gt; directories. While this approach works, it creates several long-term problems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;System Partition Bloat:&lt;/strong&gt; The system partition may grow unpredictably, complicating backup management and future restorations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Complex Backup Management:&lt;/strong&gt; The baseline image backup of your system, if used, quickly becomes obsolete. As you install new applications to the system partition, the image no longer reflects its current state, forcing you to create larger, more frequent backups to keep it useful.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Poor Portability:&lt;/strong&gt; Applications become tightly coupled to the operating system, making migration to a new computer a time-consuming process of manual reinstallation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Beyond these issues, the default path introduces a security dilemma. The Windows permission model is built for two primary levels: administrative (full control) and user (limited). Installing an application to &lt;code&gt;C:\Program Files&lt;/code&gt; requires full administrative rights - the same level needed to alter critical system files. This requirement often results in installers running with an unnecessarily high level of privilege.&lt;/p&gt;

&lt;p&gt;This security trade-off is another strong reason to favor applications that do not require a formal, administrative installation, which is the foundation of the portable software strategy we will cover next.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Solution: Embracing Portable Software
&lt;/h3&gt;

&lt;p&gt;The solution is to favor portable applications. Unlike a traditional program that scatters settings across the Windows Registry and user profile, a portable app is self-contained. It keeps all of its components - including your custom settings - in a single folder, making it independent of the operating system.&lt;/p&gt;

&lt;p&gt;Managing your software this way provides three major advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Simplified Backups:&lt;/strong&gt; Backing up your entire suite of configured software becomes as simple as copying a single folder or imaging a small, dedicated partition.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Effortless Migration:&lt;/strong&gt; When moving to a new computer, you can often just copy the portable programs folder. Your applications will work immediately, with all settings and plugins intact.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OS Independence:&lt;/strong&gt; If you need to wipe and reinstall Windows, your software environment remains untouched and fully functional, avoiding the entire reinstallation and reconfiguration process.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Adopting this practice is an effective way to lower the recovery cost of your software. It allows you to treat your entire software environment as a manageable, independent asset, much like your personal data.&lt;/p&gt;

&lt;h3&gt;
  
  
  Taming the Windows User Profile
&lt;/h3&gt;

&lt;p&gt;The Windows user profile (usually at &lt;code&gt;C:\Users&lt;/code&gt;) is one of the most critical yet misunderstood parts of the operating system. By default, it is a messy combination of high-value data, temporary files, and essential account settings.&lt;/p&gt;

&lt;p&gt;To build a resilient system, we must understand and separate these components. In Windows, this data comes in two flavors: system-wide data (the templates used for new accounts) and your individual user profile.&lt;/p&gt;

&lt;h4&gt;
  
  
  System-Wide User Data (The Templates)
&lt;/h4&gt;

&lt;p&gt;Before your personal account is even created, Windows establishes several system-wide folders. These folders act as templates and shared spaces, are managed with administrative rights, and change infrequently. They include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;C:\Users\Default&lt;/code&gt;:&lt;/strong&gt; A template profile that is copied to create a new user account.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;C:\Users\Public&lt;/code&gt;:&lt;/strong&gt; A staging area for files that should be accessible to all users on the machine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;C:\ProgramData&lt;/code&gt;:&lt;/strong&gt; A repository for application settings and data that apply to all users.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because these folders are foundational and static, it is best to treat them as part of the operating system. They are perfectly protected by the baseline image backup we discussed earlier and do not require day-to-day management.&lt;/p&gt;

&lt;h4&gt;
  
  
  The Individual User Profile (Your Digital Workspace)
&lt;/h4&gt;

&lt;p&gt;The core of your personal environment is in your user folder (e.g., &lt;code&gt;C:\Users\Username&lt;/code&gt;). This directory is a complex ecosystem, mixing different types of data that each have their own purpose, volatility, and recovery cost. Let us break down its key components.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Core Account Settings (NTUSER.DAT)&lt;/strong&gt; This file is your personal piece of the Windows Registry, storing everything from your desktop wallpaper to application preferences. If this single file becomes corrupted, your account can become unusable, often forcing a full profile rebuild. Think of it as the brain of your user account.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Application Settings (AppData)&lt;/strong&gt; This hidden folder is where your installed programs store their configurations. It is subdivided into &lt;code&gt;Roaming&lt;/code&gt; (for settings that could sync across a network) and &lt;code&gt;Local&lt;/code&gt; (for machine-specific data and caches). Some programs also create settings folders in your profile root (like &lt;code&gt;.vscode&lt;/code&gt; or &lt;code&gt;.gitconfig&lt;/code&gt;). When a program misbehaves, deleting its folder inside &lt;code&gt;AppData&lt;/code&gt; is often the easiest way to fix it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;User-Level Program Installations&lt;/strong&gt; Many modern applications (like Chrome, VS Code, and Discord) now install directly into the &lt;code&gt;AppData&lt;/code&gt; folder. While this method allows installation without administrative rights, it also blurs the line between user settings and program files, which contributes to the bloat of the user profile.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Volatile &amp;amp; High-Volume Folders (Downloads, Temp)&lt;/strong&gt; Folders like &lt;code&gt;Downloads&lt;/code&gt; and &lt;code&gt;Temp&lt;/code&gt; are designed for transient data but often fill up with large files and installers. This data has low value but consumes significant space. Relocating these folders to a secondary HDD is a smart move to free up valuable SSD space and exclude this high-volume, low-value data from your main backups.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Irreplaceable User-Created Files (Documents, Pictures, etc.)&lt;/strong&gt; These folders are the default home for your most valuable data. &lt;strong&gt;This is a serious flaw in the default Windows setup.&lt;/strong&gt; Storing irreplaceable files anywhere within the user profile is a significant risk. All of your personal, user-created files should be better kept on a dedicated &lt;code&gt;Data&lt;/code&gt; partition to isolate them from the OS and allow for targeted, efficient backups.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;A Technical Note on Relocating Folders&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While Windows lets you relocate standard folders (like &lt;code&gt;Documents&lt;/code&gt;) using the &lt;strong&gt;Properties &amp;gt; Location&lt;/strong&gt; tab, some applications may not handle this method correctly. A more robust approach is to use symbolic links (symlinks) and directory junctions. These tools create a pointer from the original location (e.g., &lt;code&gt;C:\Users\Username\Documents&lt;/code&gt;) to the new one on your data partition (e.g., &lt;code&gt;D:\Data\Documents&lt;/code&gt;). This approach ensures full application compatibility while achieving the physical separation we want.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Final Blueprint: A Sample Partition Scheme
&lt;/h2&gt;

&lt;p&gt;Now, let us put all these principles together into a concrete partitioning scheme for a primary SSD. The goal is to create a logical layout that reflects our strategy, providing a resilient and manageable foundation for your workstation.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Partition&lt;/th&gt;
&lt;th&gt;Anticipated Usage (GB)&lt;/th&gt;
&lt;th&gt;Planned Allocation (GB)&lt;/th&gt;
&lt;th&gt;Unallocated Space (GB)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;System&lt;/td&gt;
&lt;td&gt;120&lt;/td&gt;
&lt;td&gt;150&lt;/td&gt;
&lt;td&gt;50&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Portable Programs&lt;/td&gt;
&lt;td&gt;40&lt;/td&gt;
&lt;td&gt;50&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data&lt;/td&gt;
&lt;td&gt;100&lt;/td&gt;
&lt;td&gt;200&lt;/td&gt;
&lt;td&gt;50&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Buffer&lt;/td&gt;
&lt;td&gt;Variable&lt;/td&gt;
&lt;td&gt;Remaining space&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This layout uses four primary partitions, each with a specific role:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;System:&lt;/strong&gt; Houses the Windows OS, non-portable applications, and the core user profiles.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Portable Programs:&lt;/strong&gt; The dedicated home for your portable software environment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data:&lt;/strong&gt; Contains all your active, high-value user files. Relocated folders should point here.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Buffer:&lt;/strong&gt; A flexible partition for large software or for your &lt;code&gt;Downloads&lt;/code&gt; and &lt;code&gt;Temp&lt;/code&gt; folders if a secondary HDD is not available.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;A Note on Unallocated Space and SSD Health&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The "Unallocated Space" in the table is not wasted; it is a strategic reserve. It immediately follows the described partition in the logical disk layout and provides flexibility, allowing you to expand a preceding partition if needed. At the same time, it serves as manual over-provisioning for the SSD. The drive's controller uses these free blocks for maintenance tasks, which improves sustained performance and increases the drive's lifespan, especially under heavy use.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion and Next Steps
&lt;/h2&gt;

&lt;p&gt;Following this blueprint provides a logical and resilient structure for your workstation. By intentionally separating the system, programs, and data, you create a setup that is significantly easier to back up, restore, and migrate.&lt;/p&gt;

&lt;p&gt;What are your thoughts on this partitioning strategy? Do you use a different system? Share your own approach in the comments below! 👇&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>microsoft</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Stop Letting Your Browser Fail Large Downloads</title>
      <dc:creator>PChemGuy</dc:creator>
      <pubDate>Wed, 17 Sep 2025 12:39:37 +0000</pubDate>
      <link>https://forem.com/pchemguy/stop-letting-your-browser-fail-large-downloads-lk3</link>
      <guid>https://forem.com/pchemguy/stop-letting-your-browser-fail-large-downloads-lk3</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;TL;DR&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Modern browsers are unreliable for large file downloads from dynamic or expiring links because they cannot properly resume failures. This note provides two Windows batch scripts (for wget and aria2) that solve this problem. Using session information (HTTP headers and cookies) extracted from your browser's dev tools, these scripts can robustly resume downloads, even if the link needs to be refreshed.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Modern web browsers often fail to robustly download large files (e.g., OS images) over unreliable or slow connections. There are two primary reasons for this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Limited Resume Capabilities:&lt;/strong&gt; Standard browser downloaders often cannot properly resume a failed download, deleting the partial file and forcing a restart.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dynamic &amp;amp; Expiring Links:&lt;/strong&gt; Many services no longer provide direct download links. Instead, a browser must follow HTTP redirects to get a final link. This link is often temporary, containing a short-lived token (common on GitHub) or requiring a captcha challenge. When the token expires, the browser's attempt to resume from the invalid URL fails permanently.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The lack of a robust, general-purpose download manager in browsers has led to vendors providing single-purpose "stub" installers as a workaround (consider the standard Google Chrome installer). While peer-to-peer protocols like Torrent are a robust solution, their adoption for direct software distribution remains limited.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution: Scripted Command-Line Downloaders
&lt;/h2&gt;

&lt;p&gt;The most reliable solution is to use a powerful command-line tool like the classic &lt;strong&gt;wget&lt;/strong&gt; or the more modern &lt;strong&gt;aria2&lt;/strong&gt;. By wrapping them in a simple script, you can gain full control over the download process.&lt;/p&gt;

&lt;p&gt;The specific solutions presented here are Windows batch scripts (.bat), but the core concepts and tool commands can be readily adapted to other operating systems and shell languages (like bash on Linux or macOS).&lt;/p&gt;

&lt;p&gt;Both solutions rely on the same core concept: continuing a session initiated in the browser. The script achieves this goal by providing the command-line tool with the same HTTP headers (like User-Agent and cookies) that the browser used, giving the server the necessary context to recognize the request as a valid continuation of browser-based activity.&lt;/p&gt;




&lt;h2&gt;
  
  
  WGET Script
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;wget&lt;/code&gt; is a classic and highly reliable tool. Its built-in retry mechanism is excellent for temporary network errors, but it requires an external script loop to handle expiring links, where the entire download command must be re-initiated.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup and Usage
&lt;/h3&gt;

&lt;p&gt;You will need two files: the script &lt;strong&gt;&lt;a href="https://github.com/pchemguy/Field-Notes/blob/main/01-improving-large-file-downloads/download_wget.bat" rel="noopener noreferrer"&gt;download_wget.bat&lt;/a&gt;&lt;/strong&gt; and a &lt;em&gt;headers.txt&lt;/em&gt; file (see example &lt;a href="https://github.com/pchemguy/Field-Notes/blob/main/01-improving-large-file-downloads/headers.txt" rel="noopener noreferrer"&gt;here&lt;/a&gt;).&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Locate wget:&lt;/strong&gt; The script is configured for "C:/dev/msys64/usr/bin/wget.exe". You should update this path or add wget to your system's PATH.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Create headers.txt:&lt;/strong&gt; Use your browser's developer tools (F12) to inspect the network request for your download and copy the main request headers (except for the cookie) into &lt;em&gt;headers.txt&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Configure download_wget.bat:&lt;/strong&gt; Open the script and edit the configuration section with your URL, COOKIE_STRING, and OUTPUT_FILE.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run the Script:&lt;/strong&gt; Execute &lt;em&gt;download_wget.bat&lt;/em&gt; to begin.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note on Special Characters for Windows Batch Scripts:&lt;/strong&gt; Remember to escape percent signs (&lt;code&gt;%&lt;/code&gt; becomes &lt;code&gt;%%&lt;/code&gt;) in the URL or COOKIE_STRING variables. Because both URL and COOKIE_STRING are quoted, the ampersand should &lt;em&gt;not&lt;/em&gt; be escaped (do not change &lt;code&gt;&amp;amp;&lt;/code&gt; to &lt;code&gt;^&amp;amp;&lt;/code&gt;).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Execution Logic
&lt;/h3&gt;

&lt;p&gt;The wget script  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Parses the &lt;em&gt;headers.txt&lt;/em&gt; file, converting each line into a &lt;code&gt;--header&lt;/code&gt; argument for wget.&lt;/li&gt;
&lt;li&gt;Checks for cookie information, prioritizing the COOKIE_STRING variable over a COOKIE_FILE if both are present.&lt;/li&gt;
&lt;li&gt;Executes a &lt;code&gt;goto&lt;/code&gt; loop controlled by MAX_WGET_EXT_RETRIES. If wget fails because a link has expired, the loop re-runs the command, allowing it to get a fresh link from the original URL and then resume the download.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The core command placed within the &lt;code&gt;goto&lt;/code&gt; loop is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"%WGET%" -c --max-redirect 100 --content-disposition --tries=0 --timeout=20 ^
         %LOAD_COOKIES%    ^
         %WGET_HEADERS%    ^
         %OUTPUT_DOCUMENT% ^
         "%URL%"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;-c&lt;/td&gt;
&lt;td&gt;Resumes a partially downloaded file.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--max-redirect 100&lt;/td&gt;
&lt;td&gt;Follows up to 100 HTTP redirects.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--content-disposition&lt;/td&gt;
&lt;td&gt;Uses the server-suggested filename if OUTPUT_FILE is not set.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--tries=0&lt;/td&gt;
&lt;td&gt;Sets internal retries to infinite for temporary network issues.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--timeout=20&lt;/td&gt;
&lt;td&gt;Sets a 20-second connection timeout.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Aria2 Script
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/aria2/aria2" rel="noopener noreferrer"&gt;aria2&lt;/a&gt;&lt;/strong&gt; is a more modern downloader that supports multi-connection downloads from one or multiple sources for significantly faster speeds. Its error handling is more advanced, meaning an external script loop is generally not necessary.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup and Usage
&lt;/h3&gt;

&lt;p&gt;You will need &lt;strong&gt;&lt;a href="https://github.com/pchemguy/Field-Notes/blob/main/01-improving-large-file-downloads/download_aria2.bat" rel="noopener noreferrer"&gt;download_aria2.bat&lt;/a&gt;&lt;/strong&gt; and the same &lt;em&gt;headers.txt&lt;/em&gt; file. The setup steps are identical to wget: locate the executable, create &lt;em&gt;headers.txt&lt;/em&gt;, and configure the script's variables.&lt;/p&gt;

&lt;h3&gt;
  
  
  Execution Logic
&lt;/h3&gt;

&lt;p&gt;The aria2 script is simpler as it does not require an external loop. After parsing headers and cookies, it executes a single, powerful command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"%ARIA2%" -c --max-tries=20 --timeout=20 --file-allocation=none ^
          --max-connection-per-server=%THREAD_COUNT% --split=%THREAD_COUNT% ^
          %LOAD_COOKIES%    ^
          %ARIA2_HEADERS%   ^
          %OUTPUT_DOCUMENT% ^
          "%URL%"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;-c&lt;/td&gt;
&lt;td&gt;Resumes a partially downloaded file.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--file-allocation=none&lt;/td&gt;
&lt;td&gt;Do not pre-allocate file space.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--max-connection-per-server=%THREAD_COUNT%&lt;/td&gt;
&lt;td&gt;Uses &lt;em&gt;up to&lt;/em&gt; %THREAD_COUNT% connections &lt;em&gt;per&lt;/em&gt; server to accelerate the download.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--split=%THREAD_COUNT%&lt;/td&gt;
&lt;td&gt;Uses %THREAD_COUNT% connections (for &lt;em&gt;all&lt;/em&gt; servers) to download in parallel.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--max-tries=20&lt;/td&gt;
&lt;td&gt;Retries at most 20 times on errors.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--timeout=20&lt;/td&gt;
&lt;td&gt;Sets a 20-second connection timeout.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Note that due to the limitations of the batch scripting environment and special character handling details, the script would need to be adjusted if more than one source URL is provided.&lt;/p&gt;




&lt;h2&gt;
  
  
  Handling Captcha Challenges
&lt;/h2&gt;

&lt;p&gt;For downloads protected by a captcha, full automation is not possible with either tool.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Solve the captcha in your browser and start the download.&lt;/li&gt;
&lt;li&gt;Immediately cancel the download.&lt;/li&gt;
&lt;li&gt;Use the browser's developer tools to get the newly generated URL and cookie string.&lt;/li&gt;
&lt;li&gt;Update these values in the script configuration, paying attention to special characters.&lt;/li&gt;
&lt;li&gt;Run the script.&lt;/li&gt;
&lt;li&gt;When the link expires and the script fails, the partial file is kept safe.&lt;/li&gt;
&lt;li&gt;Repeat the process from &lt;strong&gt;Step 3&lt;/strong&gt; to get a new link/cookie, update the script, and run it again. The tool will resume where it left off.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>windows</category>
      <category>downloads</category>
      <category>batch</category>
    </item>
  </channel>
</rss>
