bincrafters / community

Central repository for issues and recipes
http://bincrafters.readthedocs.io/en/latest/
MIT License
217 stars 36 forks source link

sdl2/2.0.12:stable: opengl/system and xorg/system should be build requirements #1247

Closed Yuri6037 closed 4 years ago

Yuri6037 commented 4 years ago

Package and Environment Details (include every applicable attribute)

Conan profile (output of conan profile show default or conan profile show <profile> if custom profile is in use)

Configuration for profile default:

[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=9
compiler.libcxx=libstdc++
build_type=Release
[options]
[build_requires]
[env]

Steps to reproduce (Include if Applicable)

I think this package should use xorg/system and opengl/system as build requirements: a system does not need any mesa-dev, xorg-dev or gl-dev packages in order to run SDL2 only to build it.

ericLemanissier commented 4 years ago

Thanks for the report. What do you think of this change: https://github.com/bincrafters/conan-sdl2/commit/b59c43624ca03753e9c722f383a9b524df1fbc3f ? Can you try it ?

Yuri6037 commented 4 years ago

Sounds promessing, do you know how to reference it in my conan script?

ericLemanissier commented 4 years ago

unfortunately there's no direct way. you have to clone https://github.com/bincrafters/conan-sdl2/ and then call conan create /path/to/working/copy sdl2/2.0.12@bincrafters/testing -o sdl2:opengl=False -o sdl2:opengles=False and reference sdl2/2.0.12@bincrafters/testing from your package.

Yuri6037 commented 4 years ago

The package still requires xorg-dev however it should not need xorg-dev to run SDL2 maybe to build it but not to run it so xorg-dev should be not required when a pre-built version of the library is downloaded.

ericLemanissier commented 4 years ago

One could think of using self.build_requires("xorg/system") instead of self.requires("xorg/system"), but this would have the drawback of not installing/checking any xorg packages at all as soon as a pre-built binary of sdl2 is available. Conan misses some granularity here. You could report this problem on https://github.com/conan-io/conan/issues

Yuri6037 commented 4 years ago

I think build_requires is good as in all cases if no xorg is installed then SDL2 would fail when creating a window and the application should just quit with an error message

Yuri6037 commented 4 years ago

I just tried using build_requires instead of requires but it does not work instead it throws: AttributeError: 'SDL2Conan' object has no attribute 'build_requires'

ericLemanissier commented 4 years ago

build_requires is probably available only in the build_requirements method, as showcased in https://docs.conan.io/en/latest/devtools/build_requires.html#build-requires

Yuri6037 commented 4 years ago

I saw that I'm going to try setting up a special repo to build a lightweight SDL2 with only window/opengl core context creation I will strip everything else

ericLemanissier commented 4 years ago

I think build_requires is good as in all cases if no xorg is installed then SDL2 would fail when creating a window and the application should just quit with an error message

We have to choose between installing too much system packages (the current situation), or installing nothing and leave the user with a run-time/link-time error with no indication of what (s)he needs to do, so (s)he has to figure by himself/herself that system packages needs to be installed, and which packages are missing. The current situation seems the lesser evil

Yuri6037 commented 4 years ago

In my opinion the current situation is unacceptable you do not install dev packages in order to run SDL2 apps...

ericLemanissier commented 4 years ago

you don't need the dev packages in order to RUN your SDL2 app, even with the current situation. Conan just forces you to install them when BUILDING your SDL2 app.

Yuri6037 commented 4 years ago

Which is unacceptable I'm only running SDL2 in my built app I'm not building anything that uses low-level xorg if I would then I would explicitely require xorg/system. What is unacceptable is that sdl2 conan forces requirement all the time of a dependency that is only used for building the package!

ericLemanissier commented 4 years ago

as I said earlier, you need to report this on https://github.com/conan-io/conan/issues (and please explain there why it is unacceptable). There is nothing that can be done at the recipe level.

Yuri6037 commented 4 years ago

I did some tests locally and I think it is possible to move all requirements to build requirements. The only part that causes problems is system_requirements but you can do something at the package level: support an option like "hackskipdev" which is just going to skip all system_requirements so you can download the pre-built package without having to download all the dev dependencies. That is in the mean time conan decides that it's better to add build_system_requirements

ericLemanissier commented 4 years ago

you can already disable system packages by using this https://docs.conan.io/en/latest/reference/env_vars.html#conan-sysrequires-mode.

Yuri6037 commented 4 years ago

It's a pain to set environment variables on Windows straightforward things are always better so I keep my hacky way in the mean time conan accepts to do better

ericLemanissier commented 4 years ago

I'm a bit surprised by your last message, this environment variable is only relevant on Linux, which is the only OS for which conan is able to install system packages. As the issue you've raised cannot be fixed by this recipe, I'm closing it. Please report it on https://github.com/conan-io/conan-center-index/ or https://github.com/conan-io/conan/

Yuri6037 commented 4 years ago

It can be actually using two packages:

Yuri6037 commented 4 years ago

The prove is here it is possible and is apparently the solution used by some main conan-center recipes. See my work here:

See response by uilianries here: https://github.com/conan-io/conan/issues/7504