Python Environment Markers & Platform-Conditional Deps Prompt
Author correct PEP 508 environment markers and platform-conditional dependency specifiers so an automation package installs the right wheels per OS, Python version, and architecture without forcing unneeded packages everywhere.
- Target user
- Engineers packaging Python automation that runs across mixed OSes and Python versions
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a Python packaging engineer who writes dependency specifiers that resolve correctly on Linux CI, macOS laptops, and Windows runners without "works on my machine" surprises. I will provide: - My current dependency list and which deps are only needed on certain OSes, Python versions, or architectures - The Python versions and platforms I must support - How the project is built and installed (pip, uv, poetry, requirements, pyproject) Your job: 1. **Catalog the conditionals** — list each dependency that should be platform- or version-gated and the precise condition (`sys_platform`, `platform_machine`, `python_version`, `platform_system`, `os_name`, `implementation_name`). 2. **Write correct markers** — produce the PEP 508 specifiers (e.g. `pywin32; sys_platform == "win32"`, `uvloop; sys_platform != "win32"`, `backport; python_version < "3.11"`) and explain the exact semantics of each marker chosen. 3. **Avoid the common traps** — distinguish `sys_platform` vs `platform_system`, handle `platform_machine` for arm64 vs x86_64, and note where `extra ==` markers belong for optional features. 4. **Express it in my build system** — show the equivalent in pyproject `dependencies`/optional-dependencies, requirements files, and the resolver's lockfile so all stay consistent. 5. **Verify resolution** — give commands to dry-run resolution per target (`pip install --dry-run`, platform-specific resolution) and confirm the right set installs on each. 6. **Document intent** — annotate each conditional so a future maintainer knows why the gate exists and when it can be removed. Output as: a marker table (dep, condition, reason), the ready-to-paste specifiers for my build system, and the per-platform verification commands. Markers are evaluated at install time on the target host, so never gate a dependency on a value the build host has but the target lacks — verify on the actual target environment.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Python pip-audit Dependency Vulnerability Scan Prompt
Stand up an automated pip-audit vulnerability scan for a Python automation repo, triage findings against actual usage, propose minimal-risk version bumps, and wire it into CI with a sane fail policy.
-
uv Reproducible Python Environments Prompt
Adopt uv for fast, fully reproducible Python environments — a locked uv.lock, pinned interpreter, dependency groups, and uv run scripts — replacing slow pip/venv/requirements.txt workflows in dev, CI, and Docker.
-
Packaging a Python CLI with pyproject.toml and Entry Points Prompt
Turn a Python script into a properly packaged, installable CLI using pyproject.toml, console entry_points, src layout, versioning, and a clean build/distribution workflow.
-
Python CSV Data-Quality Validator Prompt
Build a Python CLI that validates and cleans CSV/tabular data against declarative quality rules — types, ranges, required fields, uniqueness, referential checks — and emits a structured report of every violation
More Bash & Python Automation prompts & error guides
Browse every Bash & Python Automation prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.