How do I manage common lisp dependencies?
Asked Answered
F

4

7

What's the lisp equivalent of a pip requirement file, ruby gemfile, node package.json, etc? I'm not entirely sure how asdf and quicklisp relate if those are the proper things to use.

Farber answered 31/10, 2013 at 22:56 Comment(0)
F
6

A .asd file is a requirements file. Use quicklisp to install requirements.

Use ASDF to define a "system". Create a my-system.asd file.

(asdf:defsystem #:my-system
  :serial t
  :description "Describe my-system here"
  :author "My Name <[email protected]>"
  :license "Specify license here"
  :depends-on (#:hunchentoot
               #:cl-who)
  :components ((:file "package")
               (:file "dispatch")))

This creates the system named #:my-system. I'm not actually sure what the # denotes as I've seen system definitions without it in source code. Only the first line is required. :depends-on tells ASDF to load other systems before this new system definition is processed. In this case it loads #:hunchentoot and #:cl-who. :components load specific files. package.lisp and dispatch.lisp are loaded. :serial t tells it to load it in order. This is important if say dispatch.lisp depends on something in package.lisp such that package.lisp needs to be loaded first.

Use quicklisp to download and install the dependencies in :depends-on. Run (ql:quickload "my-system").

I haven't seen any sign of versioning.

Farber answered 2/11, 2013 at 7:16 Comment(1)
#: stands for uninterned symbols (it's not obligatory). As for versioning, there's an appropriate :version field in defsystemDisrate
D
2

First of all, pip's requirements.txt is very different from rubygem or node's package.json: the former specifies just the dependencies, while the latter ones describe the package, including its dependencies.

Python's pip actually also relies on the similar package description format which is called "eggs".

A pretty much direct equivalent of a rubygem is ASDF defsystem form, usually placed in a file <system-name>.asd ("system" is the Lisp's term for what may be called package, module or library in other languages - see here for a more detailed explanation).

The two major differences are:

  • ASDF also allows to specify how to build (and also load, test etc) the system (somewhat equivalent to a makefile) — AFAIK, there's no such notion in rubygems or node whatsoever

  • Unlike gems or node, ASDF doesn't provide a mechanism to download and install the package. This is where quicklisp comes in — it deals with fetching ASDF systems. But ql is not the only way here: historically there were other approaches for installing ASDF libraries, including ASDF-Install and clbuild, and others may come up in the future

Disrate answered 3/11, 2013 at 6:57 Comment(0)
L
2

Qlot

For the relation with ASDF and Quicklisp the other answers give a nice approach.

I want to remark that now you can use a common lisp library quite similar to the ones pointed, that is available at quicklisp an is Qlot. It is used to specify project-local dependencies. It is pretty similar to bundle and gemfile in ruby.

Quicklisp bundles

Also introduced in 2015-04-28 you can use quicklisp bundles Quicklisp library bundles are self-contained sets of systems that are exported from Quicklisp and loadable without involving Quicklisp.

Lor answered 24/11, 2016 at 7:10 Comment(0)
F
0

There is no one-to-one equivalent to those mentioned above. However, ASDF + Quicklisp combination comes pretty close.

With ASDF you define your systems (modules if you will) -- packaging your lisp files in a coherent way, and you declare your dependencies. Quicklisp is an online repository of sources for these systems. When you load a system with Quicklisp, it will download these dependencies and load them for you.

Now I'm not sure if there is such thing as versioning..

Forrer answered 1/11, 2013 at 4:20 Comment(2)
Re' versioning: you can define version in defsystem. Quicklisp isn't a repository it downloads things from many different sources, mostly Clicky, but there are some more. The ASD serves practically the same purpose as setup.py (the traditional way of creating Python packages).Wotton
@wvxvw What I mean with versioning is to declare it in your dependency (like a gemfile or package.json).. can you do that? And will Quicklisp then download the right version? Edit: You're right that Quicklisp downloads from many sources and is not a repository -- updated answerForrer

© 2022 - 2024 — McMap. All rights reserved.