You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

84 lines
2.6 KiB

  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2014 David Thompson <davet@gnu.org>
  3. ;;;
  4. ;;; This file is part of GNU Guix.
  5. ;;;
  6. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or (at
  9. ;;; your option) any later version.
  10. ;;;
  11. ;;; GNU Guix is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  18. (define-module (guix scripts import pypi)
  19. #:use-module (guix ui)
  20. #:use-module (guix utils)
  21. #:use-module (guix import pypi)
  22. #:use-module (guix scripts import)
  23. #:use-module (srfi srfi-1)
  24. #:use-module (srfi srfi-11)
  25. #:use-module (srfi srfi-37)
  26. #:use-module (ice-9 match)
  27. #:use-module (ice-9 format)
  28. #:export (guix-import-pypi))
  29. ;;;
  30. ;;; Command-line options.
  31. ;;;
  32. (define %default-options
  33. '())
  34. (define (show-help)
  35. (display (_ "Usage: guix import pypi PACKAGE-NAME
  36. Import and convert the PyPI package for PACKAGE-NAME.\n"))
  37. (display (_ "
  38. -h, --help display this help and exit"))
  39. (display (_ "
  40. -V, --version display version information and exit"))
  41. (newline)
  42. (show-bug-report-information))
  43. (define %options
  44. ;; Specification of the command-line options.
  45. (cons* (option '(#\h "help") #f #f
  46. (lambda args
  47. (show-help)
  48. (exit 0)))
  49. (option '(#\V "version") #f #f
  50. (lambda args
  51. (show-version-and-exit "guix import pypi")))
  52. %standard-import-options))
  53. ;;;
  54. ;;; Entry point.
  55. ;;;
  56. (define (guix-import-pypi . args)
  57. (define (parse-options)
  58. ;; Return the alist of option values.
  59. (args-fold* args %options
  60. (lambda (opt name arg result)
  61. (leave (_ "~A: unrecognized option~%") name))
  62. (lambda (arg result)
  63. (alist-cons 'argument arg result))
  64. %default-options))
  65. (let* ((opts (parse-options))
  66. (args (filter-map (match-lambda
  67. (('argument . value)
  68. value)
  69. (_ #f))
  70. (reverse opts))))
  71. (match args
  72. ((package-name)
  73. (pypi->guix-package package-name)))))