From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!aioe.org!pMM5B9Rl/1LQCd+Nt14ETA.user.46.165.242.91.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Running Python code from GPRBuild (Calling from GNAT Studio) Date: Fri, 11 Nov 2022 12:04:43 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <7d578e15-d21e-4eae-a519-d98c1bf1145cn@googlegroups.com> <673c0ad1-dd6d-4cc6-a191-3bcff7f1c5ddn@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: gioia.aioe.org; logging-data="11090"; posting-host="pMM5B9Rl/1LQCd+Nt14ETA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader01.eternal-september.org comp.lang.ada:64599 List-Id: 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