Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Spacerat
Last active April 28, 2016 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Spacerat/7fb30b1cd4c7f6b54c38ba0559c10876 to your computer and use it in GitHub Desktop.
Save Spacerat/7fb30b1cd4c7f6b54c38ba0559c10876 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# Quick and dirty script to scrub pip requirements files of duplicate requirements
import sys
import fileinput
from requirements.requirement import Requirement
seen = set()
out = []
for line in fileinput.input():
try:
name = Requirement.parse(line).name
if name in seen:
continue
seen.add(name)
sys.stdout.write(line)
except ValueError as e:
sys.stdout.write(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment