Skip to content

Commit

Permalink
Merge pull request #62 from jvkersch/add-headers
Browse files Browse the repository at this point in the history
MAINT: Add parasail headers to Python wheel.
  • Loading branch information
jeffdaily authored Aug 24, 2022
2 parents e10c324 + 8f8e42b commit 73cda78
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ parasail.egg-info/
*.dll
parasail-master*
autotools/
parasail/include/**
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ include parasail/bindings_v2.py
exclude parasail/libparasail.so
exclude parasail/libparasail.dylib
exclude parasail/parasail.dll
recursive-exclude parasail/include *.h
include setup.cfg
include setup.py
include tests/test_basic.py
Expand Down
10 changes: 10 additions & 0 deletions parasail/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
elif platform.system() == 'Windows':
_libname = "parasail.dll"
_libpath = os.path.join(os.path.dirname(__file__), _libname)
_includepath = os.path.join(os.path.dirname(__file__), "include")

_verbose = os.environ.get("PARASAIL_VERBOSE", False)

Expand Down Expand Up @@ -92,3 +93,12 @@ def version():
else:
from parasail.bindings_v2 import *

def get_include():
""" Returns the path of the Parasail C library include files.
"""
return _includepath

def get_library():
""" Returns the path of the Parasail C library shared object file.
"""
return _libpath
24 changes: 23 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import tarfile
import zipfile

from distutils.dir_util import copy_tree
from distutils.util import get_platform
from setuptools import setup
from setuptools.command.install import install as install_
Expand Down Expand Up @@ -93,6 +94,11 @@ def get_libname():
libname = "parasail.dll"
return libname

def get_includes():
return ["include/*.h",
"include/parasail/*.h",
"include/parasail/matrices/*.h"]

def unzip(archive, destdir):
thefile=zipfile.ZipFile(archive)
thefile.extractall(destdir)
Expand Down Expand Up @@ -364,6 +370,16 @@ def build_parasail(libname):
print("copying {} to {}".format(src,dst))
shutil.copy(src,dst)

# copy headers into the parasail directory, so they can be added to the wheel
parasail_headers = os.path.join(parasail_root, "parasail")
dst = os.path.join("parasail", "include", "parasail")
print("copying {} to {}".format(parasail_headers, dst))
copy_tree(parasail_headers, dst)
parasail_h = os.path.join(parasail_root, "parasail.h")
dst = os.path.join("parasail", "include")
print("copying {} to {}".format(parasail_h, dst))
shutil.copy(parasail_h, dst)

def github_api_json(address):
import json
import sys
Expand Down Expand Up @@ -431,6 +447,12 @@ def download_windows_dll():
print("copying {} to {}".format(src,dst))
shutil.copy(src,dst)

# copy headers into the parasail directory, so they can be added to the wheel
headers_src = os.path.join(root, "..", "include")
dst = os.path.join("parasail", "include")
print("copying {} to {}".format(headers_src, dst))
copy_tree(headers_src, dst)

def prepare_shared_lib():
libname = get_libname()
libpath = os.path.join("parasail", libname)
Expand Down Expand Up @@ -488,7 +510,7 @@ def finalize_options(self):
maintainer_email=find_meta("email"),
keywords=KEYWORDS,
packages=PACKAGES,
package_data={"parasail": [get_libname()]},
package_data={"parasail": [get_libname()] + get_includes()},
cmdclass=cmdclass,
zip_safe=False,
classifiers=CLASSIFIERS,
Expand Down

0 comments on commit 73cda78

Please sign in to comment.