Browse Source

Support setuptools

Matthias Vogelgesang 6 years ago
parent
commit
53bef8a654
5 changed files with 27 additions and 12 deletions
  1. 3 0
      .gitignore
  2. 0 0
      bin/pcip
  3. 0 0
      pci/__init__.py
  4. 9 12
      pci/build.py
  5. 15 0
      setup.py

+ 3 - 0
.gitignore

@@ -1,3 +1,6 @@
+dist/
+build/
+pypci.egg-info/
 lextab.py
 _pciffi.*
 *.pyc

+ 0 - 0
pci → bin/pcip


+ 0 - 0
pci.py → pci/__init__.py


+ 9 - 12
build.py → pci/build.py

@@ -2,7 +2,6 @@ from cffi import FFI, __version__ as cffi_version
 
 
 def get_header():
-    fix = 'struct timeval { uint32_t tv_sec; uint32_t tv_usec; };'
     f = open('/usr/local/include/pcilib.h')
     lines = [x for x in f if not x.startswith('#') and not 'logger' in x and not 'extern "C"' in x]
 
@@ -15,17 +14,15 @@ def get_header():
     return '\n'.join(lines)
 
 
-def build():
-    builder = FFI()
-    builder.set_source("_pciffi",
-        r"""
-        #include <sys/time.h>
-        #include <pcilib.h>
-        """,
-        libraries=['pcilib'])
-    builder.cdef(get_header())
-    builder.compile(verbose=True)
+builder = FFI()
+builder.set_source("_pciffi",
+    r"""
+    #include <sys/time.h>
+    #include <pcilib.h>
+    """,
+    libraries=['pcilib'])
+builder.cdef(get_header())
 
 
 if __name__ == '__main__':
-    build()
+    builder.compile(verbose=True)

+ 15 - 0
setup.py

@@ -0,0 +1,15 @@
+from setuptools import setup, find_packages
+
+setup(
+    name='pypci',
+    version='0.1',
+    author='Matthias Vogelgesang',
+    author_email='matthias.vogelgesang@kit.edu',
+    description='Python access to pcilib',
+    packages=find_packages(),
+    scripts=['bin/pcip'],
+    setup_requires=['cffi>=1.0.0'],
+    install_requires=['cffi>=1.0.0'],
+    cffi_modules=['pci/build.py:builder'],
+)
+