Skip to content

Commit 6bb8c2f

Browse files
committed
bugfix
1 parent 8696fff commit 6bb8c2f

File tree

9 files changed

+15
-5
lines changed

9 files changed

+15
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ functions.so
55
__pycache__
66
matrix_table_consumer.egg-info
77
build
8+
dist

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
To install this package run (you need to have Go):
44

55
```bash
6-
python setup.py install
6+
pip install build
7+
python -m build
8+
pip install .
79
```
810

911
To compile Go modules with C types to work with Python run:

__init__.py

Whitespace-only changes.

matrix_table_consumer/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .matrix_table_consumer import MatrixTableConsumer, NUM_CPU
File renamed without changes.
File renamed without changes.

matrix_table_consumer.py renamed to matrix_table_consumer/matrix_table_consumer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
Content: TypeAlias = dict
1919
Rows: TypeAlias = list[dict]
2020

21+
current_dir = os.path.dirname(__file__)
22+
library_path = os.path.join(current_dir, "functions.so")
2123

22-
lib = ctypes.CDLL("./functions.so")
24+
lib = ctypes.CDLL(library_path)
2325
CollectAll = lib.CollectAll
2426
Collect = lib.Collect
2527
Count = lib.Count

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0", "wheel"]
3+
build-backend = "setuptools.build_meta"

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class BuildGoExtension(build_ext):
1414
def run(self):
1515
super().run()
1616

17-
go_dir = os.path.join(os.getcwd(), "functions")
17+
go_dir = os.path.join(os.getcwd(), "matrix_table_consumer", "functions")
1818
os.chdir(go_dir)
1919
env = os.environ.copy()
2020
env["CGO_ENABLED"] = "1"
@@ -27,7 +27,7 @@ def run(self):
2727
except subprocess.CalledProcessError as e:
2828
raise RuntimeError(f"Error building Go module: {e}")
2929
finally:
30-
os.chdir("..")
30+
os.chdir("../..")
3131

3232

3333
ext_modules = [
@@ -46,6 +46,7 @@ def run(self):
4646
packages=find_packages(),
4747
ext_modules=ext_modules,
4848
cmdclass={'build_ext': BuildGoExtension},
49+
data_files=[("", ["matrix_table_consumer/functions.so"])],
4950
include_package_data=True,
5051
zip_safe=False,
5152
license='MIT',
@@ -58,5 +59,5 @@ def run(self):
5859
"Programming Language :: Python :: 3",
5960
"Operating System :: OS Independent",
6061
],
61-
python_requires="==3.12",
62+
python_requires=">=3.12",
6263
)

0 commit comments

Comments
 (0)