conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.24k stars 980 forks source link

[feature] Conan should recognize elementaryOS as a distro that uses apt #7307

Closed seanballais closed 4 years ago

seanballais commented 4 years ago

elementaryOS is a Linux distro based on Ubuntu. So, it uses apt. However, Conan, via the conans module, disagrees and says that it does not use apt when calling tools.os_info.with_apt.

Python 3.7.4 (default, Oct  9 2019, 00:16:19) 
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from conans import tools
>>> tools.os_info.with_apt
False

Letting Conan know that elementaryOS uses apt is important since recipes that have to know whether or not the distro they are running in uses apt may have to resort to doing something less than ideal when ran under elementaryOS. For example, using opengl/system in a project under elementaryOS will fail (just like this in bincrafters/community#1216) because the recipe, as it is currently is (and supported by conan-io/conan-center-index#2114), fails hard when being used in an unrecognized distro.

As such, Conan should be updated to recognize elementaryOS as a distro that uses apt. Based on my quick skim of the conans module code, it seems that a change in client/tools/oss.py:181 to:

# ...
        apt_distros = ("debian", "ubuntu", "knoppix", "linuxmint", "raspbian", "neon", "pop", "elementary")
# ...

should do the trick.

Note: import distro; distro.id() returns 'elementary'.

memsharded commented 4 years ago

Hi @seanballais

Thanks for submitting this issue. Yes, we recently added pop there, so I see no problem to add there elementary too. Would you like to send a PR yourself, as you have already investigated where to add it?

seanballais commented 4 years ago

Hey, @memsharded. Sure! I'll send a PR as soon as I can.

SSE4 commented 4 years ago

okay, maybe we can nail everything down at once, as there are many debian and ubuntu based distributions: https://en.wikipedia.org/wiki/List_of_Linux_distributions#Debian-based https://distrowatch.com/search.php?basedon=Debian#simple https://distrowatch.com/search.php?basedon=Ubuntu%20(LTS)#simple

SSE4 commented 4 years ago

also, as new distros appear almost every month (it's actually very simple to create your own distro like BolgenOS), maybe we can go away from maintaining a hard-coded distro list, and just verify if apt exists and it's really apt package manager (not just a random executable named apt).

seanballais commented 4 years ago

Checking if apt itself exists should be a better option. Alright. I'm working on it.

seanballais commented 4 years ago

I've just submitted a PR!

seanballais commented 4 years ago

@SSE4, perhaps later on, we can stop depending on a hard-coded distro list and have the package manager properties (e.g. with_apt) check for the existence of the appropriate package manager executable.