Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/so versioning #482

Merged
merged 2 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ include dpctl/_sycl_queue.h
include dpctl/_sycl_queue_manager.h
include dpctl/_sycl_event.h
include dpctl/memory/_memory.h
include dpctl/*DPCTL*Interface.*
include dpctl/tests/input_files/*
22 changes: 11 additions & 11 deletions dpctl-capi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,24 +151,24 @@ target_link_libraries(DPCTLSyclInterface
PRIVATE ${IntelSycl_OPENCL_LIBRARY}
)

include(GetProjectVersion)
# the get_version function is defined in the GetProjectVersion module and
# defines: VERSION, SEMVER, MAJOR, MINOR, PATCH. These variables are populated
# by parsing the output of git describe.
get_version()
set_target_properties(DPCTLSyclInterface
PROPERTIES
VERSION ${VERSION_MAJOR}.${VERSION_MINOR}
SOVERSION ${VERSION_MAJOR}
)

if(DPCTL_ENABLE_LO_PROGRAM_CREATION)
target_include_directories(DPCTLSyclInterface
PRIVATE
${LEVEL_ZERO_INCLUDE_DIR}
)
endif()

# FIXME: Turning off for release until conda build can be packaging symbolic links
# NOTE: Till we hit 1.0.0 we will keep using the MINOR version to set the API
# version of the library.
# include(GetProjectVersion)
# the get_version function is defined in the GetProjectVersion module and
# defines: VERSION, SEMVER, MAJOR, MINOR, PATCH. These variables are populated
# by parsing the output of git describe.
# get_version()
# set_target_properties(DPCTLSyclInterface PROPERTIES VERSION ${VERSION_MINOR})
# set_target_properties(DPCTLSyclInterface PROPERTIES SOVERSION 1)

install(TARGETS
DPCTLSyclInterface
LIBRARY
Expand Down
49 changes: 48 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import glob
import os
import os.path
import shutil
import sys

import numpy as np
import setuptools.command.build_ext as orig_build_ext
import setuptools.command.build_py as orig_build_py
import setuptools.command.develop as orig_develop
import setuptools.command.install as orig_install
from Cython.Build import cythonize
Expand Down Expand Up @@ -251,6 +254,34 @@ def run(self):
return super().run()


class build_py(orig_build_py.build_py):
def run(self):
dpctl_src_dir = self.get_package_dir("dpctl")
dpctl_build_dir = os.path.join(self.build_lib, "dpctl")
os.makedirs(dpctl_build_dir, exist_ok=True)
if IS_LIN:
for fn in glob.glob(os.path.join(dpctl_src_dir, "*.so*")):
# Check if the file already exists before copying. The check is
# needed when dealing with symlinks.
if not os.path.exists(
os.path.join(dpctl_build_dir, os.path.basename(fn))
):
shutil.copy(
src=fn,
dst=dpctl_build_dir,
follow_symlinks=False,
)
elif IS_WIN:
for fn in glob.glob(os.path.join(dpctl_src_dir, "*.lib")):
shutil.copy(src=fn, dst=dpctl_build_dir)

for fn in glob.glob(os.path.join(dpctl_src_dir, "*.dll")):
shutil.copy(src=fn, dst=dpctl_build_dir)
else:
raise NotImplementedError("Unsupported platform")
return super().run()


class install(orig_install.install):
description = "Installs dpctl into Python prefix"
user_options = orig_install.install.user_options + [
Expand Down Expand Up @@ -308,7 +339,22 @@ def run(self):
else:
self.define = ",".join((pre_d, "CYTHON_TRACE"))
cythonize(self.distribution.ext_modules)
return super().run()
ret = super().run()
if IS_LIN:
dpctl_build_dir = os.path.join(
os.path.dirname(__file__), self.build_lib, "dpctl"
)
dpctl_install_dir = os.path.join(self.install_libbase, "dpctl")
for fn in glob.glob(
os.path.join(dpctl_install_dir, "*DPCTLSyclInterface.so*")
):
os.remove(fn)
shutil.copy(
src=os.path.join(dpctl_build_dir, os.path.basename(fn)),
dst=dpctl_install_dir,
follow_symlinks=False,
)
return ret


class develop(orig_develop.develop):
Expand Down Expand Up @@ -393,6 +439,7 @@ def _get_cmdclass():
cmdclass["install"] = install
cmdclass["develop"] = develop
cmdclass["build_ext"] = build_ext
cmdclass["build_py"] = build_py
return cmdclass


Expand Down