Skip to content

Modernize python - #3

Open
rhaschke wants to merge 12 commits into
ros-o:obese-develfrom
ubi-agni:obese-devel
Open

Modernize python#3
rhaschke wants to merge 12 commits into
ros-o:obese-develfrom
ubi-agni:obese-devel

Conversation

@rhaschke

Copy link
Copy Markdown
  • Use find_package(Python)
  • Use pip install instead of deprecated python setup.py install
    Drawback: pip performs an in-place build, creating an .egg-info folder. This is deleted after installation.

Comment thread cmake/templates/python_install.bat.in Outdated
--prefix="%_SETUPTOOLS_INSTALL_PATH%" ^
--install-scripts="%_SETUPTOOLS_INSTALL_PATH%\@CATKIN_GLOBAL_BIN_DESTINATION@" ^
--root=%_SETUPTOOLS_INSTALL_ROOT%\
"@PYTHON_EXECUTABLE@" -m pip install --ignore-installed --no-deps --prefix "%_SETUPTOOLS_INSTALL_PATH%" ^

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs a runtime dependency on python3-pip

@v4hn

v4hn commented Oct 22, 2025

Copy link
Copy Markdown
Member

@jspricke also pointed out that #2 was merged before, but is not in the tree anymore for some undocumented reason. 🙍
This PR adds it back as a part, so that should be fine.

I'll build my local workspaces with the change to check whether I find any problems in the wider scope.
Thanks for working on it @rhaschke !

Drawback: pip performs an in-place build, creating an .egg-info folder. This is deleted after installation.

Did you consider using python -m build -w -O ${CMAKE_CURRENT_BINARY_DIR} instead, building a wheel and storing it in build/? That should avoid the egg-info at the cost of more build overhead, but I didn't look into it further and do not know how it relates to editable installs right now.

@roehling

Copy link
Copy Markdown
Member

Drawback: pip performs an in-place build, creating an .egg-info folder. This is deleted after installation.

Why remove it? Leaving it in makes e.g. entry points work (which were always an issue with catkin-based Python packages), and AFAICT it does have no adverse effects besides using up a tiny extra amount of disk space.

Comment thread CMakeLists.txt
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2)
cmake_minimum_required(VERSION 3.16)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you picked 3.16 because of Ubuntu 20.04. Do we intend to support Focal past its EOL? More generally, do we have (or should we have) a policy for minimum version requirements for ROS-O?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there is no minimum OS version because there are no fixed target distributions, but if we can avoid breakage without consequences it makes sense to keep compatibility.
There is also no single branch for "ROS-O" and while compatibility is important, there is no problem to change branches in the individual builders for target platforms.

The question then is whether any "obese-devel"/"ros1" etc branches should move forward with breaking changes or whether we simply add more branches ("occult-devel" suggests itself ;)).

@rhaschke

Copy link
Copy Markdown
Author

Drawback: pip performs an in-place build, creating an .egg-info folder. This is deleted after installation.

Why remove it? Leaving it in makes e.g. entry points work (which were always an issue with catkin-based Python packages), and AFAICT it does have no adverse effects besides using up a tiny extra amount of disk space.

The egg-info folder is created in the source directory, where it shouldn't stay. I guess it is also installed, which is fine of course.

@rhaschke

Copy link
Copy Markdown
Author

Did you consider using python -m build -w -O ${CMAKE_CURRENT_BINARY_DIR} instead?

Not yet. How to install from there?

@v4hn v4hn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet. How to install from there?

You should just need to specify the wheel instead of CMAKE_CURRENT_SOURCE_DIR:

pip install ${CMAKE_CURRENT_BINARY_DIR}/build_package.whl

Again, I did not try that approach.

The egg-info folder is created in the source directory, where it shouldn't stay. I guess it is also installed, which is fine of course.

Did you test devel workspaces with this change?
In theory we might migrate to install --editable for them, but I'm sure there are non-trivial reasons why the approach catkin takes can be better in the ROS-O ecosystem.

My core workspace (with 417 basic packages on Debian testing - obviously not all with python setup) builds an install workspace with significantly less warnings with this patch. ❤️

Comment thread cmake/templates/python_install.sh.in Outdated
Comment thread cmake/templates/python_install.bat.in Outdated
rhaschke and others added 2 commits October 22, 2025 16:08
... silencing the pip deprecation warning:

DEPRECATION: Building 'xxx' using the legacy setup.py bdist_wheel mechanism, which will be removed in a future version. pip 25.3 will enforce this behaviour change. A possible replacement is to use the standardized build interface by setting the `--use-pep517` option, (possibly combined with `--no-build-isolation`), or adding a `pyproject.toml` file to the source tree of 'xxx'. Discussion can be found at pypa/pip#6334

Co-authored-by: Michael Görner <me@v4hn.de>
@rhaschke

Copy link
Copy Markdown
Author

Did you consider using python -m build -w -O ${CMAKE_CURRENT_BINARY_DIR} instead?

Tried now: ubi-agni/catkin@obese-devel...ubi-agni:catkin:python-build+pip-install
This still creates the egg-info folder in the source tree.

@v4hn: Could you rebuild your workspace with the latest commits?

@v4hn v4hn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove [the egg-info in src]? Leaving it in makes e.g. entry points work (which were always an issue with catkin-based Python packages), and AFAICT it does have no adverse effects besides using up a tiny extra amount of disk space.

@roehling The whole install logic only touches install workspaces, which need to be standalone and not devel workspaces, where it might make sense to keep files in src/ if it can help python.
It might make sense to use editable installs with devel workspaces and leave the egg-info there, but catkin uses a different awkward mechanism by overlaying all python modules/scripts with wrapper files in devel.

I guess it is also installed, which is fine of course.

@rhaschke I guess you mean the installed *.dist-info in install/?

Crucially, I went on to build my MoveIt workspaces now and hit py_binding_tools which still fails due to a bug in pybind11 that you reported upstream last year with still no response.
You also documented there that you removed the corresponding ros-o commit at that point.
That still seems like a major deal-breaker. Do we have any reasonable options to address this in the moveit repositories?

Comment thread cmake/templates/python_install.sh.in Outdated
The workaround forwards the build command through pip to setup.py
with an option to use the workspace build folder.
@v4hn

v4hn commented Dec 7, 2025

Copy link
Copy Markdown
Member

Status Update.

I started working on a buildfarm-integration of this effort and several small things did not perfectly work out yet. There are several repositories involved.

On my side this branch currently describes the automated build attempt for Debian bookworm (I know, trixi is next), listing the repositories and modified branches in the latest commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants