Skip to content

Commit

Permalink
Adding setup.py for pygrip
Browse files Browse the repository at this point in the history
  • Loading branch information
kellrott committed Aug 22, 2024
1 parent 80b1652 commit 4e79dd7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gripql/python/gripql/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
count
]

__version__ = "0.7.1"
__version__ = "0.8.0"
5 changes: 3 additions & 2 deletions pygrip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

from __future__ import print_function
from ctypes import *
import os, inspect
from ctypes.util import find_library
import os, inspect, sysconfig
import random, string
import json
from gripql.query import QueryBuilder

cwd = os.getcwd()
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
os.chdir(currentdir)
_lib = cdll.LoadLibrary("./pygrip.so")
_lib = cdll.LoadLibrary("./_pygrip" + sysconfig.get_config_vars()["EXT_SUFFIX"])
os.chdir(cwd)

_lib.ReaderNext.restype = c_char_p
Expand Down
33 changes: 33 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Setup for checksig package"""
import sys
from distutils.errors import CompileError
from subprocess import call

from setuptools import Extension, setup, find_packages
from setuptools.command.build_ext import build_ext


class build_go_ext(build_ext):
"""Custom command to build extension from Go source files"""
def build_extension(self, ext):
ext_path = self.get_ext_fullpath(ext.name)
cmd = ['go', 'build', '-buildmode=c-shared', '-o', ext_path]
cmd += ext.sources
out = call(cmd)
if out != 0:
raise CompileError('Go build failed')

setup(
name='pygrip',
version='0.8.0',
packages=find_packages(include=['pygrip']),
#py_modules=['pygrip'],
ext_modules=[
Extension('pygrip/_pygrip', ['./pygrip/wrapper.go'])
],
cmdclass={'build_ext': build_go_ext},
install_requires=[
"gripql>=0.8.0"
],
zip_safe=False,
)

0 comments on commit 4e79dd7

Please sign in to comment.