Last active
December 28, 2015 05:59
-
-
Save rcarmo/7454234 to your computer and use it in GitHub Desktop.
Setuptools in hylang
This file contains hidden or 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
(import [os [walk]] | |
[os.path [join splitext]] | |
[distutils.core [setup]] | |
[distutils.command.build [build]] | |
[fnmatch [fnmatch]] | |
[subprocess [Popen PIPE]]) | |
(defn glob [path pattern] | |
"find all files matching a given pattern" | |
(for (step (walk path)) | |
(for (basename (nth step 2)) | |
(if (fnmatch basename pattern) | |
(yield (join (nth step 0) basename)))))) | |
(defn wisp-compile [filename] | |
"compile .wisp files into .js" | |
(print (% "-> %s" filename)) | |
(.communicate | |
(kwapply (Popen "wisp") | |
{"stdin" (open filename "r") | |
"stdout" (open (+ (first (splitext filename)) ".js") "w")}))) | |
(defclass custom-build [build] | |
"custom build steps" | |
[[run | |
(fn [self] | |
(build.run self) | |
(map wisp-compile (glob "src" "*.wisp")))]]) | |
(kwapply (setup) {"cmdclass" {"build" custom-build}}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment