-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement a custom distutils command to symlink data_files #592
Conversation
The default implementation of install_data will always copy files into the destination directory. When we use the 'develop' command, we actually need to specifically tell setuptools to do something with the data_files or they will be ignored. Instead of telling setuptools to use install_data as-is, we can implement a custom version of install_data that will try to symlink the files instead.
This matches the existing behavior in colcon
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #592 +/- ##
==========================================
- Coverage 83.66% 82.06% -1.61%
==========================================
Files 65 66 +1
Lines 3765 3746 -19
Branches 728 713 -15
==========================================
- Hits 3150 3074 -76
- Misses 541 586 +45
- Partials 74 86 +12 ☔ View full report in Codecov by Sentry. |
Tested this PR and it works as expected! |
|
Hi many are eagerly waiting for this PR and what it promises 😄, any update on when it might be finished? |
Nobody has reviewed the change. I've got feedback from @RodBelaFarin that it worked as they expected (thank you!), but more feedback would be better. Have you tried the change yourself, @tonynajjar? If it works, I'd like to hear about it. |
Works like a charm! I tested it on humble on a launch file and a yaml file. @nuclearsandwich @clalancette can we please have a review for this long-awaited PR? I think it's a big source of confusion especially for beginners when --symlink-install does not work as intended with pure python packages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only comment is clarification and doesn't have any blocking suggestions.
I'm not sure if this should be discussed on ROS Discourse first or here or at all, but espacially after reading @tonynajjar's comment
I also have to speak up for all beginners using this build tool for ROS(2) and raise an even bigger question to this PR: Wouldn't it make sense that At least I am using it much more this way than the other way around and the default CLI command should be the default behavior, doesn't it? Shortly to my background: I am being a university educator and teaching ROS for 10 years now and also did external trainings for the EU ROSIN project, so I've personally trained multiple hundrets and thounds of people in ROS1 and ROS2. Most of them do not have a background in computer science and most of the times never worked with a Linux based OS, you know... the typical Windows user. So using a terminal emulator is already a hurdle for them and they don't know about features like bash-completion or similar. This means they are going to try to type With this PR's |
You mentioned above that you might not be aware of all use cases, and I think that's important to bear in mind. The most commonly used options in the education and outreach space are not necessarily the best general defaults. In this specific case, a symlink installation does not produce a relocatable installation space suitable for bundling or distributing, something that colcon is used for both on the ROS 2 CI farm and by other groups building ROS workspaces. Making the "most popular" or "most common" options the default is one strategy if there's a very clear winner of that category but I think another approach is to make the default the "least surprising" behavior and for a verb like To reduce the overhead for students, you could recommend a configuration setup using colcon-defaults although at the risk of soapboxing, I think that using non-standard defaults can introduce more confusion in the long term than adding additional command line options to support a specific workflow. |
Thanks @RodBelaFarin and @nuclearsandwich for your thoughts. I have three of my own to share:
Getting this change merged and matured in colcon-core is step zero. Even if there were a clear path forward, I can't see us making any moves until we're absolutely sure that this approach is correct and stable. It took spelunking through setuptools to understand how to make this change to begin with, which is probably why this wasn't implemented long ago. All this said, I still believe symlink installs have utility and I use them regularly, but I'm also acutely aware of the limitations. [1] Symlink installs only work as expected for existing files and Python modules. If you add a new top-level Python module or a new data file, you're going to need to build anyway to create the new symlinks in the install tree. Understanding when this is necessary could be just as confusing for new developers in my opinion. |
Note that we won't see test coverage in the added file |
Any estimate on when you plan on releasing 0.15.3? It says it's 100% complete 😁 |
May I ask some particulars about the new symlinking behavior?
Does using |
All files listed under
I think that modifying files in your install space at runtime is an antipattern even outside the context of symlink installs. When packaged and installed as a deb, those files would be owned by That said, I think it depends on precisely how you're saving over the files. If you open the file read-write at runtime, it will resolve the symlink and any changes you make will be made in the package sources. If you create a new file and replace the file in the install space, the symlink would be replaced with the new file, at least until the package is rebuilt. |
I just apt upgraded to python3-colcon-core (0.16.0-2), and symlinks are working great! Thank you! |
The default implementation of install_data will always copy files into the destination directory. When we use the 'develop' command, we actually need to specifically tell setuptools to do something with the data_files or they will be ignored. Instead of telling setuptools to use install_data as-is, we can implement a custom version of install_data that will try to symlink the files instead.