Repository: conan-io/conan-center-index

Issue:
[package] scons/4.2.0: Can not parse options with white spaces
This issues was discovered here: conan-io/conan-center-index#9311

The package `serf` uses `scons`.

### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **scons/4.2.0**
  * Operating System+version: **Linux Ubuntu 18.04**
  * Compiler+version: **GCC 11**
  * Docker image: **conanio/gcc11**
  * Conan version: **conan 1.45.0**
  * Python version: **Python 3.8.2**


### Conan profile (output of `conan profile show default` or `conan profile show <profile>` if custom profile is in use)
```
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=11
compiler.libcxx=libstdc++11
build_type=Release
```


### Steps to reproduce (Include if Applicable)

    conan install -r conancenter serf/1.3.9@ --build=serf



### Logs (Include/Attach if Applicable)
<details><summary>Click to expand log</summary>

```
$ conan create . 1.3.9@ 
Exporting package recipe
serf/1.3.9 exports: File 'conandata.yml' found. Exporting it...
serf/1.3.9 exports: Copied 1 '.yml' file: conandata.yml
serf/1.3.9 exports_sources: Copied 4 '.patch' files: 0004-1.3.9-scons-python-spaces.patch, 0001-1.3.9-scons-python3.patch, 0003-1.3.9-scons-msvc.patch, 0002-1.3.9-scons-respect-flags.patch
serf/1.3.9: A new conanfile.py version was exported
serf/1.3.9: Folder: /home/conan/.conan/data/serf/1.3.9/_/_/export
serf/1.3.9: Package recipe modified in export, forcing source folder removal
serf/1.3.9: Use the --keep-source, -k option to skip it
serf/1.3.9: Exported revision: 6e4aae124c4035f5d3f55fa5ea1e406b
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++
compiler.version=11
os=Linux
os_build=Linux
[options]
[build_requires]
[env]

serf/1.3.9: Forced build from source
serf/1.3.9 (test package): Installing package
Requirements
    apr/1.7.0 from 'conancenter' - Cache
    apr-util/1.6.1 from 'conancenter' - Cache
    expat/2.4.1 from 'conancenter' - Cache
    libiconv/1.16 from 'conancenter' - Cache
    openssl/1.1.1m from 'conancenter' - Cache
    serf/1.3.9 from local cache - Cache
    zlib/1.2.11 from 'conancenter' - Cache
Packages
    apr/1.7.0:5a93bf7d483e99fe660ecfa6f981f28ff2854b44 - Cache
    apr-util/1.6.1:4829707b0cffa0be033d0c425d4ff7445de4b922 - Cache
    expat/2.4.1:2bf99ee01cda593d5986afc64acf262ad576354f - Cache
    libiconv/1.16:dfbe50feef7f3c6223a476cd5aeadb687084a646 - Cache
    openssl/1.1.1m:dfbe50feef7f3c6223a476cd5aeadb687084a646 - Cache
    serf/1.3.9:d93f51e80ee814b31d1274d08d479004c2edc126 - Build
    zlib/1.2.11:dfbe50feef7f3c6223a476cd5aeadb687084a646 - Cache
Build requirements
    scons/4.3.0 from local cache - Cache
Build requirements packages
    scons/4.3.0:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Cache

Installing (downloading, building) binaries...
apr/1.7.0: Already installed!
apr/1.7.0: Settings APR_ROOT environment var: /home/conan/.conan/data/apr/1.7.0/_/_/package/5a93bf7d483e99fe660ecfa6f981f28ff2854b44
expat/2.4.1: Already installed!
libiconv/1.16: Already installed!
libiconv/1.16: Appending PATH environment var: /home/conan/.conan/data/libiconv/1.16/_/_/package/dfbe50feef7f3c6223a476cd5aeadb687084a646/bin
openssl/1.1.1m: Already installed!
scons/4.3.0: Already installed!
scons/4.3.0: Appending PATH environment var: /home/conan/.conan/data/scons/4.3.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/bin
scons/4.3.0: Setting SCONS environment variable: /home/conan/.conan/data/scons/4.3.0/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/bin/scons
zlib/1.2.11: Already installed!
apr-util/1.6.1: Already installed!
apr-util/1.6.1: Appending PATH env var : /home/conan/.conan/data/apr-util/1.6.1/_/_/package/4829707b0cffa0be033d0c425d4ff7445de4b922/bin
apr-util/1.6.1: Settings APR_UTIL_ROOT environment var: /home/conan/.conan/data/apr-util/1.6.1/_/_/package/4829707b0cffa0be033d0c425d4ff7445de4b922
serf/1.3.9: Applying build-requirement: scons/4.3.0
serf/1.3.9: WARN: Build folder is dirty, removing it: /home/conan/.conan/data/serf/1.3.9/_/_/build/d93f51e80ee814b31d1274d08d479004c2edc126
serf/1.3.9: Configuring sources in /home/conan/.conan/data/serf/1.3.9/_/_/source
Downloading serf-1.3.9.tar.bz2 completed [141.73k]                                       

serf/1.3.9: Copying sources to build folder
serf/1.3.9: Building your package in /home/conan/.conan/data/serf/1.3.9/_/_/build/d93f51e80ee814b31d1274d08d479004c2edc126
serf/1.3.9: Generator scons created SConscript_conan
serf/1.3.9: Aggregating env generators
serf/1.3.9: Calling build()

----Running------
> scons "-Y" "/home/conan/.conan/data/serf/1.3.9/_/_/build/d93f51e80ee814b31d1274d08d479004c2edc126/source_subfolder" "-j4" CFLAGS="-fPIC -m64 -O3 -s" LINKFLAGS=" -L'/home/conan/.conan/data/apr-util/1.6.1/_/_/package/4829707b0cffa0be033d0c425d4ff7445de4b922/lib' -L'/home/conan/.conan/data/zlib/1.2.11/_/_/package/dfbe50feef7f3c6223a476cd5aeadb687084a646/lib' -L'/home/conan/.conan/data/openssl/1.1.1m/_/_/package/dfbe50feef7f3c6223a476cd5aeadb687084a646/lib' -L'/home/conan/.conan/data/apr/1.7.0/_/_/package/5a93bf7d483e99fe660ecfa6f981f28ff2854b44/lib' -L'/home/conan/.conan/data/libiconv/1.16/_/_/package/dfbe50feef7f3c6223a476cd5aeadb687084a646/lib' -L'/home/conan/.conan/data/expat/2.4.1/_/_/package/2bf99ee01cda593d5986afc64acf262ad576354f/lib'" CPPFLAGS="-DXML_STATIC -DAPR_DECLARE_STATIC -DAPU_DECLARE_STATIC -DNDEBUG -I'/home/conan/.conan/data/apr-util/1.6.1/_/_/package/4829707b0cffa0be033d0c425d4ff7445de4b922/include' -I'/home/conan/.conan/data/zlib/1.2.11/_/_/package/dfbe50feef7f3c6223a476cd5aeadb687084a646/include' -I'/home/conan/.conan/data/openssl/1.1.1m/_/_/package/dfbe50feef7f3c6223a476cd5aeadb687084a646/include' -I'/home/conan/.conan/data/apr/1.7.0/_/_/package/5a93bf7d483e99fe660ecfa6f981f28ff2854b44/include' -I'/home/conan/.conan/data/libiconv/1.16/_/_/package/dfbe50feef7f3c6223a476cd5aeadb687084a646/include' -I'/home/conan/.conan/data/expat/2.4.1/_/_/package/2bf99ee01cda593d5986afc64acf262ad576354f/include'" CC="/usr/bin/gcc" APR="/home/conan/.conan/data/apr/1.7.0/_/_/package/5a93bf7d483e99fe660ecfa6f981f28ff2854b44" APU="/home/conan/.conan/data/apr-util/1.6.1/_/_/package/4829707b0cffa0be033d0c425d4ff7445de4b922" OPENSSL="/home/conan/.conan/data/openssl/1.1.1m/_/_/package/dfbe50feef7f3c6223a476cd5aeadb687084a646" PREFIX="/home/conan/.conan/data/serf/1.3.9/_/_/package/d93f51e80ee814b31d1274d08d479004c2edc126" LIBDIR="/home/conan/.conan/data/serf/1.3.9/_/_/package/d93f51e80ee814b31d1274d08d479004c2edc126/lib" ZLIB="/home/conan/.conan/data/zlib/1.2.11/_/_/package/dfbe50feef7f3c6223a476cd5aeadb687084a646" DEBUG="False" APR_STATIC="True" SOURCE_LAYOUT="False"
-----------------
Warning:  ignoring -m option
usage: scons [OPTION] [TARGET] ...

SCons Error: no such option: -6
serf/1.3.9: 
serf/1.3.9: ERROR: Package 'd93f51e80ee814b31d1274d08d479004c2edc126' build failed

```

</details>



Discussion:
Indeed, using the original `serf/1.3.9` recipe and removing the `scons` build requirement makes Conan use my pip scons (version 4.3.0), which succeeds. By the way, also `scons/4.2.0` available in conan-center seems to be broken with respect to the reported bug, so perhaps a solution is to have SCons 4.3.0 in Conan-Center and update serf's `build_requirements`?
Olá André! :) 

Actually, the problem is not related to the scons version, but a change made in the recipe which created that situation:

https://github.com/conan-io/conan-center-index/blob/master/recipes/scons/all/conanfile.py#L51

That script wrapper is needed to solve problems related to python and environment variables, but at same time, it caused our current problem. What we need is a fix for that script wrapper.

Scons 4.3.0 can be added to, but will not solve this situation. 
Olá :-)
I see, so this seems to be more involved. In the meantime I'm happy to share that for whatever reason, the following workaround seemed to help:

Remove the `def build_requirements(self)` method from the conanfile and add this instead (bits taken from [this](https://stackoverflow.com/questions/54493352/is-there-a-way-to-add-python-dependencies-to-conan-package) SO entry):
```
   def system_requirements(self):
        import pip 
        if hasattr(pip, "main"):
            pip.main(["install", "scons==4.3.0"])
        else:
            from pip._internal import main
            main(['install', "scons==4.3.0"])
```

Looking forward to a "proper" fix of course!
André
@malchera That's a very ugly workaround, who had this idea!? :stuck_out_tongue_closed_eyes: 

If you want to use for an internal recipe/project, go ahead, I think it should be enough for this case. Indeed when I reported this bug, I tested against pip package and worked, so I confirmed that bug. 
Yes, this is certainly not a long-time solution!
But in case anyone bumps into this problem at least they would now how to get around it until a fix is available. Internally, I have created a new `workaround` channel to make it clearly visible that this is a... well... workaround :-)

Resolving patch:
diff --git a/recipes/scons/all/conanfile.py b/recipes/scons/all/conanfile.py
--- a/recipes/scons/all/conanfile.py
+++ b/recipes/scons/all/conanfile.py
@@ -67,7 +67,7 @@ def package(self):
             currentdir="$(dirname "$(realpath "$0")")"
 
             export PYTHONPATH="$currentdir/../res:$PYTHONPATH"
-            exec ${PYTHON:-python3} "$currentdir/../res/SCons/__main__.py" $*
+            exec ${PYTHON:-python3} "$currentdir/../res/SCons/__main__.py" "$@"
         """))
         self._chmod_x(self._scons_sh)
         tools.save(self._scons_cmd, textwrap.dedent(r"""


Test patch: