-
Notifications
You must be signed in to change notification settings - Fork 0
/
cabalrebel.py
67 lines (54 loc) · 2.34 KB
/
cabalrebel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from setuptools import setup
from setuptools.command.install import install as default_install
def cabal_install(name, license, author, maintainer, category, modules, linker_args=[], depends=[]):
from scooter import BuildHere, dirof, easyrun, p, build
@build
def _():
here = p('.')
build = BuildHere(here)
setup = here/'Setup.hs'
setup.set('''
import Distribution.Simple
main = defaultMain
''')
setup.delete_at_exit()
cabal_file = here/(here.dir.name + '.cabal')
cabal_file.set('''
-- Initial haskell-hangul.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/
name: {name}
version: 0.1.0.0
-- synopsis:
-- description:
license: {license}
license-file: LICENSE
author: {author}
maintainer: {maintainer}
-- copyright:
category: {category}
build-type: Custom
cabal-version: >=1.8
library
exposed-modules: {modules}
-- other-modules:
build-depends: {depends}
'''.format(
name = name,
license = license,
author = author,
maintainer = maintainer,
category = category,
modules = ', '.join(modules),
depends = ', '.join(['base ==4.6.*'] + list(depends))
))
cabal_file.delete_at_exit()
build.easyrun('runghc', here/'Setup.hs', 'configure', '--user')
build.easyrun('runghc', here/'Setup.hs', 'build', '--ld-options=' + ','.join(map(str, linker_args)))
easyrun('runghc', here/'Setup.hs', 'install')
def CabalInstall(name, license, author, maintainer, category, modules, linker_args=[], depends=[]):
class Impl(default_install):
def run(self):
default_install.do_egg_install(self)
cabal_install(name=name, license=license, author=author, maintainer=maintainer,
category=category, modules=modules, linker_args=linker_args, depends=depends)
return Impl