Skip to content

Commit

Permalink
Port from setuptools.build_meta to meson-python
Browse files Browse the repository at this point in the history
  • Loading branch information
monego committed Dec 7, 2023
1 parent b9c89e7 commit 26dfc71
Show file tree
Hide file tree
Showing 13 changed files with 162 additions and 273 deletions.
1 change: 0 additions & 1 deletion cf_units/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
)

from . import config
from ._version import version as __version__ # noqa: F401
from .util import _OrderedHashable

__all__ = [
Expand Down
13 changes: 13 additions & 0 deletions cf_units/_udunits2_parser/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
python_sources = [
'__init__.py',
'compile.py',
'graph.py',
]

py.install_sources(
python_sources,
pure: false,
subdir: 'cf_units/_udunits2_parser'
)

subdir('parser')
12 changes: 12 additions & 0 deletions cf_units/_udunits2_parser/parser/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
python_sources = [
'__init__.py',
'udunits2Lexer.py',
'udunits2Parser.py',
'udunits2ParserVisitor.py',
]

py.install_sources(
python_sources,
pure: false,
subdir: 'cf_units/_udunits2_parser/parser'
)
25 changes: 25 additions & 0 deletions cf_units/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
python_sources = [
'__init__.py',
'config.py',
'tex.py',
'util.py',
]

py.install_sources(
python_sources,
pure: false,
subdir: 'cf_units'
)

udunits2 = dependency('udunits')

py.extension_module(
'_udunits2',
['_udunits2.pyx'],
dependencies: [udunits2],
install: true,
subdir: 'cf_units'
)

subdir('tests')
subdir('_udunits2_parser')
16 changes: 16 additions & 0 deletions cf_units/tests/integration/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
python_sources = [
'__init__.py',
'test_date2num.py',
'test_num2date.py',
'test_num2pydate.py',
'test__Unit_date2num.py',
'test__Unit_num2date.py',
]

py.install_sources(
python_sources,
pure: false,
subdir: 'cf_units/tests/integration'
)

subdir('parse')
10 changes: 10 additions & 0 deletions cf_units/tests/integration/parse/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
python_sources = [
'test_graph.py',
'test_parse.py',
]

py.install_sources(
python_sources,
pure: false,
subdir: 'cf_units/tests/integration/parse'
)
15 changes: 15 additions & 0 deletions cf_units/tests/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
python_sources = [
'__init__.py',
'test_coding_standards.py',
'test_tex.py',
'test_unit.py',
]

py.install_sources(
python_sources,
pure: false,
subdir: 'cf_units/tests'
)

subdir('integration')
subdir('unit')
12 changes: 12 additions & 0 deletions cf_units/tests/unit/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
python_sources = [
'__init__.py',
'test__udunits2.py',
]

py.install_sources(
python_sources,
pure: false,
subdir: 'cf_units/tests/unit'
)

subdir('unit')
10 changes: 10 additions & 0 deletions cf_units/tests/unit/unit/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
python_sources = [
'test_as_unit.py',
'test_Unit.py',
]

py.install_sources(
python_sources,
pure: false,
subdir: 'cf_units/tests/unit/unit'
)
6 changes: 6 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
project('cf-units', 'cython', version: '1.3.0')

py_mod = import('python')
py = py_mod.find_installation(pure: true)

subdir('cf_units')
61 changes: 43 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
[build-system]
# Defined by PEP 518
requires = [
"setuptools>=45",
"setuptools_scm[toml]>=7.0",
"wheel",
"oldest-supported-numpy",
"Cython"
[project]
name = "cf-units"
dynamic = ["version"]
description = "Units of measure as required by the Climate and Forecast (CF) Metadata Conventions"
requires-python = ">=3.10"
readme = "README.md"
dependencies = [
'python>=3.8',
'cftime>=1.6',
'Jinja2>=3',
'numpy>=1.18',
'antlr4-python3-runtime==4.11.1',
]

[project.optional-dependencies]
build = [
'Cython>=3',
'meson-python>=0.15.0',
'pytest>=7',
'spin>=0.8',
]
# Defined by PEP 517
build-backend = "setuptools.build_meta"

[build-system]
requires = ['meson-python', 'cython']
build-backend = 'mesonpy'

[tool.coverage.run]
branch = true
Expand All @@ -19,8 +33,6 @@ include = [
"cf_units/*"
]
omit = [
"setup.py",
"cf_units/_version.py",
"cf_units/etc/*",
"cf_units/tests/*",
"cf_units/_udunits2_parser/parser/*",
Expand All @@ -35,12 +47,6 @@ exclude_lines = [
"if __name__ == .__main__.:"
]

[tool.pytest.ini_options]
addopts = "-ra -v --doctest-modules"
doctest_optionflags = "NORMALIZE_WHITESPACE ELLIPSIS NUMBER"
minversion = "6.0"
testpaths = "cf_units"

[tool.setuptools_scm]
write_to = "cf_units/_version.py"
local_scheme = "dirty-tag"
Expand Down Expand Up @@ -73,3 +79,22 @@ line_length = 79
profile = "black"
skip_gitignore = "True"
verbose = "False"

[tool.spin]
package = 'cf_units'

[tool.spin.commands]
Build = [
'spin.cmds.meson.build',
'spin.cmds.meson.test',
'spin.cmds.build.sdist',
]
Environments = [
'spin.cmds.meson.run',
'spin.cmds.meson.python',
]

[tool.pytest.ini_options]
addopts = "-ra -v --doctest-modules"
doctest_optionflags = "NORMALIZE_WHITESPACE ELLIPSIS NUMBER"
minversion = "6.0"
98 changes: 0 additions & 98 deletions setup.cfg

This file was deleted.

Loading

0 comments on commit 26dfc71

Please sign in to comment.