Skip to content

Commit

Permalink
V6.1.2 (#153)
Browse files Browse the repository at this point in the history
* add setuptools dependency

* remove pip install workarounds

* Update CHANGELOG.rst

* v6.1.2

* Update Makefile

* Update build.py
  • Loading branch information
jannikmi authored Sep 13, 2022
1 parent 794914f commit 51efdd3
Show file tree
Hide file tree
Showing 5 changed files with 343 additions and 82 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Future TODOs:
* parameterised tests


6.1.2 (2022-09-13)
------------------

* bugfix potentially broken pip install due to a mismatch in ``cffi`` versions (GitHub issue #151)


6.1.1 (2022-08-18)
------------------
Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include .env

# https://stackoverflow.com/questions/38878088/activate-anaconda-python-environment-from-makefile
# By default make uses sh to execute commands, and sh doesn't know `source`
SHELL=/bin/bash
Expand Down
29 changes: 5 additions & 24 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@
"""
import pathlib
import re
import subprocess

# workaround to install build dependencies:
try:
import setuptools
except ImportError:
subprocess.run(["poetry", "run", "pip", "install", "setuptools"])

try:
import cffi
except ImportError:
subprocess.run(["poetry", "run", "pip", "install", "cffi"])

import setuptools
from cffi import FFI
Expand All @@ -33,29 +21,22 @@
c_file_path = EXTENSION_PATH / C_FILE_NAME

ffibuilder = FFI()
ffibuilder.set_source(
EXTENSION_NAME, # name of the output C extension
f'#include "{h_file_path}"',
sources=[str(c_file_path)],
)

with open(h_file_path) as h_file:
# cffi does not like our preprocessor directives, so we remove them
lns = h_file.read().splitlines()
flt = filter(lambda ln: not re.match(r" *#", ln), lns)

ffibuilder.cdef("\n".join(flt))

with open(c_file_path) as c_file:
# cffi does not like our preprocessor directives, so we remove them
c_file_content = c_file.read()

# ffibuilder.set_source(
# EXTENSION_NAME, # name of the output C extension
# c_file_content
# )

ffibuilder.set_source(
EXTENSION_NAME, # name of the output C extension
f'#include "{h_file_path}"',
sources=[str(c_file_path)],
)

if __name__ == "__main__":
# not required
# ffibuilder.compile(verbose=True)
Expand Down
Loading

0 comments on commit 51efdd3

Please sign in to comment.