pytest-cmake 0.13.0__tar.gz → 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-cmake
3
- Version: 0.13.0
3
+ Version: 1.0.0
4
4
  Summary: Provide CMake module for Pytest
5
5
  Project-URL: Documentation, https://python-cmake.github.io/pytest-cmake
6
6
  Project-URL: Repository, https://github.com/python-cmake/pytest-cmake
@@ -32,8 +32,6 @@ License-File: LICENSE
32
32
  Keywords: cmake,development,pytest
33
33
  Classifier: Intended Audience :: Developers
34
34
  Classifier: License :: OSI Approved :: MIT License
35
- Classifier: Programming Language :: Python :: 2
36
- Classifier: Programming Language :: Python :: 2.7
37
35
  Classifier: Programming Language :: Python :: 3
38
36
  Classifier: Programming Language :: Python :: 3.7
39
37
  Classifier: Programming Language :: Python :: 3.8
@@ -41,15 +39,16 @@ Classifier: Programming Language :: Python :: 3.9
41
39
  Classifier: Programming Language :: Python :: 3.10
42
40
  Classifier: Programming Language :: Python :: 3.11
43
41
  Classifier: Programming Language :: Python :: 3.12
42
+ Classifier: Programming Language :: Python :: 3.13
44
43
  Classifier: Topic :: Software Development :: Build Tools
45
- Requires-Python: !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,<4,>=2.7
44
+ Requires-Python: <4,>=3.7
46
45
  Requires-Dist: pytest<9,>=4
47
46
  Description-Content-Type: text/markdown
48
47
 
49
48
  # Pytest CMake
50
49
 
51
50
  [![PyPi version](https://img.shields.io/pypi/v/pytest-cmake.svg?logo=pypi&label=PyPI&logoColor=gold)](https://pypi.python.org/pypi/pytest-cmake)
52
- [![CMake](https://img.shields.io/badge/CMake-3.20...3.30-blue.svg?logo=CMake&logoColor=blue)](https://cmake.org)
51
+ [![CMake](https://img.shields.io/badge/CMake-3.20...4.1-blue.svg?logo=CMake&logoColor=blue)](https://cmake.org)
53
52
  [![Test](https://github.com/python-cmake/pytest-cmake/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/python-cmake/pytest-cmake/actions/workflows/test.yml)
54
53
  [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
55
54
 
@@ -1,7 +1,7 @@
1
1
  # Pytest CMake
2
2
 
3
3
  [![PyPi version](https://img.shields.io/pypi/v/pytest-cmake.svg?logo=pypi&label=PyPI&logoColor=gold)](https://pypi.python.org/pypi/pytest-cmake)
4
- [![CMake](https://img.shields.io/badge/CMake-3.20...3.30-blue.svg?logo=CMake&logoColor=blue)](https://cmake.org)
4
+ [![CMake](https://img.shields.io/badge/CMake-3.20...4.1-blue.svg?logo=CMake&logoColor=blue)](https://cmake.org)
5
5
  [![Test](https://github.com/python-cmake/pytest-cmake/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/python-cmake/pytest-cmake/actions/workflows/test.yml)
6
6
  [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
 
@@ -33,7 +33,7 @@ class BuildConfig(BuildHookInterface):
33
33
  stream.write(
34
34
  "include(CMakePackageConfigHelpers)\n"
35
35
  "write_basic_package_version_file(\n"
36
- f" \"{str(version_config_path)}\"\n"
36
+ f" \"{str(version_config_path.as_posix())}\"\n"
37
37
  f" VERSION {pytest.__version__}\n"
38
38
  " COMPATIBILITY AnyNewerVersion\n"
39
39
  ")"
@@ -17,7 +17,7 @@
17
17
  # prepend a custom search path.
18
18
  # (https://cmake.org/cmake/help/latest/policy/CMP0074.html)
19
19
 
20
- cmake_minimum_required(VERSION 3.20...3.30)
20
+ cmake_minimum_required(VERSION 3.20...4.1)
21
21
 
22
22
  include(FindPackageHandleStandardArgs)
23
23
 
@@ -55,10 +55,34 @@ if (Pytest_FOUND AND NOT TARGET Pytest::Pytest)
55
55
 
56
56
  # Function to discover pytest tests and add them to CTest.
57
57
  function(pytest_discover_tests NAME)
58
+ set(_BOOL_ARGS
59
+ STRIP_PARAM_BRACKETS
60
+ INCLUDE_FILE_PATH
61
+ BUNDLE_TESTS
62
+ )
63
+
64
+ set(_SINGLE_VALUE_ARGS
65
+ WORKING_DIRECTORY
66
+ TRIM_FROM_NAME
67
+ TRIM_FROM_FULL_NAME
68
+ )
69
+
70
+ set(_MULTI_VALUE_ARGS
71
+ TEST_PATHS
72
+ LIBRARY_PATH_PREPEND
73
+ PYTHON_PATH_PREPEND
74
+ ENVIRONMENT
75
+ PROPERTIES
76
+ DEPENDS
77
+ EXTRA_ARGS
78
+ DISCOVERY_EXTRA_ARGS
79
+ )
80
+
58
81
  cmake_parse_arguments(
59
- PARSE_ARGV 1 "" "STRIP_PARAM_BRACKETS;INCLUDE_FILE_PATH;BUNDLE_TESTS"
60
- "WORKING_DIRECTORY;TRIM_FROM_NAME;TRIM_FROM_FULL_NAME"
61
- "LIBRARY_PATH_PREPEND;PYTHON_PATH_PREPEND;ENVIRONMENT;PROPERTIES;DEPENDS;EXTRA_ARGS;DISCOVERY_EXTRA_ARGS"
82
+ PARSE_ARGV 1 ""
83
+ "${_BOOL_ARGS}"
84
+ "${_SINGLE_VALUE_ARGS}"
85
+ "${_MULTI_VALUE_ARGS}"
62
86
  )
63
87
 
64
88
  # Set platform-specific library path environment variable.
@@ -119,6 +143,7 @@ if (Pytest_FOUND AND NOT TARGET Pytest::Pytest)
119
143
  DEPENDS ${_DEPENDS}
120
144
  COMMAND ${CMAKE_COMMAND}
121
145
  -D "PYTEST_EXECUTABLE=${PYTEST_EXECUTABLE}"
146
+ -D "TEST_PATHS=${_TEST_PATHS}"
122
147
  -D "TEST_GROUP_NAME=${NAME}"
123
148
  -D "BUNDLE_TESTS=${_BUNDLE_TESTS}"
124
149
  -D "LIBRARY_ENV_NAME=${LIBRARY_ENV_NAME}"
@@ -139,13 +164,13 @@ if (Pytest_FOUND AND NOT TARGET Pytest::Pytest)
139
164
  # Create a custom target to run the tests.
140
165
  add_custom_target(${NAME} ALL DEPENDS ${_tests_file})
141
166
 
142
- file(WRITE "${_include_file}"
143
- "if(EXISTS \"${_tests_file}\")\n"
144
- " include(\"${_tests_file}\")\n"
145
- "else()\n"
146
- " add_test(${NAME}_NOT_BUILT ${NAME}_NOT_BUILT)\n"
147
- "endif()\n"
148
- )
167
+ file(WRITE "${_include_file}"
168
+ "if(EXISTS \"${_tests_file}\")\n"
169
+ " include(\"${_tests_file}\")\n"
170
+ "else()\n"
171
+ " add_test(${NAME}_NOT_BUILT ${NAME}_NOT_BUILT)\n"
172
+ "endif()\n"
173
+ )
149
174
 
150
175
  # Register the include file to be processed for tests.
151
176
  set_property(DIRECTORY
@@ -1,5 +1,5 @@
1
1
  # Wrapper used to create individual CTest tests from Pytest tests.
2
- cmake_minimum_required(VERSION 3.20...3.30)
2
+ cmake_minimum_required(VERSION 3.20...4.1)
3
3
 
4
4
  if(CMAKE_SCRIPT_MODE_FILE)
5
5
 
@@ -38,14 +38,21 @@ if(CMAKE_SCRIPT_MODE_FILE)
38
38
  list(JOIN EXTRA_ARGS_WRAPPED " " EXTRA_ARGS_STR)
39
39
 
40
40
  # Macro to create individual tests with optional test properties.
41
- macro(create_test NAME IDENTIFIER)
42
- string(APPEND _content
43
- "add_test([==[${NAME}]==] \"${PYTEST_EXECUTABLE}\" [==[${IDENTIFIER}]==] ${EXTRA_ARGS_STR} )\n"
44
- )
41
+ macro(create_test NAME IDENTIFIERS)
42
+ string(APPEND _content "add_test([==[${NAME}]==] \"${PYTEST_EXECUTABLE}\"")
43
+
44
+ foreach(identifier ${IDENTIFIERS})
45
+ string(APPEND _content " [==[${identifier}]==]")
46
+ endforeach()
47
+
48
+ string(APPEND _content " ${EXTRA_ARGS_STR} )\n")
45
49
 
46
50
  # Prepare the properties for the test, including the environment settings.
47
51
  set(args "PROPERTIES ENVIRONMENT [==[${ENCODED_ENVIRONMENT}]==]")
48
52
 
53
+ # Add working directory
54
+ string(APPEND args " WORKING_DIRECTORY [==[${WORKING_DIRECTORY}]==]")
55
+
49
56
  # Append any additional properties, escaping complex characters if necessary.
50
57
  foreach(property ${TEST_PROPERTIES})
51
58
  if(property MATCHES "[^-./:a-zA-Z0-9_]")
@@ -61,7 +68,7 @@ if(CMAKE_SCRIPT_MODE_FILE)
61
68
 
62
69
  # If tests are bundled together, create a single test group.
63
70
  if (BUNDLE_TESTS)
64
- create_test("\${TEST_GROUP_NAME}" "\${WORKING_DIRECTORY}")
71
+ create_test("\${TEST_GROUP_NAME}" "\${TEST_PATHS}")
65
72
 
66
73
  else()
67
74
  # Set environment variables for collecting tests.
@@ -69,11 +76,19 @@ if(CMAKE_SCRIPT_MODE_FILE)
69
76
  set(ENV{PYTHONPATH} "${PYTHON_PATH}")
70
77
  set(ENV{PYTHONWARNINGS} "ignore")
71
78
 
79
+ set(_command
80
+ "${PYTEST_EXECUTABLE}" --collect-only -q
81
+ "--rootdir=${WORKING_DIRECTORY}"
82
+ ${DISCOVERY_EXTRA_ARGS}
83
+ )
84
+
85
+ foreach(test_path IN LISTS TEST_PATHS)
86
+ list(APPEND _command "${test_path}")
87
+ endforeach()
88
+
72
89
  # Collect tests.
73
90
  execute_process(
74
- COMMAND "${PYTEST_EXECUTABLE}"
75
- --collect-only -q
76
- --rootdir=${WORKING_DIRECTORY} ${DISCOVERY_EXTRA_ARGS} .
91
+ COMMAND ${_command}
77
92
  OUTPUT_VARIABLE _output_lines
78
93
  ERROR_VARIABLE _output_lines
79
94
  OUTPUT_STRIP_TRAILING_WHITESPACE
@@ -81,7 +96,7 @@ if(CMAKE_SCRIPT_MODE_FILE)
81
96
  )
82
97
 
83
98
  # Check for errors during test collection.
84
- string(REGEX MATCH "=+ ERRORS =+(.*)" _error "${_output_lines}")
99
+ string(REGEX MATCH "(=+ ERRORS =+|ERROR:).*" _error "${_output_lines}")
85
100
 
86
101
  if (_error)
87
102
  message(${_error})
@@ -141,7 +156,7 @@ if(CMAKE_SCRIPT_MODE_FILE)
141
156
 
142
157
  # Prefix the test name with the test group name.
143
158
  set(test_name "${TEST_GROUP_NAME}.${test_name}")
144
- set(test_case "${WORKING_DIRECTORY}/${line}")
159
+ set(test_case "${line}")
145
160
 
146
161
  # Create the test for CTest.
147
162
  create_test("\${test_name}" "\${test_case}")
@@ -1,18 +1,16 @@
1
1
  [build-system]
2
2
  requires = [
3
- "hatchling >= 1.4; python_version >= '3'",
4
- "setuptools >= 44; python_version < '3'",
5
- "cmake >= 3.20, < 3.31"
3
+ "hatchling >= 1.4",
4
+ "cmake >= 3.20, < 4.2"
6
5
  ]
7
- build-backend = "build_backend"
8
- backend-path = ["."]
6
+ build-backend = "hatchling.build"
9
7
 
10
8
  [project]
11
9
  name = "pytest-cmake"
12
- version = "0.13.0"
10
+ version = "1.0.0"
13
11
  description = "Provide CMake module for Pytest"
14
12
  readme = "README.md"
15
- requires-python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4"
13
+ requires-python = ">=3.7, <4"
16
14
  license = {file = "LICENSE"}
17
15
  keywords = ["cmake", "pytest", "development"]
18
16
  authors = [
@@ -25,8 +23,6 @@ classifiers = [
25
23
  "Intended Audience :: Developers",
26
24
  "Topic :: Software Development :: Build Tools",
27
25
  "License :: OSI Approved :: MIT License",
28
- "Programming Language :: Python :: 2",
29
- "Programming Language :: Python :: 2.7",
30
26
  "Programming Language :: Python :: 3",
31
27
  "Programming Language :: Python :: 3.7",
32
28
  "Programming Language :: Python :: 3.8",
@@ -34,6 +30,7 @@ classifiers = [
34
30
  "Programming Language :: Python :: 3.10",
35
31
  "Programming Language :: Python :: 3.11",
36
32
  "Programming Language :: Python :: 3.12",
33
+ "Programming Language :: Python :: 3.13",
37
34
  ]
38
35
 
39
36
  [project.urls]
@@ -56,4 +53,4 @@ path = "build_config.py"
56
53
  only-include = ["*.cmake"]
57
54
 
58
55
  [tool.hatch.build.targets.sdist]
59
- only-include = ["cmake", "build_config.py", "build_backend.py", "setup.py"]
56
+ only-include = ["cmake", "build_config.py"]
@@ -1,9 +0,0 @@
1
- """Custom backend to ensure compatibility with Python 2.7.
2
- """
3
-
4
- import sys
5
-
6
- if sys.version_info[0] < 3:
7
- from setuptools.build_meta import *
8
- else:
9
- from hatchling.build import *
@@ -1,78 +0,0 @@
1
- """Setuptools config only used for Python 2.7 compatibility.
2
- """
3
-
4
- from setuptools import setup
5
- from setuptools.command.install import install
6
-
7
- import os
8
- import subprocess
9
-
10
-
11
- ROOT = os.path.dirname(os.path.realpath(__file__))
12
- DEPENDENCIES = ["pytest >= 4, < 9"]
13
-
14
-
15
- class CreateCmakeConfig(install):
16
- """Custom command to create and share pytest config."""
17
-
18
- def run(self):
19
- """Execute builder."""
20
- import pytest
21
-
22
- build_path = os.path.join(ROOT, "build")
23
- if not os.path.exists(build_path):
24
- os.makedirs(build_path)
25
-
26
- # CMake search procedure is limited to CMake package configuration files
27
- # and does not work with modules. Hence, we are generating a
28
- # configuration file based on the CMake modules created.
29
- # https://cmake.org/cmake/help/latest/command/find_package.html
30
- config_path = os.path.join(build_path, "PytestConfig.cmake")
31
- with open(config_path, "w") as stream:
32
- stream.write(
33
- "include(${CMAKE_CURRENT_LIST_DIR}/FindPytest.cmake)\n"
34
- )
35
-
36
- # Generate CMake config version file for client to target a specific
37
- # version of Pytest within CMake projects.
38
- version_config_path = os.path.join(
39
- build_path, "PytestConfigVersion.cmake"
40
- )
41
- script_path = os.path.join(
42
- build_path, "PytestConfigVersionScript.cmake"
43
- )
44
- with open(script_path, "w") as stream:
45
- stream.write(
46
- "include(CMakePackageConfigHelpers)\n"
47
- "write_basic_package_version_file(\n"
48
- " \"{path}\"\n"
49
- " VERSION {version}\n"
50
- " COMPATIBILITY AnyNewerVersion\n"
51
- ")".format(
52
- path=str(version_config_path),
53
- version=pytest.__version__,
54
- )
55
- )
56
-
57
- subprocess.call(["cmake", "-P", str(script_path), "-VV"])
58
- return install.run(self)
59
-
60
-
61
- setup(
62
- name="pytest-cmake",
63
- version="0.13.0",
64
- data_files=[
65
- (
66
- "share/Pytest/cmake",
67
- [
68
- "build/PytestConfig.cmake",
69
- "build/PytestConfigVersion.cmake",
70
- "cmake/FindPytest.cmake",
71
- "cmake/PytestAddTests.cmake"
72
- ]
73
- )
74
- ],
75
- cmdclass={"install": CreateCmakeConfig},
76
- install_requires=DEPENDENCIES,
77
- setup_requires=DEPENDENCIES,
78
- )
File without changes
File without changes