Skip to content

use GNUInstallDirs where possible (master branch) - #3126

Merged
kimkulling merged 2 commits into
assimp:masterfrom
vmatare:master
Apr 7, 2020
Merged

kimkulling merged 2 commits into
assimp:masterfrom
vmatare:master

Conversation

@vmatare

@vmatare vmatare commented Apr 2, 2020

Copy link
Copy Markdown
Contributor

Emulate the CMAKE_INSTALL_FULL_* variables on non-Unix systems and disable redefining FHS-mandated install locations via user-editable ASSIMP_*_INSTALL_DIR variables. Instead, if it REALLY proves necessary, Unix users can edit the advanced, canonical CMAKE_INSTALL_* variables.

This is cherry-picked from the assimp_5.0_release branch, but there were some conflicts, so I'd advise integration testing this, as well. I can only say that it builds on Gentoo box ;-)

@vmatare

vmatare commented Apr 2, 2020

Copy link
Copy Markdown
Contributor Author

Oh, CI is running, very nice ;-)

@vmatare vmatare changed the title use GNUInstallDirs where possible use GNUInstallDirs where possible (master branch) Apr 2, 2020
vmatare and others added 2 commits April 3, 2020 00:44
Emulate the CMAKE_INSTALL_FULL_* variables on non-Unix systems and
disable redefining FHS-mandated install locations via user-editable
ASSIMP_*_INSTALL_DIR variables. Instead, if it REALLY proves necessary,
Unix users can edit the advanced, canonical CMAKE_INSTALL_* variables.
@kimkulling
kimkulling merged commit 0f3b196 into assimp:master Apr 7, 2020
@kimkulling

Copy link
Copy Markdown
Member

Merged, thanks a lot for your contribution.

@Zalewa

Zalewa commented Apr 16, 2020 •

Copy link
Copy Markdown
Contributor

Hi, could you please comment why some of the _IMPORT_PREFIX and, in extension, LIBSUFFIX have survived this change? From what I see _IMPORT_PREFIX is now empty and this breaks the CMake configs in the installed library.

See PR #3155

@vmatare

vmatare commented Apr 16, 2020

Copy link
Copy Markdown
Contributor Author

_IMPORT_PREFIX hasn't "survived", it was wrongly reintroduced by merging #3035 which should have been closed because this PR was supposed to replace it. I didn't state explicitly that #3035 should be closed and NOT be merged, I thought it was obvious from the comments saying that it's the wrong solution (or not a solution at all). It should also have conflicted obviously with what has been merged into master via this PR.

IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/lib/${importLibraryName}"
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/${sharedLibraryName}"
IMPORTED_IMPLIB_RELEASE "@CMAKE_INSTALL_FULL_LIBDIR@/${importLibraryName}"
IMPORTED_LOCATION_RELEASE "@CMAKE_INSTALL_FULL_BINDIR@/${sharedLibraryName}"

@dirk-thomas dirk-thomas Jun 3, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Doesn't this change make the generated files non-relocatable since it embeds the absolute path of the system this was generated on?

Why not keep using ${_IMPORT_PREFIX} (which could be determined from assimp_DIR)?

${_IMPORT_PREFIX}/${ASSIMP_LIB_INSTALL_DIR}

@vmatare vmatare Jun 4, 2020 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, maybe not the the cmake files themselves, but yes, the install path will be hard-generated into the cmake file, so one has to stick with the CMAKE_INSTALL_PREFIX. However hardcoding that seems to be a very common practice, because why would you install to one location and then move things somewhere else?

But I recognize that it seems to be a requirement of the ROS build model, and then I remembered that Gentoo's package manager also does it. The difference is that Gentoo's package manager does it correctly. That is, when I build assimp with these patches, I find the correct paths in Gentoo's temporary install dir:

$ grep IMPORTED_LOCATION_RELEASE /var/tmp/portage/media-libs/assimp-5.0.0/image/usr/lib64/cmake/assimp-5.0/assimpTargets-release.cmake
      IMPORTED_LOCATION_RELEASE "/usr/lib64/${sharedLibraryName}"

I guess the way they do it is by setting CMAKE_INSTALL_PREFIX to the real install path right from the beginning, but then running the cmake install within some sandbox with the root directory redirected to /var/tmp/portage/media-libs/assimp-5.0.0/image/. That way it always works and doesn't require modifications to 3rd-party libraries.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

However hardcoding that seems to be a very common practice

While it is certainly common practice I don't think it is good practice. The CMake documentation explicitly documents how to create relocatable packages: see https://cmake.org/cmake/help/v3.17/manual/cmake-packages.7.html#creating-relocatable-packages

why would you install to one location and then move things somewhere else?

The use case if often: build it in a directory foo on one machine and then distribute the artifacts to other machines (where it will get unpacked in a location different than foo).

I guess the way they do it is by setting CMAKE_INSTALL_PREFIX to the real install path right from the beginning, but then running the cmake install within some sandbox with the root directory redirected to /var/tmp/portage/media-libs/assimp-5.0.0/image/. That way it always works and doesn't require modifications to 3rd-party libraries.

That is only possible when you know the prefix path being used on all machines which are going to use the artifacts. In ROS that is not the case because users can choose arbitrary location - specifically to be able to keep multiple different versions in parallel in different locations.

@vmatare vmatare Jun 4, 2020 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That is only possible when you know the prefix path being used on all machines which are going to use the artifacts. In ROS that is not the case because users can choose arbitrary location - specifically to be able to keep multiple different versions in parallel in different locations.

I'm not sure I fully understand in what reasonable situation you wouldn't know the final install prefix of a package at build time. There is a standard called the Filesystem Hierarchy Standard that clearly states where everything goes on any Unix system. Distributors are the ones responsible for implementing/enforcing that consistently on an end-user's system. They are the ones building everything and they have all solved this problem in a generic way. It will only break down when you take a correctly built package apart and manually move the stuff somewhere else. Why would anybody do that?

Even more specifically:

In ROS that is not the case because users can choose arbitrary location

Even in that case I don't see the problem. If we're talking about a user-built installation, why not let them make the choice at build time? I'd even go so far as to argue that there is no choice to be made. User-built stuff goes into /usr/local for a system-wide installation or into ~/.local for a user-specific installation and that's all there is to it. Moving things around is just not something you do.

specifically to be able to keep multiple different versions in parallel in different locations.

I can imagine that there are some remote situations where a user might want to shuffle around multiple different ROS releases, but then why not simply have multiple (mutually exclusive) binary packages that you can switch around? And even if you're an integration tester or running CI and have to switch around all the time, you have Docker and whatnot to take care of that problem.

Now if you truly needed multiple releases to coexist in parallel (i.e. have two processes talk to each other, where either uses a different version of the same library), futzing around with the install prefix would still be the wrong way to go about it. The way it's currently done with environment manipulation with this setup.sh mechanic is just one of the most horrible messes I've ever seen. Environment variables just aren't the right tool for that because there is no concept of environment consistency anywhere between the kernel and the GUI, and ROS has no means of ever introducing one.

If ROS really wanted to support having multiple versions in parallel, they should make proper use of SONAME versioning that truly enables different releases to coexist within the FHS.

Sorry if I'm unexpectedly making a big deal out of this, but I really think it is. The blatant and constant violation of the FHS (and the warts growing from that) have been one of the most consistently annoying design problems in ROS, for me and for many other developers I know. So I'd really like to try and get to the bottom of what was the rationale there because I'm pretty sure it's a problem that should be solved in a very different place, in a standards-conformant way.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I thought I described the use case already but let me give you another use case where:

  1. we don't want to require users to build from source
  2. parallel versions need to coexist:
    • neither soname versioning is sufficient to solve it
    • nor is FHS
  3. we can't know the final location of the prefix

Consider a CI system creating a snapshot of N packages and making those artifacts available for users to try/use. A user wants to use them (over building from source) since it saves a lot of time - especially on lower end system (1.). A user want to trying different versions of these nightly artifacts and easy switch between them e.g. to figure out if a newer version addresses a certain problem (2.). While we could use a specific unique prefix in every build and require the user to unpack in that specific location that seems to be very restrictive. Since we already rely on environment variable to support parallel versions it is easy to allow unpacking into arbitrary prefixes if the artifact are relocatable (3.).

Btw. ROS does adhere to the FHS for the layout within the chosen prefix (afaik), see ROS REP 122. Not choosing /usr stems from the fact that we need to support multiple ROS distros to be installable side-by-side. The separate prefix paths and setting up the necessary env vars for PATH, PYTHONPATH, PKG_CONFIG_PATH, etc. are fairly straight forward and work well for ROS for 8+ years. If every version of every single package would be side-by-side installable with other versions that would not be necessary. But I would argue that looking at the packages available e.g. in Debian / Ubuntu that the case for only very few packages. The majority of packages doesn't support that - e.g. headers are within the same path on the include dir and would collide between versions Yes, packages could do a better job but as a matter of fact the majority of packages doesn't do so. Also keeping in mind that the average developer writing a ROS package has usually no idea of these complex aspects of packaging.

The blatant and constant violation of the FHS (and the warts growing from that) have been one of the most consistently annoying design problems in ROS, for me and for many other developers I know.

I can only invite you to consider contributing to push things into the direction you think is better (whatever that means). I suggest you do that with concrete suggestions rather than using phrases like the above to express your "disgust". Anything can be changed over time with the right rational and contributions.


We might disagree about the need or the general necessity but to make my question simple: would you be open to make the artifacts of assimp relocatable - by either working on necessary patches or accepting contributions towards that goal?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I also don't see how this use case motivates the requirement: If I just want to try out some nightly build, why would I need the old version to remain usable (or even installed) simultaneously? If I'm getting this stuff from binary packages, I can switch back and forth in a matter of seconds. Binary packages are supposed to be installed by a package manager (could be the distribution's one or a ROS-specific one) in a predetermined location. If I need to relocate the binaries, I'm either using the wrong distribution method or the package is broken.

The only legitimate argument I can see is if we're worrying about the computational cost of reinstalling binaries, but that seems like a really marginal concern.

Sorry, the fact that I think it's a non-problem makes it difficult to be constructive about it. We're talking about significant complexity that quickly becomes an annoyance to users. It cannot ever work safely or transparently because each process (hierarchy) has its own environment and ROS cannot have sufficient control over it. All of the user's GUI sits on a different branch in the process tree, the environment of which ROS has no control over. So even if the environment manipulation itself was working perfectly (which is also close to impossible because the semantics of environment variable values were never meant for the kind of dynamicity you're demanding), you still wouldn't be able to enforce any kind of environment consistency across a user's session. This how you keep breaking everyone's IDEs.

Don't get me wrong, I can totally agree with having a custom build system with integrated dependency management. I just don't see the need to introduce this random/switchable prefix complexity and to violate standards for it. And we haven't even touched upon the question of why/how the whole issue applies to 3rd-party libraries like this one that isn't even part of ROS.

I realize that there has been some previous discussion of this quesion, but so far I have not been able to locate a single substantial argument why this issue needs to be solved in such an intrusive way. All I can find are vague comments along the lines of "I like it" and "Industrial manufacturers like it". From the fact that you also haven't given me a simple "read this and STFU" I gather that there really isn't a definite, concise argumentation about it. Maybe I'll be able to conjure something up by boiling down this discussion into a post on discourse.ros.org...?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If I just want to try out some nightly build, why would I need the old version to remain usable (or even installed) simultaneously?

Because the user might want to compare two versions extensively while they are both used in in parallel in different terminal. Restricting them to one at a time is an significant limitation for their workflow - having to switch back and forth - possibly repeatedly.

Binary packages are supposed to be installed by a package manager (could be the distribution's one or a ROS-specific one) in a predetermined location. If I need to relocate the binaries, I'm either using the wrong distribution method or the package is broken.

There are platforms like Windows were that recommendation is just applicable. The only option atm is to distribute binary archives.

I just don't see the need to introduce this random/switchable prefix complexity and to violate standards for it.

I wouldn't describe the addition of a single variable as complex. The requested change also doesn't affect the behavior at all if you don't relocate the package. So I don't see why we are discussing the details how ROS does things for it.

Can you please give me a simple answer (yes / no) if you are willing to add this to this repository?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I should have started a separate ticket for this topic. Sorry for that. To make this request more visible I created #3260. Maybe any further discussion should continue there.

@vmatare vmatare Jun 5, 2020 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because the user might want to compare two versions extensively while they are both used in in parallel in different terminal. Restricting them to one at a time is an significant limitation for their workflow - having to switch back and forth - possibly repeatedly.

Now that is an actual use case and a valid argument. Thanks for bearing with me. I can indeed imagine highly specific use cases where such functionality could be necessary (e.g. visually comparing the effects of subtle changes in 3rd-party recognition algorithms). I may still have doubts about the practical relevance but at least this is something tangible which gives me enough context to come up with more specific proposals on how to improve the situation, particularly for the people trying to integrate ROS beyond the Ubuntu world.

traversaro added a commit to traversaro/assimp-feedstock that referenced this pull request Nov 13, 2021
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