Skip to content

Commit

Permalink
meson.build changes to switch windows to C++11
Browse files Browse the repository at this point in the history
  • Loading branch information
peekxc committed Aug 17, 2023
1 parent bd06462 commit 8e7a15e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 66 deletions.
32 changes: 5 additions & 27 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,26 @@ project('simplextree', 'cpp', default_options : ['cpp_std=c++17'])
py_mod = import('python')
py = py_mod.find_installation(pure: true)
py_dep = py.dependency()
message(py.path())
message(run_command(py, ['-c', 'import numpy; print(numpy.__version__)']).stdout().strip())
message('Python path =' + py.path())
message('Numpy version =' + run_command(py, ['-c', 'import numpy; print(numpy.__version__)'], check: true).stdout().strip())

## Check the python version
if py.language_version().version_compare('< 3.8')
error('Invalid Python version, only >= 3.8 is supported.')
endif

## Message the C++ compiler location for debugging
compiler = meson.get_compiler('cpp')
message('Compiler: ')
message(compiler.get_id())

## Header includes
inc_pybind11 = include_directories('extern' / 'pybind11' / 'include')
inc_local = include_directories('include')
incdir_numpy = run_command(py,
['-c', 'import os; os.chdir(".."); import numpy; print(numpy.get_include())'],
check : true
).stdout().strip()
incdir_numpy = run_command(py, ['-c', 'import os; os.chdir(".."); import numpy; print(numpy.get_include())'], check : true).stdout().strip()
inc_np = include_directories(incdir_numpy)

## Platform detection
is_windows = host_machine.system() == 'windows'

## Compile the package directory
subdir('simplextree')

## Install the package
# install_subdir('simplextree', install_dir: py.get_install_dir(pure: false))

# py.extension_module(
# '_simplextree',
# 'simplextree' / '_simplextree.cpp',
# install: true,
# include_directories: [inc_local, incdir_numpy, inc_pybind11]
# )
# py.extension_module(
# '_unionfind',
# 'simplextree' / '_unionfind.cpp',
# install: true,
# include_directories: [inc_local, incdir_numpy, inc_pybind11]
# )

# py.install_sources(
# 'src/simplextree/__init__.py',
# subdir: 'src/simplextree',
Expand Down
22 changes: 1 addition & 21 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ requires = ['meson-python', "wheel", "ninja", "pybind11", "numpy"]

[project]
name = "simplextree"
version = '0.0.3'
version = '0.1.0'
readme = "README.md"
classifiers = [
"Intended Audience :: Science/Research",
Expand All @@ -29,7 +29,6 @@ Repository = "https://github.com/peekxc/simplextree-py"
Changelog = "https://github.com/peekxc/simplextree-py/blob/main/CHANGELOG.md"
# Documentation = "https://simplextree.readthedocs.io/"


[project.optional-dependencies]
dev = [
"ruff",
Expand All @@ -48,25 +47,6 @@ dev = [
[tool.meson-python.args]
setup = ['--default-library=static']

[tool.setuptools.packages.find]
exclude = [
"*.tests",
"*.tests.*",
"tests.*",
"tests",
"docs*",
"scripts*"
]

[tool.setuptools]
include-package-data = true

[tool.setuptools.package-data]
simplextree = ["py.typed"]

[tool.setuptools.dynamic]
version = { attr = "simplextree.VERSION" }

[tool.black]
line-length = 180
include = '\.pyi?$'
Expand Down
1 change: 0 additions & 1 deletion simplextree/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

from .version import VERSION, VERSION_SHORT
from .SimplexTree import SimplexTree
from .UnionFind import UnionFind
27 changes: 17 additions & 10 deletions simplextree/meson.build
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
## Message the C++ compiler location for debugging
compiler = meson.get_compiler('cpp')
message('Compiler = '+compiler.get_id())

## Platform detection
cpp_std = 'c++17'
is_windows = host_machine.system() == 'windows'

## Windows adjustments
is_mingw = is_windows and compiler.get_id() == 'gcc'
if is_windows
gcc_link_args = ['-lucrt', '-static'] # For mingw-w64, link statically against the UCRT.
if is_windows
cpp_std = 'c++11'
if is_mingw
add_project_link_arguments(gcc_link_args, language: ['cpp'])
add_project_link_arguments(['-lucrt', '-static'], language: ['cpp']) # For mingw-w64, link statically against the UCRT.
add_project_arguments('-D__USE_MINGW_ANSI_STDIO=1', language: ['cpp']) # https://github.com/rgommers/scipy/issues/118
endif
endif
endif
endif

## Extension modules
py.extension_module(
'_simplextree',
'_simplextree.cpp',
install: true,
include_directories: [inc_local, incdir_numpy, inc_pybind11]
include_directories: [inc_local, incdir_numpy, inc_pybind11],
cpp_args: ['-std=' + cpp_std]
)
py.extension_module(
'_unionfind',
'_unionfind.cpp',
install: true,
include_directories: [inc_local, incdir_numpy, inc_pybind11]
include_directories: [inc_local, incdir_numpy, inc_pybind11],
cpp_args: ['-std=' + cpp_std]
)

python_sources = [
Expand All @@ -30,9 +39,7 @@ python_sources = [
]

## Print install directory
message('Install directory for sources: ')
message(py.get_install_dir())

message('Source install dir = '+py.get_install_dir())
py.install_sources(
python_sources,
subdir: 'simplextree'
Expand Down
Empty file removed simplextree/py.typed
Empty file.
7 changes: 0 additions & 7 deletions simplextree/version.py

This file was deleted.

0 comments on commit 8e7a15e

Please sign in to comment.