Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Runtime only Perl for Win32

by fdesar (Beadle)
on Feb 01, 2019 at 15:11 UTC ( [id://1229242]=perlquestion: print w/replies, xml ) Need Help??

fdesar has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

Continuing on trying to have an Inkscape integration of Perl extensions, I've been playing with Strawberry Perl as many of you suggested me and have been very impressed by its possibilities (I already got a patch from the Win32 Inkscape team to call wperl.exe instead of perl.exe and they confirmed me they only focussed on Python and didn't even thought of having Perl extensions running on Win32).

I'm now trying to find a way to use perldist_strawberry to get what I would call "a minimum runtime Perl installation for (Inkscape) End-Users".

I already red a few previous topics about building a minimal Perl runtime, but I didn't found really what I was looking for. So I'm trying to explain more exactly what I'm trying to get: an auto-installable (ie msi or exe) package that would allow end-users (people who doesn't even know what a computer is and how does it work) to run arbitrary Perl scripts, without even knowing what Perl is about, just knowing it is a required program to be installed on their desktop to get their extensions working.

That looks for me like a subset or Strawberry Perl with only perl.exe wperl.exe as executable binaries which can load modules (so miniperl is not enough) with only a subset of vital/important modules (such as CORE modules or XML::LibXML for example but I have not yet any clear idea of what modules that really means) and all the .DLL and PATH definitions required to have this Perl run and and load its pre-built modules, excluding all the unneeded development tools as the C mingwin32 environment or Cpan module build utilities, neither than any pods/html or any docs that will never be used and/or red.

I would like to have your wise advises on this idea as I'm in a very early stage and don't know yet about the traps and pitfalls I could fall in neither than the good way to achieve this or if someone already built up such a thing.

So any suggestion or comment from you is very welcome...

Thanks in advance for your time.

Replies are listed 'Best First'.
Re: Runtime only Perl for Win32
by salva (Canon) on Feb 01, 2019 at 16:26 UTC
    Check Win32::Packer. It is aimed at creating standalone applications written in Perl, but maybe you could adapt it to do what you want.

      I realize that Win32::Packer is probably your creation: would you help me to see what I could do with it ?

      I would need at least to have perl.exe and wperl.exe available and probably a lot of modules (with XS code in them). The must, at first glance, would be to have it installed directly in the Inkscape directory and to have everything (like perllibs, DLL, etc. relative to the path the executables are running, so no environment variables would be necessary as I cannot act from within Inkscape to do anything before calling the Perl executable wperl.exe...). There would be no perl script to install but just the running Perl environment...

      One big problem that comes to my mind is that Inkscape installs itself within the 'Program File' directory which has a space character in its path...

      Anyway, I'll setup a Windows VirtualBox (as I'm not a Windows user) and have a try on this soon...

      Thanks again

        There would be no perl script to install but just the running Perl environment...

        The executable created by tools like Win32::Packer and PAR:Packer don't install anything.

        BUT, the script you package with a tool like those CAN install what you need.

        First, write a script - let's call it "setup_InkPerl.pl" - that copies your framework and customized Perl distribution to the places they need to be.

        Then, run Win32::Packer or PAR:Packer (or other) to create "setup_InkPerl.exe"

        When the end user runs setup_InkPerl.exe, setup_InkPerl.pl, your framework and your Perl mini-distribution will be extracted, then setup_InkPerl.pl will be run.

        In setup_InkPerl.pl, you need to copy your framework to wherever it needs to be for Inkscape to run extension made for your framework. And you need to copy your Perl distribution to somewhere Inkscape can find it.

        There are some scripts in the portable Strawberry Perl distribution that might be helpful, including one that can add entries to the registry.

        I hope this helps

      Thanks ! I'll have a look.
Re: Runtime only Perl for Win32
by syphilis (Archbishop) on Feb 02, 2019 at 00:16 UTC
    Sounds to me that you probably want PAR::Packer.

    AIUI, it's pp utility can create standalone executables from perl scripts - and I gather that's what you're wanting.

    Cheers,
    Rob

      Thanks, Rob for your reply.

      But, no, it is not what I'm looking for: I don't have any script to run a priori, I just need a minimal installed perl environment (with some extra modules) to run any perl script written as an Inkscape extension.

      That's quite different: it smells like strawberry but without all the bells and whistles needed for perl development as docs, pods, gcc, c environment, cpan modules builder, etc. which, for the lambda end-user, is just a waste of disk space as he will not even know they exist and what they're made for.

        But, no, it is not what I'm looking for

        UPDATE: Corrected "vendor" to "perl/vendor" (below)

        Ok ... back to thinking that you do want a perl installation of some sort.
        Note that Strawberry Perl includes a couple of sizeable directories that are not part of a standard windows perl installation - namely "c" and "perl/vendor". (The "cpan", "licences" and "win32" directories are also absent on a standard build of Windows perl - but, between them, they take up less than 2 megabytes.)
        My standard build of latest blead (version 5.29.7) on Windows 7 consumes 45 megabytes on my hard drive - which can be tarred and gzipped down to 12 megabytes.
        The same figures would apply also to perl-5.28.0.

        I'm thinking that shouldn't be considered to be "too large and unwieldy".
        Even over a slow internet connection, a 12 megabyte download should be quite acceptable.
        And 45 megabytes of space is hardly a consideration in the 21st century.

        Cheers,
        Rob
Re: Runtime only Perl for Win32
by bliako (Monsignor) on Feb 02, 2019 at 12:08 UTC

    The two approaches already mentioned:

    1. use PAR::Packer, Win32::Packer and then pp to create stand-alone perl executables (PEX) for a single perl script (like jars for java so to speak). These PEX carry all the modules you will ever need for that particular script you are distributing. So, duplicate modules exist in each PEX. In addition, it takes some time to run because of initial setup costs (unpacking). But that decreases by activating the cache switch. I consider this a good solution, the minus is the duplicate modules in each PEX.
    2. Install some minimal perl distribution.

    I will suggest add to the list a solution based on containers (e.g. docker): create such container to include perl and all your scripts. Right now I can not even make docker run on my Linux to try this approache and that reminds me why I never use them nor caught their band-wagon when first came to town. But I am sure it's child's play to sell that idea to any snake charmer, any day.

    bw, bliako

      This is not at all what I'm looking for: I don't have any script to run, but want to have a Perl runtime to be able to run any script written as an Inkscape extension, which calls directly wperl.exe with the name of the extension script which get its parameters from Inkscape through STDIN, including a temporary XML file name which is the current document, and output its messages , if any, to Inkscape through STDERR and finally returns the modified document through STDOUT). As I said earlier, it smells like Strawberry but without all the stuff needed for Perl development, like gcc, cpan, pods etc. Only a wperl.exe excecutable, some XS modules and the DLL needed to run them, nothing more.

Re: Runtime only Perl for Win32
by Lotus1 (Vicar) on Feb 02, 2019 at 22:54 UTC

    The portable version of Strawberry Perl doesn't need to be installed and includes all the needed modules. It could be setup next to Python in the Inkscape\lib folder and added to the Inkscape configuration.

    Write an install script to do these steps:

    • Download the Portable Strawberry Perl zip file.
    • Unzip it to the Inkscape\lib folder next to Python.
    • Remove the C and CPAN folders and whatever else you don't want
    • Configure the user's Inkscape preferences file to run the Perl Inkscape extensions by passing the Perl scripts to portableshell.bat.

      Only one minor problem : there is no Inkscape preference file on Win32.

        As I mentioned before the Windows install of Inkscape does have the preference file. Mine is located at C:\Users\xxUsernamexx\AppData\Roaming\inkscape\preferences.xml. I posted a link to the directions for how to find this location. There should be an easy way to find it in a Perl script.

        Update: You can find that location in your script with $ENV{APPDATA} which equals C:\Users\xxUsernamexx\AppData\Roaming.

Re: Runtime only Perl for Win32
by harangzsolt33 (Chaplain) on Feb 02, 2019 at 07:52 UTC
    I use TinyPerl 5.8 on my computer. I don't know if that would meet your needs, but it does meet my needs. It only takes up 30MB of space on my hard drive. I just unzip it, and it's ready to run in 10 seconds. I have set it up so when I click on a .pl file or .cgi file, it automatically runs that Perl program, which is neat since I don't like to call Perl from command line.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1229242]
Approved by marto
Front-paged by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-25 09:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found