Re: Regression? GetOption('prefix') does not seem to work in SConscript files since Python 3.10

Robert-André Mauchin <[email protected]>
Newsgroups gmane.comp.programming.tools.scons.user
Message-ID <[email protected]>
On 6/21/22 15:59, Mats Wichmann wrote:
> On 6/21/22 07:04, Robert-André Mauchin wrote:
>> Hi Scons people,
>>
>>
>> So I'm trying to build rmlint https://github.com/sahib/rmlint
>> It worked normally on Python 3.9, but since 3.10 and 3.11, I can't
>> install it in the location I want.
>>
>> In the SConstruct file we have
>> ```
>> AddOption(
>>       '--prefix', default='/usr/local',
>>       dest='prefix', type='string', nargs=1,
>>       action='store', metavar='DIR', help='installation prefix'
>> )
>> ```
>>
>> which I set to /usr instead of /usr/local with `scons config --prefix=/usr`
> 
> couple of questions about the setup:
> 
> 
>> `scons config -m 16  --prefix=/usr --actual-prefix=/usr --libdir=lib64
>> DEBUG=1 SYMBOLS=1 VERBOSE=1`
> 
> -m 16 ?  was that intended to be -j 16 ?
> 
>> scons`
>>
>> -> Builds correctly.
>>
>> `scons install`
> 
> Those two would have to repeat the --prefix setting.  Was the above just
> shorthand?
> 
>>
>> -> Install the gui sublibrary in the weong place (/usr/local instead of
>> /usr/)
>>
>> See a build log here:
>> https://koji.fedoraproject.org/koji/taskinfo?taskID=88548801
> 
> So can see this:
> 
> 
> cd gui && python3 setup.py install --prefix
> /builddir/build/BUILDROOT/rmlint-2.10.1-10.fc37.x86_64/usr --record
> .files.txt
> /usr/lib/python3.11/site-packages/setuptools/dist.py:519: UserWarning:
> The version specified ('2.10.1 Ludicrous Lemur') is an invalid version,
> this may not work as expected with newer versions of setuptools, pip,
> and PyPI. Please see PEP 440 for more details.
> 
> aside from the setuptools complaint, that looks ok, no? the "setup.py"
> line has on execution expanded to a path ending in /usr, not /usr/local
> 
> What am I missing?
> 

Well, none of this is actually the problem but according to my Python master, it is due to 
change in Fedora about how it handles Python installations:

================================================================================================
RPM build–related caveats

When Python runs during RPM build, it selects the rpm_prefix installation scheme. This 
behavior is triggered when the $RPM_BUILD_ROOT environment variable is set. That has several 
caveats:
Executing Python in Python’s subprocess

If the Python code that runs in RPM build (for example in %check) executes another Python 
instance via a subprocess, it is relatively easy to inadvertently unset all environment 
variables. When this happens, the inner Python will not know it runs within RPM build and 
will return paths with the /local/ infix.
================================================================================================

So the problem is not SCons itself, however I need:

```
if 'install' in COMMAND_LINE_TARGETS and GetOption('with_gui'):
     if not which('python3'):
         print('!! Unable to find python3 executable.')
         print('!! Will build no GUI.')
     else:
         py_install = env.Command(
             'always.install',
             ['setup.py'],
             'cd gui && python3 -m install . --prefix {}'.format(
                 GetOption('prefix')
             )
         )
         env.Alias('install', py_install)
```

to be able to pass an environment variable to the Python subprocess via env.Command.

Any idea how to do that?

Thanks!

Best regards,

Robert-André
_______________________________________________
Scons-users mailing list
[email protected]
https://pairlist4.pair.net/mailman/listinfo/scons-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.