Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make an effort at automatically determining the Python include dir
Ignore-this: 9a23e3f1b51804aab62d6cf3222840a0 darcs-hash:20111120043015-0344a-37614883556edbcf451effdc289b310c0a77b50a.gz
- Loading branch information
pinterface
committed
Nov 20, 2011
1 parent
a014960
commit b10e1cf
Showing
3 changed files
with
40 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
(in-package #:cpython) | ||
|
||
(defun read-path () | ||
(format *query-io* "Enter directory containing Python's C header files: ") | ||
(cl:list (read-line *query-io*))) | ||
|
||
(defun query-error (format-string &rest args) | ||
(restart-case (apply #'error format-string args) | ||
(use-value (v) | ||
:report "Specify directory containing CPython's header files" | ||
:interactive read-path | ||
v))) | ||
|
||
(defun query-user-for-include-dir () | ||
(loop :for path := (query-error "Unable to determine Python include directory.") | ||
:then (query-error "Path ~s does not appear to exist." path) | ||
:when (cl-fad:directory-exists-p path) :return it)) | ||
|
||
(defparameter *cpython-include-dir* | ||
(or (loop :for minor :from 7 :downto 4 | ||
:when (or (cl-fad:directory-exists-p (format nil "/usr/include/python2.~d" minor)) | ||
(cl-fad:directory-exists-p (format nil "/usr/local/include/python2.~d" minor))) | ||
:return it) | ||
;; This allows us to avoid querying the user during a recompile, while | ||
;; still allowing for a change in Python version | ||
(when (boundp '*cpython-include-dir*) | ||
(cl-fad:directory-exists-p *cpython-include-dir*)) | ||
(query-user-for-include-dir))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters