-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
569e70c
commit 378f16b
Showing
1 changed file
with
131 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,131 +1,131 @@ | ||
import os | ||
from conans import ConanFile, CMake, tools | ||
from conans.errors import ConanException | ||
|
||
|
||
class XmsinterpConan(ConanFile): | ||
name = "xmsmesher" | ||
# version = None # This no longer worked after conan version 1.11 | ||
license = "BSD2" | ||
url = "https://github.com/Aquaveo/xmsmesher" | ||
description = "Meshing library for XMS products" | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = { | ||
"xms": [True, False], | ||
"pybind": [True, False], | ||
"testing": [True, False], | ||
} | ||
default_options = "xms=False", "pybind=False", "testing=False" | ||
generators = "cmake" | ||
build_requires = "cxxtest/4.4@aquaveo/stable" | ||
exports = "CMakeLists.txt", "LICENSE", "test_files/*" | ||
exports_sources = "xmsmesher/*", "_package/*" | ||
|
||
def configure(self): | ||
# Set verion dynamically using XMS_VERSION env variable. | ||
self.version = self.env.get('XMS_VERSION', '99.99.99') | ||
|
||
# Raise ConanExceptions for Unsupported Versions | ||
s_os = self.settings.os | ||
s_compiler = self.settings.compiler | ||
s_compiler_version = self.settings.compiler.version | ||
|
||
self.options['xmscore'].xms = self.options.xms | ||
self.options['xmscore'].pybind = self.options.pybind | ||
self.options['xmscore'].testing = self.options.testing | ||
|
||
self.options['xmsinterp'].xms = self.options.xms | ||
self.options['xmsinterp'].pybind = self.options.pybind | ||
self.options['xmsinterp'].testing = self.options.testing | ||
|
||
self.options['xmsgrid'].xms = self.options.xms | ||
self.options['xmsgrid'].pybind = self.options.pybind | ||
self.options['xmsgrid'].testing = self.options.testing | ||
|
||
if s_compiler == "apple-clang" and s_os == 'Linux': | ||
raise ConanException("Clang on Linux is not supported.") | ||
|
||
if s_compiler == "apple-clang" \ | ||
and s_os == 'Macos' \ | ||
and float(s_compiler_version.value) < 9.0: | ||
raise ConanException("Clang > 9.0 is required for Mac.") | ||
|
||
def requirements(self): | ||
"""Requirements.""" | ||
self.requires("boost/1.74.0@aquaveo/stable") | ||
# Pybind if not clang | ||
if not self.settings.compiler == "clang" and self.options.pybind: | ||
self.requires("pybind11/2.5.0@aquaveo/testing") | ||
|
||
self.requires("xmscore/4.0.0-rc1@aquaveo/testing") | ||
self.requires("xmsgrid/5.0.0-rc1@aquaveo/testing") | ||
self.requires("xmsinterp/4.0.0-rc1@aquaveo/testing") | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
|
||
if self.settings.compiler == 'Visual Studio': | ||
cmake.definitions["XMS_BUILD"] = self.options.xms | ||
|
||
# CXXTest doesn't play nice with PyBind. Also, it would be nice to not | ||
# have tests in release code. Thus, if we want to run tests, we will | ||
# build a test version (without python), run the tests, and then (on | ||
# sucess) rebuild the library without tests. | ||
cmake.definitions["XMS_VERSION"] = '{}'.format(self.version) | ||
cmake.definitions["IS_PYTHON_BUILD"] = self.options.pybind | ||
cmake.definitions["BUILD_TESTING"] = self.options.testing | ||
cmake.definitions["XMS_TEST_PATH"] = "test_files" | ||
cmake.definitions["PYTHON_TARGET_VERSION"] = self.env.get("PYTHON_TARGET_VERSION", "3.6") | ||
cmake.configure(source_folder=".") | ||
cmake.build() | ||
cmake.install() | ||
|
||
if self.options.testing: | ||
print("***********(0.0)*************") | ||
try: | ||
cmake.test() | ||
except ConanException: | ||
raise | ||
finally: | ||
if os.path.isfile("TEST-cxxtest.xml"): | ||
with open("TEST-cxxtest.xml", "r") as f: | ||
for line in f.readlines(): | ||
no_newline = line.strip('\n') | ||
print(no_newline) | ||
print("***********(0.0)*************") | ||
elif self.options.pybind: | ||
with tools.pythonpath(self): | ||
if not self.settings.os == "Macos": | ||
self.run('pip install --user numpy wheel') | ||
else: | ||
self.run('pip install numpy wheel') | ||
self.run('python -m unittest discover -v -p *_pyt.py -s {}/_package/tests'.format( | ||
os.path.join(self.build_folder)), cwd=os.path.join(self.package_folder, "_package")) | ||
# Create and upload wheel to aquapi if release and windows | ||
# We are uploading to aquapi here instead of pypi because pypi doesn't accept | ||
# the type of package 'linux_x86_64 that we want to upload. They only accept | ||
# manylinux1 as the plat-tag | ||
is_release = self.env.get("RELEASE_PYTHON", 'False') | ||
if is_release == 'True' and ((self.settings.os == "Macos" or (self.settings.os == "Linux" and float(self.settings.compiler.version.value) == 6.0)) | ||
or (self.settings.os == "Windows" and | ||
str(self.settings.compiler.runtime) == "MD")): | ||
devpi_url = self.env.get("AQUAPI_URL", 'NO_URL') | ||
devpi_username = self.env.get("AQUAPI_USERNAME", 'NO_USERNAME') | ||
devpi_password = self.env.get("AQUAPI_PASSWORD", 'NO_PASSWORD') | ||
self.run('devpi use {}'.format(devpi_url)) | ||
self.run('devpi login {} --password {}'.format(devpi_username, devpi_password)) | ||
plat_names = {'Windows': 'win_amd64', 'Linux': 'linux_x86_64', "Macos": 'macosx-10.6-intel'} | ||
self.run('python setup.py bdist_wheel --plat-name={} --dist-dir {}'.format( | ||
plat_names[str(self.settings.os)], | ||
os.path.join(self.build_folder, "dist")), cwd=os.path.join(self.package_folder, "_package")) | ||
self.run('devpi upload --from-dir {}'.format(os.path.join(self.build_folder, "dist")), cwd=".") | ||
|
||
def package(self): | ||
self.copy("license", dst="licenses", ignore_case=True, keep_path=False) | ||
|
||
def package_info(self): | ||
self.env_info.PYTHONPATH.append(os.path.join(self.package_folder, "_package")) | ||
if self.settings.build_type == 'Debug': | ||
self.cpp_info.libs = ["xmsmesherlib_d"] | ||
else: | ||
self.cpp_info.libs = ["xmsmesherlib"] | ||
import os | ||
from conans import ConanFile, CMake, tools | ||
from conans.errors import ConanException | ||
|
||
|
||
class XmsinterpConan(ConanFile): | ||
name = "xmsmesher" | ||
# version = None # This no longer worked after conan version 1.11 | ||
license = "BSD2" | ||
url = "https://github.com/Aquaveo/xmsmesher" | ||
description = "Meshing library for XMS products" | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = { | ||
"xms": [True, False], | ||
"pybind": [True, False], | ||
"testing": [True, False], | ||
} | ||
default_options = "xms=False", "pybind=False", "testing=False" | ||
generators = "cmake" | ||
build_requires = "cxxtest/4.4@aquaveo/stable" | ||
exports = "CMakeLists.txt", "LICENSE", "test_files/*" | ||
exports_sources = "xmsmesher/*", "_package/*" | ||
|
||
def configure(self): | ||
# Set verion dynamically using XMS_VERSION env variable. | ||
self.version = self.env.get('XMS_VERSION', '99.99.99') | ||
|
||
# Raise ConanExceptions for Unsupported Versions | ||
s_os = self.settings.os | ||
s_compiler = self.settings.compiler | ||
s_compiler_version = self.settings.compiler.version | ||
|
||
self.options['xmscore'].xms = self.options.xms | ||
self.options['xmscore'].pybind = self.options.pybind | ||
self.options['xmscore'].testing = self.options.testing | ||
|
||
self.options['xmsinterp'].xms = self.options.xms | ||
self.options['xmsinterp'].pybind = self.options.pybind | ||
self.options['xmsinterp'].testing = self.options.testing | ||
|
||
self.options['xmsgrid'].xms = self.options.xms | ||
self.options['xmsgrid'].pybind = self.options.pybind | ||
self.options['xmsgrid'].testing = self.options.testing | ||
|
||
if s_compiler == "apple-clang" and s_os == 'Linux': | ||
raise ConanException("Clang on Linux is not supported.") | ||
|
||
if s_compiler == "apple-clang" \ | ||
and s_os == 'Macos' \ | ||
and float(s_compiler_version.value) < 9.0: | ||
raise ConanException("Clang > 9.0 is required for Mac.") | ||
|
||
def requirements(self): | ||
"""Requirements.""" | ||
self.requires("boost/1.74.0@aquaveo/stable") | ||
# Pybind if not clang | ||
if not self.settings.compiler == "clang" and self.options.pybind: | ||
self.requires("pybind11/2.5.0@aquaveo/testing") | ||
|
||
self.requires("xmscore/4.0.0-rc14@aquaveo/testing") | ||
self.requires("xmsgrid/5.0.0-rc3@aquaveo/testing") | ||
self.requires("xmsinterp/4.0.0-rc1@aquaveo/testing") | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
|
||
if self.settings.compiler == 'Visual Studio': | ||
cmake.definitions["XMS_BUILD"] = self.options.xms | ||
|
||
# CXXTest doesn't play nice with PyBind. Also, it would be nice to not | ||
# have tests in release code. Thus, if we want to run tests, we will | ||
# build a test version (without python), run the tests, and then (on | ||
# sucess) rebuild the library without tests. | ||
cmake.definitions["XMS_VERSION"] = '{}'.format(self.version) | ||
cmake.definitions["IS_PYTHON_BUILD"] = self.options.pybind | ||
cmake.definitions["BUILD_TESTING"] = self.options.testing | ||
cmake.definitions["XMS_TEST_PATH"] = "test_files" | ||
cmake.definitions["PYTHON_TARGET_VERSION"] = self.env.get("PYTHON_TARGET_VERSION", "3.6") | ||
cmake.configure(source_folder=".") | ||
cmake.build() | ||
cmake.install() | ||
|
||
if self.options.testing: | ||
print("***********(0.0)*************") | ||
try: | ||
cmake.test() | ||
except ConanException: | ||
raise | ||
finally: | ||
if os.path.isfile("TEST-cxxtest.xml"): | ||
with open("TEST-cxxtest.xml", "r") as f: | ||
for line in f.readlines(): | ||
no_newline = line.strip('\n') | ||
print(no_newline) | ||
print("***********(0.0)*************") | ||
elif self.options.pybind: | ||
with tools.pythonpath(self): | ||
if not self.settings.os == "Macos": | ||
self.run('pip install --user numpy wheel') | ||
else: | ||
self.run('pip install numpy wheel') | ||
self.run('python -m unittest discover -v -p *_pyt.py -s {}/_package/tests'.format( | ||
os.path.join(self.build_folder)), cwd=os.path.join(self.package_folder, "_package")) | ||
# Create and upload wheel to aquapi if release and windows | ||
# We are uploading to aquapi here instead of pypi because pypi doesn't accept | ||
# the type of package 'linux_x86_64 that we want to upload. They only accept | ||
# manylinux1 as the plat-tag | ||
is_release = self.env.get("RELEASE_PYTHON", 'False') | ||
if is_release == 'True' and ((self.settings.os == "Macos" or (self.settings.os == "Linux" and float(self.settings.compiler.version.value) == 6.0)) | ||
or (self.settings.os == "Windows" and | ||
str(self.settings.compiler.runtime) == "MD")): | ||
devpi_url = self.env.get("AQUAPI_URL", 'NO_URL') | ||
devpi_username = self.env.get("AQUAPI_USERNAME", 'NO_USERNAME') | ||
devpi_password = self.env.get("AQUAPI_PASSWORD", 'NO_PASSWORD') | ||
self.run('devpi use {}'.format(devpi_url)) | ||
self.run('devpi login {} --password {}'.format(devpi_username, devpi_password)) | ||
plat_names = {'Windows': 'win_amd64', 'Linux': 'linux_x86_64', "Macos": 'macosx-10.6-intel'} | ||
self.run('python setup.py bdist_wheel --plat-name={} --dist-dir {}'.format( | ||
plat_names[str(self.settings.os)], | ||
os.path.join(self.build_folder, "dist")), cwd=os.path.join(self.package_folder, "_package")) | ||
self.run('devpi upload --from-dir {}'.format(os.path.join(self.build_folder, "dist")), cwd=".") | ||
|
||
def package(self): | ||
self.copy("license", dst="licenses", ignore_case=True, keep_path=False) | ||
|
||
def package_info(self): | ||
self.env_info.PYTHONPATH.append(os.path.join(self.package_folder, "_package")) | ||
if self.settings.build_type == 'Debug': | ||
self.cpp_info.libs = ["xmsmesherlib_d"] | ||
else: | ||
self.cpp_info.libs = ["xmsmesherlib"] |