It Works on My Machine: Writing Python Code for Any Environment
summary
Case studies from the AWS CLI show concrete fixes: use six and a project-level compat module to import renamed APIs, vendor or conditionally depend on backports for Python 2.6, normalize path separators for Windows vs POSIX, and convert incoming bytes to Unicode early. Tests run under tox and CI (Travis/Jenkins) across Python 2.6–3.x and OSes. A surprising bug is corrupted uploads on Windows solved by funneling writes through a single IO thread instead of concurrent seeks.
AI-written summary · about
chapters (30)
- 0:00Intro
- 0:23Familiar?
- 0:56Why does compatibility matter?
- 1:59What will be covered?
- 2:26The Example Application AWS Command Line Interface
- 3:41Renaming: Intro
- 4:34No six compatibility
- 6:09String Types: Intro
- 6:55Python String Types
- 7:33Python 2
- 10:17Limitations: Intro
- 10:31Backports
- 12:50File Handling: Intro
- 14:05Problem - Issues when concurrently writing to the same file on Windows
- 14:57Lessons Learned
- 15:50File Paths: Intro aws s3 cp --recursive
- 16:30Example: Linux
- 16:53Example: Windows
- 18:22Functionality: Intro
- 20:28Solution (cont.)
- 22:29Writing: Intro
- 23:17Dependencies
- 23:57Best Practices: Inputs
- 25:05Best Practices: File Handling
- 26:23Best Practices: Env. Specific
- 27:26Best Practices: Main Points
- 28:00Running: Intro
- 28:38Running: Example
- 29:20Running: Systems
- 30:06Major Points
related talks
43mPython 3: ten years later
45mWriting Python 2/3 compatible code
40mA Few Python Tips
41mEcosystem for Reliable Python Programming
58m Python on Windows, the State of the Art
30mAn Admin's Cornucopia - Python Is More Than Just A Better Bash
42mWhy is Windows so broken? and what to do about it
51mBuilding useful project utils in Python
