Windows / ctypes issue with custom build

2017-03-27 Thread Eric Frederich
I built my own Python 2.7.13 for Windows because I'm using bindings to a 3rd party application which were built with Visual Studio 2012. I started to code up some stuff using the "click" module and found an error when using click.echo with any kind of unicode input. Python 2.7.13 (default, Mar

Compiling new Pythons on old Windows compilers

2017-03-12 Thread Eric Frederich
There is a commercial application which allows customizations through a C API. There are 3 different releases of this application each compiled with different versions of Visual Studio, 2008, 2010, and 2012. I'd like to release a customization which embeds a Python interpreter, but I'd like to use

Re: Passing C pionters to Python for use with cffi

2013-10-18 Thread Eric Frederich
r to Python so that cffi can cast and use it. On Fri, Oct 11, 2013 at 2:09 AM, dieter wrote: > Eric Frederich writes: > > > I'm extending an application that supports customization using the C > > language. > > I am able to write standalone python applications that

Passing C pionters to Python for use with cffi

2013-10-10 Thread Eric Frederich
Hello, I'm extending an application that supports customization using the C language. I am able to write standalone python applications that use the C API's using cffi. This is good, but only a first step. This application allows me to register code that will run on various events but it has to b

Re: embedding interactive python interpreter

2013-09-11 Thread Eric Frederich
Scott, Yes. As Mark Hammond suggested I took a look into the code/console modules. I wound up using InteractiveConsole from the code module. I'm sure my requirements are completely different from yours but I'll explain what I did anyway... I was working with a client/server architecture where I w

Re: distributing a binary package

2013-05-07 Thread Eric Frederich
I see where I can specify a module that distutils will try to compile. I already have the .so files compiled. I'm sure its simple, I just can't find it or don't know what to look for. On Mon, May 6, 2013 at 9:13 PM, Miki Tebeka wrote: > >> Basically, I'd like to know how to create a proper setup

distributing a binary package

2013-05-06 Thread Eric Frederich
Hello, Hopefully a simple question. Basically, I'd like to know how to create a proper setup.py script to install a package. The package exists as a single directory with a single __init__.py file and (currently) 93 .so files. Right now I just copy it into the site-packages directory but I'd like

Python platform/framework for new RESTful web app

2013-04-25 Thread Eric Frederich
If I wanted to create a new web application (RESTful) today with Python what are my options given the following requirements. * Google Account authentication * Facebook authentication * Managed hosting (like Google App Engine or Heroku) but with the ability to be self-hosted later down the road.

empty object from C

2012-12-07 Thread Eric Frederich
Hello, >From C, I'd like to call a Python function that takes an object and sets some attributes on it. Lets say this is the function... def foo(msg): msg.bar = 123 msg.spam = 'eggs' How do I create an empty object in C? In Python I would do something like this... class Msg(object):

Re: error importing smtplib

2012-11-19 Thread Eric Frederich
I can do this in stand alone programs because my code does the import and calls the login function so I can control the order of things. Unfortunately stand alone programs are not the only ways in which I am using these Python bindings. You can customize and extend this 3rd party application at va

Re: error importing smtplib

2012-11-16 Thread Eric Frederich
n I try to import smtplib it tries getting things from there and that is where the errors are coming from. The question now is how do I fix this? On Thu, Nov 15, 2012 at 4:37 PM, Terry Reedy wrote: > On 11/15/2012 1:48 PM, Eric Frederich wrote: > >> Thanks for the idea. >>

Re: error importing smtplib

2012-11-15 Thread Eric Frederich
11:57 AM, Terry Reedy wrote: > On 11/15/2012 9:38 AM, Eric Frederich wrote: > >> Hello, >> >> I created some bindings to a 3rd party library. >> I have found that when I run Python and import smtplib it works fine. >> If I first log into the 3rd party application u

Re: error importing smtplib

2012-11-15 Thread Eric Frederich
Thanks for the idea. sys.path was the same before and after the login What else should I be checking? On Thu, Nov 15, 2012 at 11:57 AM, Terry Reedy wrote: > On 11/15/2012 9:38 AM, Eric Frederich wrote: > >> Hello, >> >> I created some bindings to a 3rd party library. &

error importing smtplib

2012-11-15 Thread Eric Frederich
Hello, I created some bindings to a 3rd party library. I have found that when I run Python and import smtplib it works fine. If I first log into the 3rd party application using my bindings however I get a bunch of errors. What do you think this 3rd party login could be doing that would affect the

Re: remote read eval print loop

2012-08-21 Thread Eric Frederich
= MyInteractiveConsole() On Fri, Aug 17, 2012 at 10:06 AM, Chris Angelico wrote: > On Fri, Aug 17, 2012 at 11:28 PM, Eric Frederich > wrote: > > Within the debugging console, after importing all of the bindings, there > > would be no reason to import anything whatso

Re: remote read eval print loop

2012-08-17 Thread Eric Frederich
What I wanted to implement was a debugging console that runs right on the client rather than on the server. You'd have to be logged into the application to do anything meaningful or even start it up. All of the C functions that I created bindings for respect the security of the logged in user. Wit

remote read eval print loop

2012-08-16 Thread Eric Frederich
Hello, I have a bunch of Python bindings for a 3rd party software running on the server side. I can add client side extensions that communicate over some http / xml type requests. So I can define functions that take a string and return a string. I would like to get a simple read eval print loop wo

Re: properly catch SIGTERM

2012-07-20 Thread Eric Frederich
On Fri, Jul 20, 2012 at 1:51 AM, Jason Friedman wrote: > > This seems to work okay but just now I got this while hitting ctrl-c > > It seems to have caught the signal at or in the middle of a call to > > sys.stdout.flush() > > > > > > --- Caught SIGTERM; Attempting to quit gracefully --- > > Trac

properly catch SIGTERM

2012-07-19 Thread Eric Frederich
So I wrote a script which acts like a daemon. And it starts with something like this ### Begin Code import signal STOPIT = False def my_SIGTERM_handler(signum, frame): global STOPIT print '\n--- Caught SIGTERM; Attempting to quit gracefully ---' STOPIT = True signal.sig

Re: Get stack trace from C

2012-04-18 Thread Eric Frederich
2012 at 1:15 AM, Stefan Behnel wrote: > Eric Frederich, 16.04.2012 20:14: > > I embed Python in a 3rd party application. > > I need to use their conventions for errors. > > > > Looking here... > > http://docs.python.org/extending/embedding.html#pure-embeddin

Get stack trace from C

2012-04-16 Thread Eric Frederich
I embed Python in a 3rd party application. I need to use their conventions for errors. Looking here... http://docs.python.org/extending/embedding.html#pure-embedding ...the example uses PyErr_Print() but that goes to stdout or stderr or something. I need to put the error somewhere else. How

Re: multiprocessing, what am I doing wrong?

2012-02-28 Thread Eric Frederich
27/02/2012 16:57, Eric Frederich wrote: > >> Still freezing sometimes, like 1 out of 10 times that I run it. >> Here is updated code and a couple of outputs. >> >> [snip] > I don't know what the problem is. All I can suggest is a slightly > modified version. &

Re: multiprocessing, what am I doing wrong?

2012-02-27 Thread Eric Frederich
ning Worker 2 2 9 20 35 54 77 104 135 170 209 252 299 350 405 464 527 594 665 Traceback (most recent call last): File "./multi.py", line 53, in print result_queue.get() File "/home/frede00e/software/python/lib/python2.7/multiprocessing/queues.py", line 91, in get res =

Re: multiprocessing, what am I doing wrong?

2012-02-24 Thread Eric Frederich
I can sill get it to freeze and nothing is printed out from the other except block. Does it look like I'm doing anything wrong here? On Thu, Feb 23, 2012 at 3:42 PM, MRAB wrote: > On 23/02/2012 17:59, Eric Frederich wrote: > >> Below is some pretty simple code and the

multiprocessing, what am I doing wrong?

2012-02-23 Thread Eric Frederich
Below is some pretty simple code and the resulting output. Sometimes the code runs through but sometimes it just freezes for no apparent reason. The output pasted is where it just got frozen on me. It called start() on the 2nd worker but the 2nd worker never seemed to enter the run method. ###

nested embedding of interpreter

2012-02-06 Thread Eric Frederich
Hello, I work with a 3rd party tool that provides a C API for customization. I created Python bindings for this C API so my customizations are nothing more than this example wrapper code almost verbatim: http://docs.python.org/extending/embedding.html#pure-embedding I have many .c files just

portable multiprocessing code

2011-05-17 Thread Eric Frederich
I have written some code using Python 2.7 but I'd like these scripts to be able to run on Red Hat 5's 2.4.3 version of Python which doesn't have multiprocessing. I can try to import multiprocessing and set a flag as to whether it is available. Then I can create a Queue.Queue instead of a multiproc

multiple Python 2.7 Windows installations

2011-04-19 Thread Eric Frederich
Hello, I am trying to get an installer built with distutils to recognize multiple installations. The installer currently finds my installation at C:\Python27 I have a custom Python27 built myself with Visual Studio sitting somewhere else, say C:\MyPython27. I looked at PC/bdist_wininst/install.c

Re: installing setuptools on Windows custom python install

2011-04-19 Thread Eric Frederich
his file would the socket library then be built into the main dll file? I'm not sure exactly how to use this config.c file. Thanks, ~Eric On Mon, Apr 18, 2011 at 2:30 PM, Wolfgang Rohdewald wrote: > On Montag 18 April 2011, Eric Frederich wrote: >>   File "F:\My_Python27\lib\s

installing setuptools on Windows custom python install

2011-04-18 Thread Eric Frederich
Hello, I have a python installation that I built myself using Visual Studio 2005. I need this version because I need to link Python bindings to a 3rd party library that uses VS 2005. I want to get setuptools installed to this Python installation but the installer won't find my version of Python e

Re: embedding interactive python interpreter

2011-03-27 Thread Eric Frederich
: > On Friday, March 25, 2011 12:02:16 PM UTC-4, Eric Frederich wrote: >> >> Is there something else I should call besides "exit()" from within the >> interpreter? >> Is there something other than Py_Main that I should be calling? > > Does PyRun_Interactive

Re: embedding interactive python interpreter

2011-03-27 Thread Eric Frederich
ot; or "sys.exit(123)". I cannot call any of my C cleanup code because of this. On Sun, Mar 27, 2011 at 1:55 PM, Jerry Hill wrote: > On Sun, Mar 27, 2011 at 9:33 AM, Eric Frederich > wrote: >> This is behavior contradicts the documentation which says the value >>

Re: embedding interactive python interpreter

2011-03-27 Thread Eric Frederich
This is behavior contradicts the documentation which says the value passed to sys.exit will be returned from Py_Main. Py_Main doesn't return anything, it just exits. This is a bug. On Sun, Mar 27, 2011 at 3:10 AM, Mark Hammond wrote: > On 26/03/2011 4:37 AM, Eric Frederich wrote: >

Re: embedding interactive python interpreter

2011-03-25 Thread Eric Frederich
Added a fflush(stdout) after each printf and, as I expectedstill only the first 2 prints. On Fri, Mar 25, 2011 at 1:47 PM, MRAB wrote: > On 25/03/2011 17:37, Eric Frederich wrote: >> >> So I found that if I type ctrl-d then the other lines will print. >> >>

Re: embedding interactive python interpreter

2011-03-25 Thread Eric Frederich
to pass a value back from the interpreter via sys.exit. Thanks, ~Eric On Fri, Mar 25, 2011 at 12:02 PM, Eric Frederich wrote: > I am able to embed the interactive Python interpreter in my C program > except that when the interpreter exits, my entire program exits. > >    #include >

embedding interactive python interpreter

2011-03-25 Thread Eric Frederich
I am able to embed the interactive Python interpreter in my C program except that when the interpreter exits, my entire program exits. #include #include int main(int argc, char *argv[]){ printf("line %d\n", __LINE__); Py_Initialize(); printf("line %d\n", __LI

Re: Creating custom Python objects from C code

2011-01-05 Thread Eric Frederich
On Wed, Jan 5, 2011 at 11:39 AM, Antoine Pitrou wrote: > On Wed, 5 Jan 2011 11:27:02 -0500 > Eric Frederich wrote: >> I have read through all the documentation here: >> >>     http://docs.python.org/extending/newtypes.html >> >> I have not seen any documenta

Creating custom Python objects from C code

2011-01-05 Thread Eric Frederich
I have read through all the documentation here: http://docs.python.org/extending/newtypes.html I have not seen any documentation anywhere else explaining how to create custom defined objects from C. I have this need to create custom objects from C and pass them as arguments to a function call

Re: Creating custom types from C code

2010-12-20 Thread Eric Frederich
n and instantiate that type from C? On Sat, Dec 18, 2010 at 1:18 AM, Stefan Behnel wrote: > Eric Frederich, 17.12.2010 23:58: >> >> I have an extension module for a 3rd party library in which I am >> wrapping some structures. >> My initial attempt worked okay on Windo

Creating custom types from C code

2010-12-17 Thread Eric Frederich
Hello, I have an extension module for a 3rd party library in which I am wrapping some structures. My initial attempt worked okay on Windows but failed on Linux. I was doing it in two parts. The first part on the C side of things I was turning the entire structure into a char array. The second part

Reference counting problems?

2010-12-09 Thread Eric Frederich
I am attempting to automate the building of binding for a 3rd party library. The functions I'm wrapping all return an integer of whether they failed and output are passed as pointers. There can be multiple return values. So the code that I generate has a PyObject* called python__return_val that I u

Re: multiple modules from single c extension

2010-12-02 Thread Eric Frederich
e for each module"? Are you saying that in python when I say from "Spam.ABC import *" I need a file called "Spam.ABC.[so|pyd]"? On Wed, Dec 1, 2010 at 8:39 PM, Robert Kern wrote: > On 12/1/10 4:12 PM, Eric Frederich wrote: >> >> I have an extension to

multiple modules from single c extension

2010-12-01 Thread Eric Frederich
I have an extension to some C library that I created using the guide found here... http://docs.python.org/extending/extending.html I am starting to have A LOT of functions being wrapped. The library that I'm creating bindings for is organized into modules. In fact, all of their function call

C struct to Python

2010-11-30 Thread Eric Frederich
I am not sure how to proceed. I am writing a Python interface to a C library. The C library uses structures. I was looking at the struct module but struct.unpack only seems to deal with data that was packed using struct.pack or some other buffer. All I have is the struct itself, a pointer in C. Is

Round Trip: C to Python to C Module

2010-11-19 Thread Eric Frederich
I have a proprietary software PropSoft that I need to extend. They support extensions written in C that can link against PropLib to interact with the system. I have a Python C module that wraps a couple PropLib functions that I call PyProp. >From an interactive Python shell I can import PyProp and

Re: Extension on Windows

2010-11-19 Thread Eric Frederich
On Fri, Nov 19, 2010 at 8:12 AM, Ulrich Eckhardt wrote: > Eric Frederich wrote: >> Do I put them [DLL dependencies] in some environment variable? >> Do I put them in site-packages along with the .pyd file, or in some >> other directory? > > Take a look at the

Re: Extension on Windows

2010-11-19 Thread Eric Frederich
On Fri, Nov 19, 2010 at 7:28 AM, Ulrich Eckhardt wrote: >> Now when I created a 2nd function to wrap a library function I get the >> following. >> >> ImportError: DLL load failed: The specified module could not be found. > > This can mean that the module itself couldn't be loaded or that one of t

Extension on Windows

2010-11-18 Thread Eric Frederich
Hello, I am trying to create an extension on Windows and I may be over my head but I have made it pretty far. I am trying to create bindings for some libraries which require me to use Visual Studio 2005. I set up the spammodule example and in VS set the output file to be a .pyd file. When I copy