Skip to content

avrdude Python binding CMake configuration improvement #1914

@leventelist

Description

@leventelist

I have a script that builds AVR toolchain, including avrdude. The sctipt installs the artifacts to a directory in my user's home. I've noticed that when I want to install v8.0, it directly targets /usr/local for installing some python module. Is there any workaround not doing it? I run my script as a normal user, and it keeps failing, as it is not writable by a non superuser.

I came up with this patch.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e358e4b1..7bef99ed 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -403,8 +403,10 @@ install(FILES "avrdude.1"
 	)
 
 if(HAVE_SWIG)
-    execute_process(COMMAND ${Python3_EXECUTABLE} -c "import site; print(site.getsitepackages()[0])"
-                    OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
+    if(NOT DEFINED PYTHON_SITE_PACKAGES)
+      execute_process(COMMAND ${Python3_EXECUTABLE} -c "import site; print(site.getsitepackages()[0])"
+                      OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
+    endif()
     install(TARGETS swig_avrdude DESTINATION ${PYTHON_SITE_PACKAGES})
     install(FILES ${CMAKE_BINARY_DIR}/src/swig_avrdude.py DESTINATION ${PYTHON_SITE_PACKAGES})
     install(DIRECTORY python/ DESTINATION ${CMAKE_INSTALL_DATADIR}/avrdude FILES_MATCHING PATTERN "*.ui")

And call cmake with something like this: "-DPYTHON_SITE_PACKAGES=python"

Metadata

Metadata

Assignees

No one assigned

    Labels

    PythonRelated to Python bindingbuild_CIRelated to CMake, auto-tools build infrastructure and github CIenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions