Skip to content

Commit

Permalink
Add emacspy.el. Rename emacspy.so to emacspy-module.so
Browse files Browse the repository at this point in the history
  • Loading branch information
813gan committed Aug 25, 2024
1 parent 6e540fb commit 8ed35c5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@ endif

.PHONY: all clean test_module_assertions test test_ert test_formatting test_valgrind

all: emacspy.so
all: emacspy-module.so

emacspy.c: emacspy.pyx
cython emacspy.pyx

# https://github.com/grisha/mod_python/issues/81#issuecomment-551655070
emacspy.so: BLDLIBRARY=$(shell ${PYTHON} -c \
emacspy-module.so: BLDLIBRARY=$(shell ${PYTHON} -c \
'import sysconfig; print(sysconfig.get_config_var("BLDLIBRARY"))')
emacspy.so: PKGCONFIG_PATH=$(shell ${PYTHON} -c \
emacspy-module.so: PKGCONFIG_PATH=$(shell ${PYTHON} -c \
'import sysconfig; print(sysconfig.get_config_var("LIBPC"))')
emacspy.so: LIBPYTHON_NAME=$(shell ${PYTHON} -c \
emacspy-module.so: LIBPYTHON_NAME=$(shell ${PYTHON} -c \
'import sysconfig; print(sysconfig.get_config_var("LDLIBRARY"))')
emacspy.so: emacspy.c stub.c subinterpreter.c
emacspy-module.so: emacspy.c stub.c subinterpreter.c
gcc -fPIC -g -DCYTHON_FAST_THREAD_STATE=0 -DCYTHON_PEP489_MULTI_PHASE_INIT=0 \
-Wall -Wextra -Werror ${OPTIMALISATION_FLAGS} ${HARDENING_FLAGS} ${GCC_NO_WARN} \
emacspy.c stub.c \
${BLDLIBRARY} -DLIBPYTHON_NAME=$(LIBPYTHON_NAME) \
-shared $(shell pkg-config --cflags --libs $(PKGCONFIG_PATH)"/python3-embed.pc") \
-o emacspy.so
-o emacspy-module.so

clean:
rm -vf emacspy.c emacspy.so
rm -vf emacspy.c emacspy-module.so

test: test_ert test_formatting

Expand All @@ -65,6 +65,6 @@ test_valgrind: clean all .valgrind-python.supp
test_formatting:
${CLANGFORMAT} --dry-run --Werror stub.c subinterpreter.c

test_module_assertions: emacspy.so
test_module_assertions: emacspy-module.so
${EMACS} --batch --module-assertions --eval \
'(progn (add-to-list '\''load-path ".") (load "emacspy"))'
19 changes: 19 additions & 0 deletions emacspy.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
;;; emacspy.el --- emacspy enables you to use python modules from Elisp or program Emacs in Python instead of ELisp. -*- lexical-binding: t; -*-

;; Copyright (C) 2024 zielmicha, 813gan

;; URL: https://github.com/zielmicha/emacspy
;; Author: zielmicha, 813gan
;; Keywords: python
;; Version: 1.0
;; Package: emacspy
;; Package-Requires:

;;; Commentary:
;; # emacspy.el

;;; Code:

(require 'emacspy-module)

;;; emacspy.el ends here
2 changes: 1 addition & 1 deletion emacspy.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def init():
return ret

_F().define_error(sym('python-exception'), "Python error")
_F().provide(sym('emacspy'))
_F().provide(sym('emacspy-module'))

cdef public int emacs_module_init_py(emacs_runtime* runtime):
global current_env, nil
Expand Down
4 changes: 2 additions & 2 deletions tests/test.el
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
(should-error (py-run-string "NON_EXISTING" "True")))

(ert-deftest ert-test-emacspy-duplicate-load ()
(should-error (progn (load "emacspy")
(load "emacspy"))))
(should-error (progn (load "emacspy-module")
(load "emacspy-module"))))

(ert-deftest ert-test-emacspy-create-destroy-subinterpreter ()
(let ((sub "test_subinterpreter"))
Expand Down

0 comments on commit 8ed35c5

Please sign in to comment.