comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Running Python code from GPRBuild (Calling from GNAT Studio)
Date: Fri, 11 Nov 2022 12:04:43 +0100	[thread overview]
Message-ID: <tkla8a$aqi$1@gioia.aioe.org> (raw)
In-Reply-To: 673c0ad1-dd6d-4cc6-a191-3bcff7f1c5ddn@googlegroups.com

On 2022-11-11 11:25, Rego, P. wrote:

>> 1. If you want to create a Python module in a form of a dynamically
>> linked library, you must use C or Ada for that.
> 
> Not the case, I also don't see advantages of it (so I agree, I'd go directly to Ada or C).

Actually this is the way of doing scripting from Ada, like GPS IDE does. 
You write a module, e.g. in Ada, and then you can import it in your 
Python script. The module must be a DLL.

>> 2. If you rather meant pre-compiled binary code (*.pyc). Python creates
>> them by py_compile command. See
>> https://docs.python.org/3/library/py_compile.html#py_compile.compile
>> There is also command-line interface:
>> https://docs.python.org/3/library/compileall.html
>> You possibly could configure gpr to call compileall on *.py files,
>> though it would make no sense to me.
> 
> I think this would be the closer of what I was trying to do.
> The idea is to help in the development. Instead of having to develop the
> Python part from a separate IDE, being able to code in the same would
> speed up things.
> 
> Would you have some example of it? (how to configure gpr to call
> compileall on *.py files).

You could start with something like this:

project Python is
    for Languages use ("Python");
    package Compiler is
       for Driver ("Python") use
 
"C:/GNAT/2021/libexec/gnatstudio/gnathub/share/gnathub/python/python.exe";
       for Required_Switches ("Python") use ("-m", "compileall");
    end Compiler;
    package Naming is
       for Body_Suffix ("Python") use ".py";
    end Naming;
end Python;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  reply	other threads:[~2022-11-11 11:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-10 19:25 Running Python code from GPRBuild (Calling from GNAT Studio) Rego, P.
2022-11-10 21:57 ` Dmitry A. Kazakov
2022-11-11 10:25   ` Rego, P.
2022-11-11 11:04     ` Dmitry A. Kazakov [this message]
2022-11-11 11:28       ` Rego, P.
2022-11-11 13:30         ` Dmitry A. Kazakov
2022-11-11 13:40           ` Dmitry A. Kazakov
2022-11-11 18:12             ` Rego, P.
2022-11-11 18:08           ` Rego, P.
2022-11-11 19:50             ` Dmitry A. Kazakov
2022-11-11 21:34               ` Rego, P.
2022-11-11 15:20         ` Egil H H
2022-11-11 18:14           ` Rego, P.
2022-11-11 20:05             ` Egil H H
2022-11-11 21:24               ` Rego, P.
2022-11-12 17:40 ` Stephen Leake
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox