Skip to content

Commit b0899fa

Browse files
committed
[Build] Fix incorrect Version metadata in dist-info
Closes #123. The CMake script has the ability to simulate a Python package installation, such that a `dist-info` metadata directory is installed alongside the package, effectively preventing accidental overwrite by other package managers (e.g. pip) when the project is installed via CMake - see #58. However, the `Version` field in the `METADATA` file that forms part of the Python package `dist-info` was not being properly filled in. This was not caught by CI because the test for it is only enabled if generation of Python traits via CMake is enabled (i.e. `OPENASSETIO_MEDIACREATION_GENERATE_PYTHON`), which was not the case for the "test" CMake preset used by the "Test Cpp" CI job. There was another problem with running the test, in that the PYTHONPATH was not properly set in the CMake test target, and so the test would not necessarily be able to locate the `openassetio-mediacreation` package installed by CMake. Signed-off-by: David Feltell <david.feltell@foundry.com>
1 parent 37192e9 commit b0899fa

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ jobs:
4646
- name: Install Traitgen
4747
run: python -m pip install openassetio-traitgen
4848

49+
- name: Install Python test dependencies
50+
run: python -m pip install -r tests/python/requirements.txt
51+
4952
- name: Configure CMake build
5053
run: |
5154
cmake -S . -DCMAKE_PREFIX_PATH=$(pwd)/openassetio -B build -G Ninja --preset test

CMakePresets.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"dev": true
88
},
99
"cacheVariables": {
10-
"OPENASSETIO_MEDIACREATION_ENABLE_TEST": "ON"
10+
"OPENASSETIO_MEDIACREATION_ENABLE_TEST": "ON",
11+
"OPENASSETIO_MEDIACREATION_GENERATE_PYTHON": "ON"
1112
}
1213
}
1314
]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Metadata-Version: 2.1
22
Name: openassetio-mediacreation
3-
Version: @OPENASSETIO_MEDIACREATION_PYTHON_PACKAGE_VERSION@
3+
Version: @OPENASSETIO_MEDIACREATION_PYTHON_PKG_VERSION@

tests/cpp/CMakeLists.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,13 @@ target_compile_features(test.cpp PRIVATE cxx_std_17)
1717

1818
if (OPENASSETIO_MEDIACREATION_ENABLE_PYTHON_INSTALL_DIST_INFO)
1919

20-
# Build the command to extend the PYTHONPATH such that the
21-
# site-packages directory in the install tree is included correctly.
22-
set(_set_pythonpath_command
23-
PYTHONPATH=${CMAKE_INSTALL_PREFIX}/${OPENASSETIO_MEDIACREATION_PYTHON_SITEDIR})
24-
2520
# Add pytest target to run the packaging tests. These are concerned
2621
# with python metadata information so run in a python context.
2722
add_custom_target(
2823
openassetio-mediacreation.tests.packaging
2924
COMMAND cmake -E echo -- "Running pytest check for CMake dist-info packaging"
30-
COMMAND ${_set_pythonpath_command} &&
25+
COMMAND ${CMAKE_COMMAND} -E env
26+
PYTHONPATH=${CMAKE_INSTALL_PREFIX}/${OPENASSETIO_MEDIACREATION_PYTHON_SITEDIR}
3127
pytest -v --capture=tee-sys
3228
"${CMAKE_CURRENT_LIST_DIR}/test_cmake.py"
3329
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"

0 commit comments

Comments
 (0)