Re: Inline::Python for windows 10
by syphilis (Archbishop) on Oct 15, 2018 at 13:24 UTC
|
Appearantly it relies on the module Proc::ProccessTable which from what I have heard does not work on windows
The README that ships with Proc-ProcessTable-0.55 confirms that the module doesn't work on native windows (though it does say it will work under Cygwin on Windows).
When I try to build it on Strawberry Perl I get the following errors:
ProcessTable.o:ProcessTable.c:(.text+0x49): undefined reference to `OS
+_initialize'
ProcessTable.o:ProcessTable.c:(.text+0x412): undefined reference to `O
+S_get_table'
collect2.exe: error: ld returned 1 exit status
I'm not at all confident that the workaround for windows would be trivial, though I don't really know.
However, according to the Inline::Python-0.56 Makefile.PL, Proc::ProcessTable is needed only for running the test suite.
I would therefore just go ahead and install Inline::Python without bothering about the test suite, and see whether it is functional.
What is the perl -V output for your ActiveState Perl ?
Cheers, Rob | [reply] [d/l] [select] |
Re: Inline::Python for windows 10 (update)
by Discipulus (Canon) on Oct 15, 2018 at 15:24 UTC
|
Hello tobbes and welcome to the monastery and to the wonderful world of Perl!
> which from what I have heard does not work on windows
is not knoweledge, are rumors.. ;=) but if you want to know how a module, generally speaking, runs out of the box on a OS take a look at cpan testers matrix: matrix for Inline-Python+0.56.
The whole column for windows family is not promising: I tried skipping tests as suggested but I had no success anyway.
# set INLINE_PYTHON_EXECUTABLE=c:\path\to\python.exe
....
dmake.exe: Error code 129, while making 'blib\arch\auto\Inline\Python
+\Python.dll'
NINE/Inline-Python-0.56.tar.gz
C:\path\strawberry\c\bin\dmake.exe -- NOT OK
Skipping test because of notest pragma
Running make install
Make had returned bad status, install seems impossible
Failed during this command:
JWB/Proc-ProcessTable-0.55.tar.gz : make NO
NINE/Inline-Python-0.56.tar.gz : make NO
Obviously you already have python installed, rigth (and in PATH..)?
My best wishes and share your results!
L*
update
I installed active python on another machine: I set the ENV var correctly, I issued force notest install Inline::Python and still fails on the module:
JWB/Proc-ProcessTable-0.55.tar.gz : make NO
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
| [reply] [d/l] [select] |
|
JWB/Proc-ProcessTable-0.55.tar.gz : make NO
Hmmm ... given that you had specified "notest" and that Proc-ProcessTable is required only for testing, it seems rather ridiculous that the build process should throw up that obstacle.
I would recommend switching to a procedure that bypasses that insanity.
Cheers, Rob
| [reply] |
|
cpanm --look Inline::Python
perl Makefile.PL
gmake
gmake install
Substitute dmake for gmake as needed.
I just tried it, but don't have a python handy that satisfies Inline::Python (it's provided as part of a commercial package) so could not get it to a successful make stage without more work or installing another python on my system. | [reply] [d/l] [select] |
Re: Inline::Python for windows 10
by dbuckhal (Chaplain) on Oct 16, 2018 at 03:16 UTC
|
If you are willing to use Cygwin on Windows 10, I was able to successfully install Inline::Python on Windows 10 using Cygwin(64bit):
- Install Cygwin.
- Using Cygwin Package Manager:
- Install perl-Inline.
- Install python and/or python3.
- Install python3-devel and/or python2-devel.
- Install libintl-devel (resolves a "mostly harmless" warning message...).
- From cpan (perl -MCPAN -e shell...)
- cpan1> get Inline::Python
- Go to the Inline::Python build directory (~/.cpan/build/Inline-Python-0.56-0).
- Execute the usual:
- NOTE: Defaults to "/usr/bin/python" You will need to enter "/usr/bin/python3", manually, if you prefer python3 (See "Use which?" under 'e', below).
perl Makefile.PL
make
make test
make install
$ perl Makefile.PL
Found these python executables on your PATH:
1. /usr/bin/python
Use which? [1] /usr/bin/python3
Using /usr/bin/python3
Using These Settings:
Extra Libs: -lintl -ldl
Python Lib: -L/usr/lib/python3.6/config-3.6m-x86_64-cygwin -lpytho
+n3.6m.dll
Includes: -I/usr/include/python3.6m
Extra Flags: none (perl Makefile.PL --help for details)
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Inline::Python
Writing MYMETA.yml and MYMETA.json
- Test 35 will fail due to 'rss' not being available in Windows (See PORTING file under Proc::ProccessTable source).
-
.
.
.
t/31stringification.t ..... ok
t/32boolean.t ............. ok
t/33reinit.t .............. ok
t/34env.t ................. ok
t/35dictunicodememleak.t .. Can't access `rss' field in class Proc::Pr
+ocessTable::Process at t/35dictunicodememleak.t line 28.
# Looks like your test exited with 2 before it could output anything.
t/35dictunicodememleak.t .. Dubious, test returned 2 (wstat 512, 0x200
+)
Failed 2/2 subtests
t/cmp.t ................... ok
Test Summary Report
-------------------
t/35dictunicodememleak.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: Bad plan. You planned 2 tests but ran 0.
Files=37, Tests=838, 12 wallclock secs ( 0.12 usr 0.19 sys + 3.16 cu
+sr 7.80 csys = 11.27 CPU)
Result: FAIL
Failed 1/37 test programs. 0/838 subtests failed.
make: *** [Makefile:1061: test_dynamic] Error 255
- Rename "t/35dictunicodememleak.t"
- Tests pass:
.
.
.
t/34env.t .............. ok
t/cmp.t ................ ok
All tests successful.
Files=36, Tests=838, 12 wallclock secs ( 0.09 usr 0.22 sys + 2.94 cu
+sr 7.37 csys = 10.62 CPU)
Result: PASS
Testing...
$ perl -e '
print "9 + 16 = ", add(9, 16), "\n";
print "9 - 16 = ", subtract(9, 16), "\n";
use Inline Python => <<"END_OF_PYTHON_CODE";
def add(x,y):
return x + y
def subtract(x,y):
return x - y
END_OF_PYTHON_CODE
'
__output__
9 + 16 = 25
9 - 16 = -7
Hope this helps, because this was a pain to type as appropriately formatted correctly as possible... Whew!
Aaaaand if you choose to say, "Screw Cygwin!", then that is OK, too. :)
Lastly, these steps worked for me, but YMMV...
--Derrick | [reply] [d/l] [select] |
|
Unfortunately this is not an option, I did get it to install on linux subsystem as well without doing anything, but I am going to distribute the program I am creating to users and also need to convert it to .exe so cygwin or linux subsystem is not an option unfortunately.
But rest assured, I sincearly appreciate the effort :)
| [reply] |
Re: Inline::Python for windows 10
by marto (Cardinal) on Oct 15, 2018 at 12:38 UTC
|
"As I am unable to get Inline::Python to compile properly on windows 10"
What did you try, how did it fail?
| [reply] |
Re: Inline::Python for windows 10
by pythonguy (Initiate) on May 29, 2019 at 06:42 UTC
|
Don't know if this will work for you, but I had luck with the following:
-
Setup
-
Windows 10 64-bit
-
Strawberry Perl 5.30 64-bit
-
Anaconda with Python 3.7 64-bit
-
Add Anaconda to System (not User) Path
-
PATH\TO\ANACONDA
-
PATH\TO\ANACONDA\Library\mingw-w64\bin
-
PATH\TO\ANACONDA\Library\usr\bin
-
PATH\TO\ANACONDA\Library\bin
-
PATH\TO\ANACONDA\Scripts
-
PATH\TO\ANACONDA\bin
-
PATH\TO\ANACONDA\condabin
-
Add System (not User) Environment Variable PYTHONHOME=PATH\TO\ANACONDA
-
Run cpanm -n --interactive Inline::Python
-
The Makefile.PL seems to have issues finding proper Python info in standard install, so need to do it interactively
-
Also want to avoid testing since that relies on Proc::ProcessTable, which isn't available for Windows
-
For the python executable path, enter PATH\TO\ANACONDA\python.exe
-
For the extra libraries, select default (default = None)
-
For the python library, enter PATH\TO\ANACONDA\libs\python37.lib (will change depending on Python version you are using)
-
For the python include, enter PATH\TO\ANACONDA\include
-
Open \PATH\TO\STRAWBERRY_PERL\perl\site\lib\Inline.pm
-
Windows seems to have write permission issues, so we fix that here
-
Find the line with "if ($bin = $FindBin::Bin and"
-
Replace it with the following lines:
$bin = $FindBin::Bin;
chmod 0755, $bin;
chmod 0755, $cwd;
if (defined $bin and $bin and
I haven't had time to check this out with other versions or distributions of Perl/Python, but hopefully this will at least give a starting point. Good luck!
| [reply] [d/l] [select] |
Re: Inline::Python for windows 10
by tobbes (Acolyte) on Oct 17, 2018 at 11:29 UTC
|
I just realized that I do not know how well Inline::Python would work for me even if I got it installed.
I need to distribute my script as a .exe file and I am somewhat dubious as to whether the pythonfiles will be included in the .exe magically.
Lilkely the users will have to install Python, which is not an option.
It basically leaves me with one option as far as i understand:
run perl and python as seperate processes and then use sockets to communicate between them *sigh* that should be simple and stable.
| [reply] |
|
pp --addfile packed_python.exe -o yourtool.exe yourtool.pl
In your perl script you would need to find the packed python exe and call it, e.g.:
$python_exe = Path::Class::file ($ENV{PAR_TEMP}, 'inc', 'packed_python.exe');
Your perl script will need to check for $ENV{PAR_0} to control the use of a packed python exe, otherwise debugging can be a pain, but this can be factored into a sub and the general approach does work.
Addendum - unsurprisingly, there are tools to pack python exes. I have no idea if these work, but this link looks handy at first glance: https://medium.com/dreamcatcher-its-blog/making-an-stand-alone-executable-from-a-python-script-using-pyinstaller-d1df9170e263 | [reply] [d/l] [select] |
|
at some point you need to ignore "packers" and just distribute a big'ol zip file
| [reply] |
|
|
| [reply] |