Windows and Apache Thrift Executable - python

I am testing out how simple Apache Thrift is to learn and it looks promising. One major problem: the first tutorial doesn't work...
I have Windows 7, Python 2.7, and got the Thrift .exe for Windows v.0.9.1. I'd rather not compile from source as I don't use Cygwin etc. The exe gave the problems described below. So I moved on and tried using Chocolatey to install Thrift using
cinst Thrift
which worked fine and gave me Thrift v0.9.0. But this version results in the same behavior as the exe, described below.
When I run the tutorial found at http://thrift.apache.org/tutorial/py I get the following:
C:\Users\Me\Desktop\Thrift>thrift -r --gen py tutorial.thrift
[WARNING:C:/Users/Me/Desktop/Thrift/tutorial.thrift:59] Could not find include file shared.thrift
[ERROR:C:/Users/Me/Desktop/Thrift/tutorial.thrift:123] (last token was 'shared.SharedService')
Service "shared.SharedService" has not been defined.
Hopefully the exe works for someone because I'd love to avoid this requiring a build from source.

The answer is that the tutorial assumes you have a /tutorial folder with two .thrift files included in it. If you go the Windows EXE route and then build your tutorial.thrift file, you will also need to add shared.thrift which can be found in Git at https://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob_plain;f=tutorial/shared.thrift
Save this file next to your tutorial.thrift file and you can proceed with the tutorial.

The command
thrift -r --gen py tutorial.thrift
uses the -r[recurse] switch to automatically build a second, included IDL file shared.thrift. This shared.thrift file is located in the same folder as tutorial.thrift is. Because Thrift looks for included files based on the current folder, you have to explicitly call the Thrift compiler from that folder.
Assumed, your Thrift working copy is under C:\Thrift and the thrift.exe is reachable via search path, open a command prompt, navigate to that folder and enter the command again:
C:\> cd Thrift\tutorial
C:\Thrift\tutorial> thrift.exe -r --gen py tutorial.thrift
PS: The 0.9.0 is slightly outdated. The 0.9.1 is fine, the forthcoming release 0.9.2 will have even more improvements.

Related

how to build .exe for python 3.5+, 3.6 if possible?

Is there now an easy protocol to build a .exe from python 3.5+, using modules pyqtgraph, qt5, theano, pymc3, numpy, scipy, os and sys, and opening a simple GUI stored in a '.ui' file ? I lost hours and eventually failed to make one (for w7-64 bits). Help !
preliminary failure with py2exe: I first install py2exe for python 3 but it turns out this is not compatible with my python 3.6 yet, so I downgraded to python 3.5… to get a bunch of errors. Then I went to forums and tried the proposed cures but failed (I’m uneasy with windows), the alternative being to downgrade to python 3.4… So I downgraded to python 3.4 to get an error concerning a missing ‘msvcr100.dll’ that I tried to install following instructions on forums but by default I don’t have the permission to modify system directories… When I eventually had this permission it turns out the ‘regsvr32’ command fails (isn’t this for 32 bits ? but there is no ‘regsvr64’…). Following episodes are described below.
update august 23, 2017, 1pm:
I also tried pyinstaller as advised but it failed (see my related question build a .exe for Windows from a python 3 script importing theano with pyinstaller)
I also tried cx_freeze but it failed (see my related question build a .exe for Windows from a python 3 script)
I also tried pynsist but it fails (same link than above)
what's next ?
update september, 2, 2pm:
I eventually managed to build a .exe with pyinstaller after many episodes.
Unfortunately I failed to deal with the ‘theano’ module (that is required in my case by the ‘pymc3’ module) and I had to modify the .py files and give up part of the application. Could anyone help me building a .exe for windows 7+, with the ‘theano’ module ?
see build a .exe for Windows from a python 3 script importing theano with pyinstaller
Pyinstaller Works with Python 3.5 and it is working even for packages like tensor-flow, scipy , etc (The packages I worked with)
py -3.5 pip install pyinstaller
then go the C:\Users\user\AppData\Local\Programs\Python\Python35\Scripts
and run the command
pyinstaller <code .py file along with directory> --onefile
--onefile : is for compressing the build and get a single file as output
I would suggest pyinstaller see http://www.pyinstaller.org/
The pyinstaller already supports 3.5
The development version supports 3.6
It is better to use spec file to import other hidden libraries. I listed all Sklearn libraries and add them to spec file as a hiddenimports, you can add libraries you used in your project.

Python PIP using .cfg

I have a package I am installing in Python that requires dependancies or it fails to install:
> pip install http://etc
pak/test.cpp:3:10: fatal error:
'tools/test.cv' file not found
#include "tools/test.cv"
I have been infomred that I need to download the files (which I have done) then...
create a file ~/.tools.cfg containing:
[build_ext]
include_dirs=/path/to/home/tools
However, I don't understand this last part!
How does the pip installer pick up the .tools.cfg file, where do I even create the file .tools.cfg?
I'm running this on a mac if thats makes a difference.
According to the path you gave, you make the file in your home directory. On a Mac (OS X, I assume), that is a sub-directory of /Users named for your user name (i.e. /Users/Sputnik). You can create it with any text editor, i.e. emacs, vim, nano, TextEdit.app, etc.
I don't know exactly how the pip installer is looking up that file, but presumably it's looking for a file with the name of the package (in this case, tools).
Please comment if this doesn't answer your question, and accept (i.e. click on the Checkmark) if it does!

How do I build pysvn on Windows32?

I'm trying to build PySVN from source on my Windows 7 PC. It's running 64bit Windows, but for various reasons I need to compile it so that it works on 32bit Python. That's what we run on a lot of our automation servers.
I've downloaded the PySvn extensions source, I've got Visual Studio 2008 Express Edition installed. I've tried to a batch to automate the process, it looks like this:
set PROJECT_DIR=%~dp0
set SRC_DIR=%PROJECT_DIR%pysvn-1.7.8
cd %SRC_DIR%\Builder
set SVN_VER_MAJ_MIN=1.8
call builder_custom_init.cmd
cd %SRC_DIR%\Source
python setup.py configure --platform=win32
When I get to the last line I get the error message:
Info: Configure for python 2.7.6 in exec_prefix c:\python27
('Error:', 'cannot find PyCXX include CXX/Version.hxx - use --pycxx-dir')
My python - include directory does not contain a file called Version.hxx. Where do I get this file, how do I fix this bug?
One way is to install PYCXX by hand - it installs a Version.hxx under the Include folder on windows.
The source for PYCXX is here: http://cxx.sourceforge.net/
Another way is to point the C/L parameter --pycxx-dir at the Import folder under the pysvn root where the corresponding version of PYCXX for the version of pysvn is kept.
(On top of this you will have to build the subversion libraries on windows.)

Using opscode's omnibus installer in windows 7

I am working my way through a video tutorial at http://gettingstartedwithdjango.com/en/lessons/introduction-and-launch/
I am working on win7 and using git-bash for my terminal. I have installed the latest virtualbox - 4.2.12 and the latest vagrant - 1.22.
I tried to run vagrant up and got: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
creating Makefile
make
sh: 1: make: not found
Once of the answers given by jtimberman is:
The basebox you're using does not have the "build-essential" package installed by default, and it has a "[shell provisioner][1]" that installs the Chef gem into the default Ruby environment. Chef has a dependency on the JSON RubyGem, which itself has C extensions that must be compiled. This is what is looking for `make`.
To resolve this issue, I'd recommend using Opscode's "omnibus" [full stack installer for Chef][2]. This can be used by changing the shell provisioner line to:
config.vm.provision :shell, :inline => "curl -L https://opscode.com/chef/install.sh | bash"
The `[install.sh][3]` script simply inspects the VM to determine what its platform is so it can retrieve the proper URL from an S3 bucket. If you prefer you can use the constructed URL to download the .deb file directly:
https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/11.04/x86_64/chef_11.4.4-2.ubuntu.11.04_amd64.deb
And then install it:
dpkg -i chef_11.4.4-2.ubuntu.11.04_amd64.deb
I have not been able to get the first method to work and would like to try the second. would:
dpkg -i chef_11.4.4-2.ubuntu.11.04_amd64.deb
work on win7. If not how do I get this working in windows?
In order to compile native extensions in Windows, you must install the Ruby DevKit. Joshua's answer is valid for Debian-based systems.
An addition to sethvargo.
In addition to the Ruby DevKit, you also need the client library for your native software.
For example, in order to compile/install ruby-oci8 gem, you should have the Oracle Client installed on your computer as well.

Understanding concepts of Python installation on Mac OS for Cocoa development

I want to try to develop Cocoa application using Python. I'm new to Mac and I need some help to understand how it works.
First of all I found that I need to install py2app and py2objc. I used easy_install as documented here. There were a few errors with setup tools but eventually py2app was installed. Then I launch "easy_install pyobjc==2.2" and it ended with many errors:
Processing pyobjc-2.2-py2.7.egg
...
Running pyobjc-framework-SystemConfiguration-2.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ipMzFU/pyobjc-framework-SystemConfiguration-2.2/egg-dist-tmp-odfVol
In file included from Modules/_manual.m:1:
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:19:20: error: limits.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:22:2: error: #error "Something's broken. UCHAR_MAX should be defined in limits.h."
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:26:2: error: #error "Python's source code assumes C's unsigned char is an 8-bit type."
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:33:19: error: stdio.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:35:5: error: #error "Python.h requires that stdio.h define NULL."
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:38:20: error: string.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:40:19: error: errno.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:42:20: error: stdlib.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:44:20: error: unistd.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:56:20: error: assert.h: No such file or directory
...
etc
My questions:
What I need to do to install
py2objc? Unfortunately, I haven't
found a solution for errors, which I
posted previously.
As I understand
there are two kinds of python. One I
installed into Applications folder
(IDLE, launcher), another is the
current Python version supplied with
OS. Can you describe the
difference?
How can I select the
current version of Python used by
Mac OS? And what is the Current
folder in
/Library/Frameworks/Python.framework?
Probably it looks confusing, but this is my first steps! :)
Thank you
Cannot give a definitive answer to that. See comment.
You can install multiple versions of python on your machine (OSX includes a defualt one as you already mentioned). In the applications folder there are some apps to open an interactive interpreter in which you can enter python commands, such as IDLE. These applications use one of the python versions you've got installed. Which brings us to
python_select is the command you want. e.g. python_select -l to list all the python versions you've got installed and python_select python27 to select your own 2.7 version. The Current folder links to the version currently selected via python_select

Categories