Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #418 from mrclary/black-recipe
Add recipe for black
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
from pkg_resources import get_distribution | ||
|
||
|
||
def check(cmd, mf): | ||
m = mf.findNode("black") | ||
if m is None or m.filename is None: | ||
return None | ||
|
||
egg = get_distribution('black').egg_info | ||
top = os.path.join(egg, 'top_level.txt') | ||
|
||
# These cannot be in zip | ||
packages = ["black", "blib2to3"] | ||
|
||
# black may include optimized platform specific C extension which has | ||
# unusual name, e.g. 610faff656c4cfcbb4a3__mypyc; best to determine it from | ||
# the egg-info/top_level.txt | ||
with open(top, 'r') as f: | ||
includes = set(f.read().strip().split('\n')) | ||
includes = list(includes.difference(packages)) | ||
|
||
# Missed dependency | ||
includes.append('pathspec') | ||
|
||
return {"includes": includes, "packages": packages} |