[PyQt] [SIP] Multi-platform pyproject.toml (platform dependent values)

Phil Thompson phil at riverbankcomputing.com
Thu Dec 12 10:18:00 GMT 2019


On 12/12/2019 09:15, Matteo Bertini wrote:
> On Wed, Dec 11, 2019 at 11:04 PM Phil Thompson 
> <phil at riverbankcomputing.com>
> wrote:
> 
>> On 11/12/2019 15:46, Matteo Bertini wrote:
>> >
>> > I tried using this syntax
>> > https://www.python.org/dev/peps/pep-0566/#environment-markers:
>> >
>> >     libraries = ["usb-1.0; 'linux' in sys_platform"]
>> >
>> > But seems to be unsupported.
>> 
>> If you need to do any introspection (ie. you need to write code) then
>> you need a project.py file.
>> 
> 
> Can you point me to some documentation or example? Searching the 
> filename
> gives me a lot of unrelated results.

https://www.riverbankcomputing.com/static/Docs/sip/examples.html#package-projects

> 
> Alternatively, is there some interest in supporting the linked
> environment-markers syntax? (or even, if I spend some time on the 
> feature,
> are you interested in merging it?)

I'd consider it. My concern would be that the vast majority of cases 
would need a project.py file anyway.

>> > 2) I tried using paths relative to `pyproject.toml` bus sip fails not
>> > finding my `.h` files (found using the absolute path), what is the best
>> > practice here?
>> 
>> Configure 'include_dirs'?
>> 
> 
> Let me explain, my project is in `/home/matteo/someproject`, with
> `pyproject.toml` and `somename.sip` + `somename.h` in the root of the
> project.
> 
>   [tool.sip.bindings.somename]
>   include-dirs = ["."]
> 
> ^^^ fails, instead the absolute path below works:
> 
>    [tool.sip.bindings.somename]
>    include-dirs = ["/home/matteo/someproject"]

Using ".." might be better as the current directory should be the build 
directory which (by default) is a sub-directory of the root directory 
(the one containing pyproject.toml). However that would break in the 
case with a different build directory.

The normal thing would be to set include_dirs in project.py based on the 
value of the "root_dir" attribute. As I've said, at the moment at least, 
a project.py file is needed in all but the most trivial of cases but I'm 
open to suggestions as to how that can be improved. For example allowing 
you to say something like...

     include-dirs = ["$ROOT_DIR"]

Phil


More information about the PyQt mailing list