diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 1ab9d14905..1e5e1cdf51 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,2 +1,28 @@ - +# Add the MDSplus Python package subdirectory add_subdirectory(MDSplus) + +# Find Python interpreter for building the wheel +find_package(Python3 COMPONENTS Interpreter REQUIRED) + +# Define where the wheel will be placed +set(WHEEL_OUTPUT_DIR ${CMAKE_BINARY_DIR}/python) + +# Ensure the output directory exists +file(MAKE_DIRECTORY ${WHEEL_OUTPUT_DIR}) + +# Custom target that depends on the build command +add_custom_target(build_wheel ALL + ${Python3_EXECUTABLE} -m pip wheel --wheel-dir ${WHEEL_OUTPUT_DIR} --no-deps ${CMAKE_CURRENT_SOURCE_DIR}/MDSplus + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/MDSplus/_version.py + COMMENT "Building MDSplus wheel" +) + +# After building the wheel, install it into the python directory of the project + +install(DIRECTORY ${WHEEL_OUTPUT_DIR} + DESTINATION ${CMAKE_INSTALL_PREFIX} + FILES_MATCHING + PATTERN "*.whl" + PATTERN "MDSplus" EXCLUDE + PATTERN "CMakeFiles" EXCLUDE +) diff --git a/python/MDSplus/CMakeLists.txt b/python/MDSplus/CMakeLists.txt index 823f873c98..d49f856b1f 100644 --- a/python/MDSplus/CMakeLists.txt +++ b/python/MDSplus/CMakeLists.txt @@ -23,4 +23,6 @@ install( PATTERN "tests" EXCLUDE PATTERN "*.pyc" EXCLUDE PATTERN "__pycache__" EXCLUDE -) \ No newline at end of file + PATTERN "build" EXCLUDE + PATTERN "*.egg-info" EXCLUDE +) diff --git a/python/MDSplus/pyproject.toml b/python/MDSplus/pyproject.toml index 7afed270e8..128f590848 100644 --- a/python/MDSplus/pyproject.toml +++ b/python/MDSplus/pyproject.toml @@ -7,14 +7,13 @@ authors = [ {name = "MDSplus Development Team", email = "mdsplusadmin@psfc.mit.edu"}, ] - license = {text = "MIT License"} description = "MDSplus Python Object interface" + license = "MIT" classifiers = [ "Programming Language :: Python", "Intended Audience :: Science/Research", "Environment :: Console", "Topic :: Scientific/Engineering", - "License :: OSI Approved :: MIT License", ] keywords=['physics', 'mdsplus'] dynamic = ["version"] @@ -33,9 +32,8 @@ [tool.setuptools] packages = [ 'MDSplus', - 'MDSplus.widgets', + 'MDSplus.widgets', 'MDSplus.wsgi', - 'MDSplus.tests', ] include-package-data = false # use package-data below @@ -43,10 +41,9 @@ 'MDSplus' = '.' 'MDSplus.widgets' = 'widgets' 'MDSplus.wsgi' = 'wsgi' - 'MDSplus.tests' = 'tests' - + [tool.setuptools.package-data] - 'MDSplus.wsgi' = [ + 'MDSplus.wsgi' = [ 'html/*', 'conf/*', 'js/*',