aboutsummaryrefslogtreecommitdiff
path: root/guix-env.scm
blob: f8ab32e8ad57d6350c2a7a249f36d7667429d718 (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
(use-modules ((guix licenses) #:select (bsd-3 gpl3+ psfl lgpl2.1+))
             (guix packages)
             (guix download)
             (guix git-download)
             (guix gexp)
             (guix build-system cmake)
             (guix build-system trivial)
             (guix build-system python)
             (guix build-system gnu)
             (gnu packages python)
             (gnu packages xml)
             (gnu packages tls)
             (gnu packages emacs)
             (gnu packages package-management)
             (gnu packages zip)
             (gnu packages swig)
             (gnu packages compression)
             (gnu packages guile))

(define libsolv
  (package
    (name "libsolv")
    (version "0.6.22")
    (source (origin
             (method url-fetch)
             (uri (string-append "https://github.com/openSUSE/libsolv/archive/"
                                 version ".tar.gz"))
             (file-name (string-append name "-" version ".tar.gz"))
             (modules '((guix build utils)))
             (sha256
              (base32
               "0zl7dlqmib05y5f2wkbz66n68bmqk2fxhvph1dfr071v7jnzc6gf"))
             (snippet
               '(substitute* '("bindings/python/CMakeLists.txt")
                  (("EXECUTE_PROCESS.*") "")
                  (("libsolv ") "libsolv python2.7 ")
                  ))))
    (build-system cmake-build-system)
    (inputs
     `(("expat" ,expat)
       ("zlib" ,zlib)
       ("python" ,python-2.7)
       ("swig" ,swig)))
    (arguments
     '(#:configure-flags
       (list (string-append "-DPYTHON_INSTALL_DIR="
                            (assoc-ref %outputs "out") "/lib/python2.7/site-packages")
             "-DENABLE_PYTHON=1"
             (string-append ; uses lib64 by default
               "-DLIB=lib")
             (string-append "-DCMAKE_INSTALL_RPATH="
                            (assoc-ref %outputs "out") "/lib"))))
                            ;(assoc-ref %outputs "out") "/lib:"
                            ;(assoc-ref %outputs "out") "/lib64"))))
    (home-page "https://github.com/openSUSE/libsolv")
    (synopsis "libsolv")
    (description "")
    (license bsd-3)))

(define pyguile
  (package
    (name "pyguile")
    (version "0.3.1")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "http://git.cbaines.net/pyguile")
                     (commit "e37142e8aaa903920d4f13a5ef66a352618e65c6")))
              (sha256
                (base32
                  "037w1bf58yn4kfy5jydd1jzfi7dpg0m2w8p1sd2wnr6py03hybwq"))))
    ;(source (origin
    ;         (method url-fetch)
    ;         (uri (string-append "https://github.com/cbaines/pyguile/archive/v"
    ;                             version ".tar.gz"))
    ;         (file-name (string-append name "-" version ".tar.gz"))
    ;         (modules '((guix build utils)))
    ;         (sha256
    ;          (base32
    ;           "0ds5pnm4dc0vyfa5wlyw9dvzl6dyiizh4q8s153byyn8jkiimb5c"))))
    (build-system cmake-build-system)
    (inputs
     `(("python" ,python-2.7)
       ("guile" ,guile-2.0)))
    (arguments
     '(;#:tests? #f ; no tests
       ;#:make-flags (list "CC=gcc"
       ;                   (string-append "PREFIX=" %output))
       #:phases
       (modify-phases %standard-phases
         (delete 'configure)
         (delete 'check)
         (replace 'build
          (lambda* (#:key outputs #:allow-other-keys)
           ;(chdir "..")
           (display "CWD ")(display (getcwd))(display "\n")
           (let ((out (assoc-ref outputs "out")))
            (zero?
             (system* "make" "CC=gcc")))))
         (replace
          'install
          (lambda* (#:key outputs #:allow-other-keys)
            (let* ((out     (assoc-ref outputs "out"))
                   (guild (string-append (assoc-ref %build-inputs "guile")
                                         "/bin/guild"))
                   (scm-dir
                     (string-append out "/share/guile/site/2.0/"))
                   (scm-path
                     (string-append scm-dir "pyguile.scm"))
                   (lib-dir
                     (string-append out "/lib/"))
                   (lib-path
                     (string-append lib-dir "libpyguile.so")))
              (mkdir-p scm-dir)
              (mkdir-p lib-dir)
              (copy-file "pyguile.scm" scm-path)
              (copy-file "libpyguile.so" lib-path)
              (substitute* scm-path
                           (("libpyguile")
                            (string-append lib-dir "libpyguile")))
              (setenv "GUILE_AUTO_COMPILE" "0")
              (unless (zero?
                        (system* guild "compile" scm-path
                                  "-o" (string-append scm-dir "pyguile.go")))
                (error "failed to compile"))
              #t))))))
    (home-page "https://github.com/tddpirate/pyguile")
    (synopsis "pyguile")
    (description "")
    (license lgpl2.1+)))

(define python-packaging
  (package
    (name "python-packaging")
    (version "16.7")
    (source
      (origin
        (method url-fetch)
        (uri (string-append
               "https://pypi.python.org/packages/28/ad/4e6601d14b11bb300719a8bb6247f6ef5861467a692523c978a4e9e3981a/packaging-"
               version
               ".tar.gz"))
        (sha256
          (base32
            "07h18mrpqs0lv2x4fl43pqi0xj6hdrmrnm6v9q634yliagg6q91f"))))
    (build-system python-build-system)
    (inputs
      `(("python-setuptools" ,python-setuptools)))
    (propagated-inputs
     `(("python-pyparsing" ,python-pyparsing)
       ("python-six" ,python-six)))
    (home-page "https://github.com/pypa/packaging")
    (synopsis "Core utilities for Python packages")
    (description
      "Core utilities for Python packages")
    (license #f)))

(define python2-packaging
  (package-with-python2 python-packaging))

(define python-setuptools
  (package
    (name "python-setuptools")
    (version "20.10.1")
    (source
     (origin
      (method url-fetch)
      (uri "https://pypi.python.org/packages/d3/16/21cf5dc6974280197e42d57bf7d372380562ec69aef9bb796b5e2dbbed6e/setuptools-20.10.1.tar.gz")
      (sha256
       (base32
        "1pdm34rjixkdyp5j2yp774ri1da7ncqy8s34h4qxdl4yy22whn9y"))))
    (build-system python-build-system)
    ;; FIXME: Tests require pytest, which itself relies on setuptools.
    ;; One could bootstrap with an internal untested setuptools.
    (arguments
     `(#:tests? #f))
    (home-page "https://pypi.python.org/pypi/setuptools")
    (synopsis
     "Library designed to facilitate packaging Python projects")
    (description
     "Setuptools is a fully-featured, stable library designed to facilitate
packaging Python projects, where packaging includes:
Python package and module definitions,
distribution package metadata,
test hooks,
project installation,
platform-specific details,
Python 3 support.")
    (license psfl)))

(define python2-setuptools
  (package-with-python2 python-setuptools))

(define guix-pypi-utils
  (package
    (name "guix-pypi-utils")
    (version "0.1")
    ;(source (local-file "../guix-pypi-utils" #:recursive? #t))
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "http://git.cbaines.net/guix-pypi-utils")
                     (commit "86de22b526313a68e5c8bb8a361d5904c30d8b51")))
              (file-name (string-append name "-" version "-checkout"))
              (sha256
                (base32
                  "1n0f3cgxinxgfsf48vgvj6ggn5m8is7hrinx8bzmxiy4rlzaq5db"))))
    (build-system trivial-build-system)
    (arguments
     `(#:modules
       ((guix build utils)
        (ice-9 match))
       #:builder
       (begin
         (use-modules (guix build utils)
                      (ice-9 match))
         (let* ((out (assoc-ref %outputs "out"))
                (module-dir (string-append out "/share/guile/site/2.0"))
                (source (assoc-ref %build-inputs "source"))
                (guild (string-append (assoc-ref %build-inputs "guile")
                                      "/bin/guild")))

           (mkdir-p (string-append module-dir "/pypi"))
           (copy-recursively (string-append source "/pypi")
                             (string-append module-dir "/pypi"))

           (mkdir-p (string-append module-dir "/solver"))
           (install-file
             (string-append source "/solver/__init__.py")
             (string-append module-dir "/solver"))

           (display "pythonpath\n")
           (display (getenv "PYTHONPATH"))
           (substitute* (string-append module-dir "/pypi/dependency-solver.scm")
             (("\\(define %solver-location \"\"\\)")
              (string-append
                "(define %solver-location \"" module-dir "\")")))

           (setenv "GUILE_AUTO_COMPILE" "0")
           ;(for-each (lambda (file)
           ;            (let ((scm-file
           ;                    (string-append module-dir file))
           ;                  (go-file (match (string-split file #\.)
           ;                              ((base _)
           ;                               (string-append module-dir "/"
           ;                                              base ".go")))))
           ;              ;; Install compiled module.
           ;              (unless (zero? (system* guild "compile"
           ;                                      "-L" source
           ;                                      "-o" go-file
           ;                                      scm-file))
           ;                (error (format #f "Failed to compile ~s to ~s!"
           ;                               scm-file go-file)))))
           ;          (map
           ;            (lambda (file)
           ;              (substring
           ;                file
           ;                (string-length module-dir)))
           ;            (find-files (string-append
           ;                          module-dir
           ;                          "/pypi")
           ;                        ".*\\.scm$")))
           #t))))
    (inputs
      `(("unzip" ,unzip)
        ("guile" ,guile-2.0)))
    (propagated-inputs
      `(("guix" ,guix-0.11.0)
        ("guile-lib" ,guile-lib)
        ("guile-json" ,guile-json)
        ("pyguile" ,pyguile)
        ("libsolv" ,libsolv)
        ("python" ,python-2.7)
        ("python2-setuptools" ,python2-setuptools)
        ("python2-packaging" ,python2-packaging)))
    (home-page "https://example.com")
    (synopsis "guix-pypi-utils")
    (description "")
    (license gpl3+)))

(define guix-python-integration-project
  (package
    (name "guix-python-integration-project")
    (version "0.1")
    (source (local-file "." #:recursive? #t))
    (build-system trivial-build-system)
    (arguments
     `(#:modules
       ((guix build utils)
        (ice-9 match))
       #:builder
       (begin
         (use-modules (guix build utils)
                      (ice-9 match))
         (let* ((out (assoc-ref %outputs "out"))
                (module-dir (string-append out "/share/guile/site/2.0"))
                (source (assoc-ref %build-inputs "source"))
                (scm-files
                  (find-files "." ".*\\.scm$"))
                (guild (string-append (assoc-ref %build-inputs "guile")
                                      "/bin/guild")))
           ;; Make installation directories.
           (mkdir-p (string-append module-dir "/guix-python-integration-project"))

           (setenv "GUILE_AUTO_COMPILE" "0")
           (for-each (lambda (file)
                       (let* ((dest-file (string-append module-dir "/"
                                                        file))
                              (go-file (match (string-split file #\.)
                                         ((base _)
                                          (string-append module-dir "/"
                                                         base ".go")))))
                         ;; Install source module.
                         (copy-file file dest-file)
                         ;; Install compiled module.
                         (unless (zero? (system* guild "compile"
                                                 "-L" source
                                                 "-o" go-file
                                                 file))
                           (error (format #f "Failed to compile ~s to ~s!"
                                          file go-file)))))
                     (map
                       (lambda (file)
                         (display file)(display "\n")
                         (display
                           (substring
                             file
                             (string-length module-dir))) (display "\n")
                         (substring
                           file
                           (string-length module-dir)))
                       scm-files))
           #t))))
    (propagated-inputs
      `(("guix" ,guix-0.11.0)
        ("guile" ,guile-2.0)
        ("guix-pypi-utils" ,guix-pypi-utils)))
    (home-page "https://example.com")
    (synopsis "guix-pypi-utils")
    (description "")
    (license gpl3+)))

guix-python-integration-project