Skip to content

Commit

Permalink
Remove scikit-build
Browse files Browse the repository at this point in the history
  • Loading branch information
learnforpractice committed Jun 26, 2023
1 parent e795c39 commit b68b17d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/python-app.yml
Expand Up @@ -56,7 +56,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -U flake8 pytest scikit-build cython auditwheel
python -m pip install --upgrade wheel
python -m pip install -U flake8 pytest cython auditwheel
# - name: Lint with flake8
# run: |
# # stop the build if there are Python syntax errors or undefined names
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,3 +1,5 @@
# generated file by cython
src/_mixin.cpp
.testnet
*.wallet
testnet
Expand Down
1 change: 0 additions & 1 deletion requirements-dev.txt
Expand Up @@ -4,7 +4,6 @@ websocket-client>=0.54.0
websockets
dataclasses-json

scikit-build
cython
pytest
pytest-asyncio
Expand Down
56 changes: 53 additions & 3 deletions setup.py
@@ -1,9 +1,13 @@
import os
import sys
import platform
from setuptools import find_packages
from skbuild import setup


from setuptools import find_packages, setup, Extension
from Cython.Build import cythonize

os.environ["CC"] = "clang"
os.environ["CXX"] = "clang++"

# Require pytest-runner only when running tests
pytest_runner = (['pytest-runner>=2.0,<3dev']
if any(arg in sys.argv for arg in ('pytest', 'test'))
Expand All @@ -22,6 +26,48 @@
version = platform.python_version_tuple()
version = '%s.%s' % (version[0], version[1])

dir_name = os.path.dirname(os.path.realpath(__file__))

root_path = os.path.join(dir_name, 'src/mixin')
def check_modification():
lib_name = os.path.join(root_path, 'libmixin.a')
if not os.path.exists(lib_name):
return True
modify_time = os.path.getmtime(lib_name)
for root, dirs, files in os.walk(root_path):
for f in files:
if f[-3:] == '.go':
f = os.path.join(root, f)
file_time = os.path.getmtime(f)
if modify_time < file_time:
return True
return False

r = check_modification()
if r:
print('mixin lib need to rebuild.')
os.system(f'touch {root_path}/main.go')

if platform.system() == 'Windows':
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')
else:
os.system('cd ./src/mixin;go build -o libmixin.a -buildmode=c-archive')

ext_modules = [
Extension(
'pymixin._mixin',
sources=[
'src/_mixin.pyx',
],
include_dirs=[
'src/mixin',
],
language='c++',
extra_compile_args=['-std=c++17'],
extra_link_args=['-L./src/mixin', '-lmixin'],
)
]

setup(
name="mixin-python",
version="0.2.10",
Expand All @@ -34,6 +80,10 @@
package_data={'pymixin': data},
data_files = data_files,
scripts=[],
ext_modules=cythonize(
ext_modules,
compiler_directives={'language_level': 3, },
),
install_requires=[
"PyJWT>=2.4.0",
"websockets>=9.1",
Expand Down

0 comments on commit b68b17d

Please sign in to comment.