Skip to content

Commit b68b17d

Browse files
Remove scikit-build
1 parent e795c39 commit b68b17d

File tree

4 files changed

+57
-5
lines changed

4 files changed

+57
-5
lines changed

.github/workflows/python-app.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ jobs:
5656
- name: Install dependencies
5757
run: |
5858
python -m pip install --upgrade pip
59-
python -m pip install -U flake8 pytest scikit-build cython auditwheel
59+
python -m pip install --upgrade wheel
60+
python -m pip install -U flake8 pytest cython auditwheel
6061
# - name: Lint with flake8
6162
# run: |
6263
# # stop the build if there are Python syntax errors or undefined names

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# generated file by cython
2+
src/_mixin.cpp
13
.testnet
24
*.wallet
35
testnet

requirements-dev.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ websocket-client>=0.54.0
44
websockets
55
dataclasses-json
66

7-
scikit-build
87
cython
98
pytest
109
pytest-asyncio

setup.py

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import os
22
import sys
33
import platform
4-
from setuptools import find_packages
5-
from skbuild import setup
6-
4+
5+
from setuptools import find_packages, setup, Extension
6+
from Cython.Build import cythonize
7+
8+
os.environ["CC"] = "clang"
9+
os.environ["CXX"] = "clang++"
10+
711
# Require pytest-runner only when running tests
812
pytest_runner = (['pytest-runner>=2.0,<3dev']
913
if any(arg in sys.argv for arg in ('pytest', 'test'))
@@ -22,6 +26,48 @@
2226
version = platform.python_version_tuple()
2327
version = '%s.%s' % (version[0], version[1])
2428

29+
dir_name = os.path.dirname(os.path.realpath(__file__))
30+
31+
root_path = os.path.join(dir_name, 'src/mixin')
32+
def check_modification():
33+
lib_name = os.path.join(root_path, 'libmixin.a')
34+
if not os.path.exists(lib_name):
35+
return True
36+
modify_time = os.path.getmtime(lib_name)
37+
for root, dirs, files in os.walk(root_path):
38+
for f in files:
39+
if f[-3:] == '.go':
40+
f = os.path.join(root, f)
41+
file_time = os.path.getmtime(f)
42+
if modify_time < file_time:
43+
return True
44+
return False
45+
46+
r = check_modification()
47+
if r:
48+
print('mixin lib need to rebuild.')
49+
os.system(f'touch {root_path}/main.go')
50+
51+
if platform.system() == 'Windows':
52+
os.system('cd ./src/mixin &&go build -o mixin.dll -buildmode=c-shared && copy mixin.dll ../../pysrc/mixin.dll && gendef mixin.dll && lib /def:mixin.def /machine:x64 /out:mixin.lib')
53+
else:
54+
os.system('cd ./src/mixin;go build -o libmixin.a -buildmode=c-archive')
55+
56+
ext_modules = [
57+
Extension(
58+
'pymixin._mixin',
59+
sources=[
60+
'src/_mixin.pyx',
61+
],
62+
include_dirs=[
63+
'src/mixin',
64+
],
65+
language='c++',
66+
extra_compile_args=['-std=c++17'],
67+
extra_link_args=['-L./src/mixin', '-lmixin'],
68+
)
69+
]
70+
2571
setup(
2672
name="mixin-python",
2773
version="0.2.10",
@@ -34,6 +80,10 @@
3480
package_data={'pymixin': data},
3581
data_files = data_files,
3682
scripts=[],
83+
ext_modules=cythonize(
84+
ext_modules,
85+
compiler_directives={'language_level': 3, },
86+
),
3787
install_requires=[
3888
"PyJWT>=2.4.0",
3989
"websockets>=9.1",

0 commit comments

Comments
 (0)