Re: [Python-Dev] Hi, I am new to this board and have a question

2015-02-05 Thread Nick Coghlan
On 5 February 2015 at 12:26, Alexander Belopolsky
 wrote:
>
> On Wed, Feb 4, 2015 at 6:18 PM, Jianhua Zhou 
> wrote:
>>
>> The necessary bits to build these optional modules were not found:
>> _bz2  _lzma _ssl
>> _tkinter  zlib
>> So what package name should I gave to download the additional source to
>> build the optional module?
>
> Questions like this are really better asked on Red Hat forums, but off the
> top of my head, you need *-devel packages such as zlib-devel, openssl-devel,
> etc.  It is usually easy to figure out from yum search.

I actually have a few suggestions here:

1. The system build deps for Python 2 should be the same as those for
Python 3, so "yum-builddep python" should solve the problem of getting
dependencies to do your own build

2. You may also be interested in Slavek's proposal to add a Python 3.4
stack to EPEL: https://fedoraproject.org/wiki/User:Bkabrda/EPEL7_Python3
(Relevant discussions at [1] and [2])

3. Alternatively, Software Collections may be a better fit for your
use case: http://wiki.centos.org/AdditionalResources/Repositories/SCL

As Alexander says though, we're getting a bit off topic for upstream
python-dev - this is more a topic for EPEL, CentOS or the Red Hat
customer portal.

Regards,
Nick.

[1] 
https://lists.fedoraproject.org/pipermail/epel-devel/2014-December/010548.html
[2] 
https://lists.fedoraproject.org/pipermail/epel-devel/2014-January/009043.html

>
>
>
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com
>



-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Hi, I am new to this board and have a question

2015-02-05 Thread Bohuslav Kabrda
- Original Message -

> Hi Everyone,

> I am a core software engineer at Rocket Software Inc. I am working on
> database system called UniData and Universe.

> Now we plan to introduce Python as the new programming language to our
> customer. When I try to build the python 3.4.1 on Red Hat Linux platform. I
> found some problem and need help.

> After I run configure and make the python, at the very end, it said some
> optional modules we missing,

> Python build finished successfully!

> The necessary bits to build these optional modules were not found:

> _bz2 _lzma _ssl

> _tkinter zlib

> So, I went to python development guide site and found out I have to download
> some other source to build the optional modules.

> Since I am on RH Linux and yum is installed on my Linux box, so I run
> following command

> # yum install yum-utils

> Loaded plugins: product-id, refresh-packagekit, security,
> subscription-manager

> This system is not registered to Red Hat Subscription Management. You can use
> subscription-manager to register.

> WANdisco | 951 B 00:00

> WANdisco/primary | 94 kB 00:00

> WANdisco 450/450

> my_repo | 3.9 kB 00:00 ...

> Setting up Install Process

> Package yum-utils-1.1.30-14.el6.noarch already installed and latest version

> Nothing to do

> Looks like yum-utils is already installed. Then

> # yum-builddep python3

> Loaded plugins: product-id, refresh-packagekit

> No such package(s): python3

> So what package name should I gave to download the additional source to build
> the optional module?

> Thanks!

> Jianhua Zhou

> 
> Rocket Software, Inc. and subsidiaries ■ 77 Fourth Avenue, Waltham MA 02451 ■
> +1 800.966.3270 ■ +1 781.577.4321
> Unsubscribe From Commercial Email – unsubscr...@rocketsoftware.com
> Manage Your Subscription Preferences -
> http://info.rocketsoftware.com/GlobalSubscriptionManagementEmailFooter_SubscriptionCenter.html
> Privacy Policy - http://www.rocketsoftware.com/company/legal/privacy-policy
> 
> This communication and any attachments may contain confidential information
> of Rocket Software, Inc. All unauthorized use, disclosure or distribution is
> prohibited. If you are not the intended recipient, please notify Rocket
> Software immediately and destroy all copies of this communication. Thank
> you.

Hi Jianhua, 
this is probably not a question to be asked on this list. If you need some 
help, please drop me a private mail and I can help you sort this out (I'm the 
RHEL Python maintainer, so I consider myself pretty knowledgeable about these 
things ;)). 

Slavek 
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Import Fails in setup.py On Android

2015-02-05 Thread Cyd Haselton
While I'm waiting for a response from mobile-sig, I'm going through
the documentation (and something called "fossies") of importlib.  I
hope that it's okay to ask some follow up questions...even though I've
redirected this post to mobile-sig.

If it is, my first question(s) is/are about the import machinery and
C-extension modules. Assuming that C-extension modules are ones that
include files that are named as *.c, how does the import machinery
handle specified shared libraries, such as -ldl?  Additionally, how
does the import machinery handle the symbols from those libraries...if
it does at all?

On Tue, Feb 3, 2015 at 12:10 AM, Eric Snow  wrote:
> On Mon, Feb 2, 2015 at 12:36 PM, Cyd Haselton  wrote:
>> After fixing a segfault issue (many thanks Ryan) I'm back to the same issue
>> I was having with Python 2.7.8; the newly built python throws an undefined
>> reference to dlopen when running setup.py...specifically when importing
>> just-built extensions
>>
>> I've managed to narrow the problem down to the following line:
>>
>> importlib._bootstrap._SpecMethods(spec).load()
>
> That call is where modules are created (and executed) via the loader
> designated for the module by the import machinery.  So a problem here
> may simply reflect a problem with the loader.  Which module is being
> imported when you run into trouble?  Is it a C-extension module?
>
> Also keep in mind that basically everything in importlib._bootstrap is
> frozen into your Python binary when you build Python (or should be).
> So if you are seeing any errors related to something missing or broken
> in importlib._bootstrap, it could be related to the build step where
> importlib gets frozen.
>
> Either way, more info (e.g. a traceback) would be great if you need more help.
>
> -eric
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Encoding of PyFrameObject members

2015-02-05 Thread Francis Giraldeau
I need to access frame members from within a signal handler for tracing
purpose. My first attempt to access co_filename was like this (omitting
 error checking):

PyFrameObject *frame = PyEval_GetFrame();
PyObject *ob = PyUnicode_AsUTF8String(frame->f_code->co_filename)
char *str = PyBytes_AsString(ob)

However, the function PyUnicode_AsUTF8String() calls PyObject_Malloc(),
which is not reentrant. If the signal handler nest over PyObject_Malloc(),
it causes a segfault, and it could also deadlock.

Instead, I access members directly:
char *str = PyUnicode_DATA(frame->f_code->co_filename);
size_t len = PyUnicode_GET_DATA_SIZE(frame->f_code->co_filename);

Is it safe to assume that unicode objects co_filename and co_name are
always UTF-8 data for loaded code? I looked at the PyTokenizer_FromString()
and it seems to convert everything to UTF-8 upfront, and I would like to
make sure this assumption is valid.

Thanks!

Francis
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Encoding of PyFrameObject members

2015-02-05 Thread Chris Angelico
On Fri, Feb 6, 2015 at 10:27 AM, Francis Giraldeau
 wrote:
> Instead, I access members directly:
> char *str = PyUnicode_DATA(frame->f_code->co_filename);
> size_t len = PyUnicode_GET_DATA_SIZE(frame->f_code->co_filename);
>
> Is it safe to assume that unicode objects co_filename and co_name are always
> UTF-8 data for loaded code? I looked at the PyTokenizer_FromString() and it
> seems to convert everything to UTF-8 upfront, and I would like to make sure
> this assumption is valid.

I don't think you should be using _GET_DATA_SIZE with _DATA - they're
mix-and-matched from old and new APIs. If you want a raw,
no-allocation look at the data, you'd need to check PyUnicode_KIND and
then read Latin-1, UCS-2, or UCS-4 data:

https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_1BYTE_DATA

(By the way, I don't think the name "UCS-1" is part of the Unicode
spec. But it's an obvious parallel to UCS-2 and UCS-4.)

Getting UTF-8 data out of the structure, if it had indeed been cached,
ought to be possible. But I can't see a documented function or macro
for doing it. Is there a way? Reaching into the structure and grabbing
the utf8 and utf8_length members seems like a bad idea.

ChrisA
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Azure event hub network access

2015-02-05 Thread syed khalid
I am getting http error 404. I am able to access the site via telnet which
eliminates network issues. Here is the code and subsequent errors



user/bin/python
import sys
import azure
import socket

from azure.servicebus import (
  _service_bus_error_handler
  )

from azure.servicebus.servicebusservice import (
  ServiceBusService,
  ServiceBusSASAuthentication
  )

from azure.http import (
  HTTPRequest,
  HTTPError
  )

from azure.http.httpclient import _HTTPClient

class EventHubClient(object):

def sendMessage(self,body,partition):
eventHubHost = "pac-ns.servicebus.windows.net"

httpclient = _HTTPClient(service_instance=self)

sasKeyName = "pac-pl"
sasKeyValue = "IhkEepQPLfSy9jo6H2Y="

authentication = ServiceBusSASAuthentication(sasKeyName,sasKeyValue)

request = HTTPRequest()
request.method = "POST"
request.host = eventHubHost
request.protocol_override = "https"
#request.path = "/myhub/publishers/" + partition +
"/messages?api-version=20
14-05"
request.body = body
request.headers.append(('Content-Type',
'application/atom+xml;type=entry;cha
rset=utf-8'))

authentication.sign_request(request, httpclient)

request.headers.append(('Content-Length', str(len(request.body
status = 0

try:
resp = httpclient.perform_request(request)
status = resp.status
except HTTPError as ex:
status = ex.status

return status

class EventDataParser(object):

  def getMessage(self,payload,sensorId):
host = socket.gethostname()
body = "{ \"DeviceId\" : \"" + host + "\",\"SensorData\": [ "

msgs = payload.split(",")
first = True

for msg in msgs:
# print msg
  sensorType = msg.split(":")[0]
sensorValue = msg.split(":")[1]
  if first == True:
first = False
  else:
body += ","

  body += "{ \"SensorId\" : \"" + sensorId + "\", \"SensorType\" : \""
+ sen
sorType + "\", \"SensorValue\" : " + sensorValue + " }"
body += "]}"

return body

hubClient = EventHubClient()
parser = EventDataParser()
hostname = socket.gethostname()
sensor = sys.argv[2]

body = parser.getMessage(sys.argv[1],sensor)
hubStatus = hubClient.sendMessage(body,hostname)
# return the HTTP status to the caller
print hubStatus
print hostname
print sensor




~/IOT/AZURE$ python send.py temperature:22,humidity:20 deviceid

404
ubuntu
deviceid
{ "DeviceId" : "ubuntu","SensorData": [ { "SensorId" : "deviceid",
"SensorType" : "temperature", "SensorValue" : 22 },{ "SensorId" :
"deviceid", "SensorType" : "humidity", "SensorValue" : 20 }]}




-- 
*Syed Khalid*
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Azure event hub network access

2015-02-05 Thread Steve Dower
This would be much better posted on the github page for the project. I don't 
have the URL handy, but if you search github for "Python Azure SDK" you'll find 
it.

Cheers,
Steve

Sent from my Windows Phone

From: syed khalid
Sent: ‎2/‎5/‎2015 21:27
To: python-dev@python.org
Cc: python-l...@python.org
Subject: [Python-Dev] Azure event hub network access

I am getting http error 404. I am able to access the site via telnet which 
eliminates network issues. Here is the code and subsequent errors



user/bin/python
import sys
import azure
import socket

from azure.servicebus import (
  _service_bus_error_handler
  )

from azure.servicebus.servicebusservice import (
  ServiceBusService,
  ServiceBusSASAuthentication
  )

from azure.http import (
  HTTPRequest,
  HTTPError
  )

from azure.http.httpclient import _HTTPClient

class EventHubClient(object):

def sendMessage(self,body,partition):
eventHubHost = 
"pac-ns.servicebus.windows.net"

httpclient = _HTTPClient(service_instance=self)

sasKeyName = "pac-pl"
sasKeyValue = "IhkEepQPLfSy9jo6H2Y="

authentication = ServiceBusSASAuthentication(sasKeyName,sasKeyValue)

request = HTTPRequest()
request.method = "POST"
request.host = eventHubHost
request.protocol_override = "https"
#request.path = "/myhub/publishers/" + partition + "/messages?api-version=20
14-05"
request.body = body
request.headers.append(('Content-Type', 'application/atom+xml;type=entry;cha
rset=utf-8'))

authentication.sign_request(request, httpclient)

request.headers.append(('Content-Length', str(len(request.body
status = 0

try:
resp = httpclient.perform_request(request)
status = resp.status
except HTTPError as ex:
status = ex.status

return status

class EventDataParser(object):

  def getMessage(self,payload,sensorId):
host = socket.gethostname()
body = "{ \"DeviceId\" : \"" + host + "\",\"SensorData\": [ "

msgs = payload.split(",")
first = True

for msg in msgs:
# print msg
  sensorType = msg.split(":")[0]
sensorValue = msg.split(":")[1]
  if first == True:
first = False
  else:
body += ","

  body += "{ \"SensorId\" : \"" + sensorId + "\", \"SensorType\" : \"" + sen
sorType + "\", \"SensorValue\" : " + sensorValue + " }"
body += "]}"

return body

hubClient = EventHubClient()
parser = EventDataParser()
hostname = socket.gethostname()
sensor = sys.argv[2]

body = parser.getMessage(sys.argv[1],sensor)
hubStatus = hubClient.sendMessage(body,hostname)
# return the HTTP status to the caller
print hubStatus
print hostname
print sensor




~/IOT/AZURE$ python send.py temperature:22,humidity:20 deviceid

404
ubuntu
deviceid
{ "DeviceId" : "ubuntu","SensorData": [ { "SensorId" : "deviceid", "SensorType" 
: "temperature", "SensorValue" : 22 },{ "SensorId" : "deviceid", "SensorType" : 
"humidity", "SensorValue" : 20 }]}




--
Syed Khalid

___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Encoding of PyFrameObject members

2015-02-05 Thread Gregory P. Smith
On Thu Feb 05 2015 at 4:36:30 PM Francis Giraldeau <
francis.girald...@gmail.com> wrote:

> I need to access frame members from within a signal handler for tracing
> purpose. My first attempt to access co_filename was like this (omitting
>  error checking):
>
> PyFrameObject *frame = PyEval_GetFrame();
> PyObject *ob = PyUnicode_AsUTF8String(frame->f_code->co_filename)
> char *str = PyBytes_AsString(ob)
>
> However, the function PyUnicode_AsUTF8String() calls PyObject_Malloc(),
> which is not reentrant. If the signal handler nest over PyObject_Malloc(),
> it causes a segfault, and it could also deadlock.
>
> Instead, I access members directly:
> char *str = PyUnicode_DATA(frame->f_code->co_filename);
> size_t len = PyUnicode_GET_DATA_SIZE(frame->f_code->co_filename);
>
> Is it safe to assume that unicode objects co_filename and co_name are
> always UTF-8 data for loaded code? I looked at the PyTokenizer_FromString()
> and it seems to convert everything to UTF-8 upfront, and I would like to
> make sure this assumption is valid.
>

The faulthandler module calls into Python/traceback.c in signal context
which has some low level code for extracting something useful from
PyUnicode objects without triggering a conversion:

https://hg.python.org/cpython/file/f1a82e949fb8/Python/traceback.c#l531

That code is written to write output to a fd. It's much more useful for
signal handler tracing data collection from a signal handler if you
refactor it to dump its output into a preallocated char* buffer.

-gps


>
> Thanks!
>
> Francis
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/
> greg%40krypto.org
>
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Encoding of PyFrameObject members

2015-02-05 Thread Maciej Fijalkowski
Hi Francis

I don't think it's safe to assume f_code is properly filled by the
time you might read it, depending a bit where you find the frame
object. Are you sure it's not full of garbage?

Besides, are you writing a profiler, or what exactly are you doing?

On Fri, Feb 6, 2015 at 1:27 AM, Francis Giraldeau
 wrote:
> I need to access frame members from within a signal handler for tracing
> purpose. My first attempt to access co_filename was like this (omitting
> error checking):
>
> PyFrameObject *frame = PyEval_GetFrame();
> PyObject *ob = PyUnicode_AsUTF8String(frame->f_code->co_filename)
> char *str = PyBytes_AsString(ob)
>
> However, the function PyUnicode_AsUTF8String() calls PyObject_Malloc(),
> which is not reentrant. If the signal handler nest over PyObject_Malloc(),
> it causes a segfault, and it could also deadlock.
>
> Instead, I access members directly:
> char *str = PyUnicode_DATA(frame->f_code->co_filename);
> size_t len = PyUnicode_GET_DATA_SIZE(frame->f_code->co_filename);
>
> Is it safe to assume that unicode objects co_filename and co_name are always
> UTF-8 data for loaded code? I looked at the PyTokenizer_FromString() and it
> seems to convert everything to UTF-8 upfront, and I would like to make sure
> this assumption is valid.
>
> Thanks!
>
> Francis
>
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/fijall%40gmail.com
>
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com