Skip to content

Commit

Permalink
Use build instead of flit (#219)
Browse files Browse the repository at this point in the history
* use build instead of flit directly;  natlink can have .dev version umbers.

* use build instead of flit directly;  natlink can have .dev version umbers.

* bump dev version
  • Loading branch information
dougransom authored Dec 10, 2024
1 parent 14927ad commit 3e056c7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
14 changes: 13 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
cmake_minimum_required (VERSION 3.20)

project (Natlink)
set(NATLINK_VERSION 5.5.7)

#leave this line in
set (NLC_PIP_OPTIONS "--pre")

#Important
#when you change NATLINK_VERSION, decide if you want a prerelease of natlinkcore

#comment this line out to only install a release version of natlinkcore. During development it will be normally commented out.

#set (NLC_PIP_OPTIONS "")

set(NATLINK_VERSION 5.5.8.dev2) #if you are changing this to a release version, probably you want to comment out the line above.

set(PYTHON_VERSION 3.10 CACHE STRING "3.X for X >= 8") # Python to compile PYTHON_VERSION 3.X
set(MYAPP_NAME "Natlink")

Expand Down
3 changes: 2 additions & 1 deletion InstallerSource/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ add_custom_command(OUTPUT "${INSTALLER_FILE_BASE}.exe"
/D"PythonInstallExe=${PYTHON_INSTALL_EXE}"
/D"PythonWheelName=${WHEEL_NAME}"
/D"PythonWheelPath=${WHEEL_PATH}"
/D"MyAppName=${MYAPP_NAME}")
/D"MyAppName=${MYAPP_NAME}"
/D"NLC_PIP_OPTIONS=${NLC_PIP_OPTIONS}")


add_custom_target(natlink-installer-zip ALL DEPENDS "${INSTALLER_FILE_BASE}.zip")
Expand Down
2 changes: 1 addition & 1 deletion InstallerSource/inno-setup-natlink.iss
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Filename: "{code:GetPythonInstallPath}\\Scripts\\pip.exe"; Parameters: "install

Filename: "icacls.exe"; Parameters: " ""{#SitePackagesDir}"" /t /grant *{#AllowedUsersSid}:RX "; StatusMsg: "icacls.exe";
Filename: "regsvr32"; Parameters: "-s \""{#CoreDir}\{#NatlinkCorePyd}\""" ; StatusMsg: "regsvr32 {#NatlinkCorePyd}"
Filename: "{code:GetPythonInstallPath}\\Scripts\\pip.exe"; Parameters: "install --upgrade natlinkcore"; StatusMsg: "natlinkcore"
Filename: "{code:GetPythonInstallPath}\\Scripts\\pip.exe"; Parameters: "install --upgrade {#NLC_PIP_OPTIONS} natlinkcore "; StatusMsg: "natlinkcore"

Filename: "{code:GetPythonInstallPath}\\Scripts\\natlinkconfig_gui.exe"; Parameters: ""; StatusMsg: "Configure Natlink…"

Expand Down
27 changes: 9 additions & 18 deletions pythonsrc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
message("src CMakeLists.txt")

# Find Flit executable path
cmake_path(GET Python3_EXECUTABLE PARENT_PATH python_root)
find_program(FLIT NAMES "${python_root}/Scripts/flit.exe")

# If default python script directory is not writable check appdata Python script directory
if(NOT FLIT)
cmake_path(GET python_root STEM LAST_ONLY lastStem)
cmake_path(SET flit_appdata "$ENV{appdata}/python/${lastStem}/Scripts/flit.exe" NORMALIZE)
find_program(FLIT NAMES ${flit_appdata})
endif(NOT FLIT)

if(NOT FLIT)
message(FATAL_ERROR " Flit exe not found at: ${python_root}/Scripts/flit.exe
or ${flit_appdata}\n "
"Install Flit with: .\"${Python3_EXECUTABLE}\" -m pip install flit")
else(FLIT)
message(STATUS "FLIT exe found at ${FLIT}")
endif(NOT FLIT)


#in theory any python should work, not necessarily the python used to run natlink. Maybe not even a windows python.
#that could be useful in something like a github build action.


set(PACKAGE "dist/natlink-${NATLINK_VERSION}-py3-none-any.whl")

Expand All @@ -40,11 +28,14 @@ ${_Python3_RUNTIME_LIBRARY_RELEASE} )

add_custom_target(natlink-package ALL DEPENDS "${WHEEL_PATH}")

# If it is ever desired to use a different Python for building the wheel, than the natlink python,
# change this to use the desired python in the custom command below: COMMAND ${Python3_EXECUTABLE} -m build

add_custom_command(
OUTPUT "${WHEEL_PATH}"
COMMENT "Building python wheel package in ${WHEEL_PATH}"
COMMAND ${CMAKE_COMMAND} -E copy ${NL_FILES} ${NL_PY_DIR}
COMMAND ${FLIT} build --format wheel
COMMAND ${Python3_EXECUTABLE} -m build
DEPENDS StampDriver # otherwise the stamps are not checked
${PROJECT_BINARY_DIR}/NatlinkSource/NatlinkSource.STAMP
${NL_FILES}
Expand Down

0 comments on commit 3e056c7

Please sign in to comment.