2

I would like to execute a Common Lisp (SBCL) code from Python e.g. via shell. Also I need to run a Lisp-library called Shop3 to execute my Lisp code. I tried:

os.system('sbcl && (asdf:load-system "shop3") && (in-package:SHOP-USER) && (load "/Users/kiliankramer/Desktop/Shop-Planer/planner-new")')

But it's not working, it's only starting sbcl but then stop before to load the asdf library "shop3".

Can you tell how to execute my Lisp code or what alternatives I have to run an external Lisp program (including the Lisp library) to execute it?

Thanks in forward. :)

5
  • The file I am trying to execute from python is "load "/Users/kiliankramer/Desktop/Shop-Planer/planner-new" but for that I need to load shop3 before. Commented May 13, 2021 at 15:12
  • I'm not familiar with shop. Can it be executed in hylang (github.com/hylang/hy)? Commented May 13, 2021 at 15:18
  • thanks, I read about Hy, I will try that! :) (ps: SHOP3 - Simple Hierarchical Order Planner is a planner for robotics) Commented May 13, 2021 at 15:22
  • SHOP3 is a system for planning tasks and is written in Common Lisp: github.com/shop-planner/shop3 Commented May 13, 2021 at 18:56
  • 1
    See also cl4py, it's supposed to help in this scenario: github.com/marcoheisig/cl4py Commented May 13, 2021 at 22:04

1 Answer 1

5

&& chains shell commands. I.e., it starts sbcl and waits for it to terminate, and if the termination was successful, then it will try to execute (asdf:load-system "shop3") as a shell command (not what you want!)

You need to use sbcl command line arguments:

os.system("sbcl --eval '(asdf:load-system \\"shop3\\")' --eval '(in-package :SHOP-USER)' --load /Users/kiliankramer/Desktop/Shop-Planer/planner-new")

However, you might want to use the more modern interface instead of os.system. It will also avoid the need for escaping quotes &c:

subprocess.run(["sbcl","--eval",'(asdf:load-system "shop3")',
                "--eval",'(in-package :SHOP-USER)',
                "--load","/Users/kiliankramer/Desktop/Shop-Planer/planner-new")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.