"…mais ce serait peut-être l'une des plus grandes opportunités manquées de notre époque si le logiciel libre ne libérait rien d'autre que du code…"

Archive for avril 2010

An other ctypes based python module : pyUSB 1.0 (alpha) is out !

Posted by patrick sur avril 22, 2010

http://pyusb.sourceforge.net
http://pyusb.sourceforge.net/docs/1.0/tutorial.html 

=======================================
PyUSB 1.0 – Easy USB access from Python
=======================================

Introduction
============

The PyUSB module provides Python with easy access to the host
machine’s Universal Serial Bus (USB) system.

Until 0.4 version, PyUSB used to be a thin wrapper aroung libusb.
With 1.0 version, things changed considerably. Now PyUSB is an
API rich, backend neutral Python USB module easy to use.

As with most Python modules, PyUSB’s documentation is based on Python
doc strings and can therefore be manipulated by tools such as pydoc.

You can also find a tutorial at: http://pyusb.sourceforge.net/docs/1.0/tutorial.html.

PyUSB is being developed and tested in Linux and Windows, but it should work
fine in any platform running Python >= 2.3, ctypes and at least one of the
builtin backends.

PyUSB supports libusb 0.1, libusb 1.0 and OpenUSB, but the user does not need
to worry about that, unless in some corner cases.

If you have any question about PyUSB, you can use the PyUSB mailing list
hosted in the SourceForge. In the PyUSB website (http://pyusb.sourceforge.net)
you can find instructions on how to subscribe to the mailing list.

Installing PyUSB on GNU/Linux Systems
=====================================

These instructions are for Debian-based systems.  Instructions for
other flavors of GNU/Linux should be similar.

You will first need to install the following packages:

1) python (PyUSB is useless without it), version >= 2.3
2) At least one of the supported libraries (libusb 1.0, libusb 0.1 or OpenUSB)
3) If your Python version is < 2.5, you have to install ctypes as a separate package,
because these versions of Python does not ship it.

For example, the command

sudo apt-get install python libusb

should install all these packages on most Debian-based systems with
access to the proper package repositories.

Once the above packages are installed, you can install PyUSB
with the command

python setup.py install

run as root from within the same directory as this README file.

Installing PyUSB on Windows
===========================

Now that PyUSB is 100% written in Python, you install it on Windows
in the same way you do on Linux, but libusb for Windows is done
through libusb-win32 package (libusb 1.0 backend is in progress).
To install it you do as usual:

python setup.py install

Reporting bugs/Submitting patches
=================================

Some people have been sending me patches and reporting bugs directly
in my email. Please, do it through SourceForge tracker, I had
a hardtime tracking their names to put them in the acknowledgments file. 😉

PS: this README file was based on the great Josh Lifton’s one… ^_^

import usb.core
import usb.util

# find our device
dev = usb.core.find(idVendor=0xfffe, idProduct=0x0001)

# was it found?
if dev is None:
    raise ValueError('Device not found')

# set the active configuration. With no arguments, the first
# configuration will be the active one
dev.set_configuration()

# get an endpoint instance
ep = usb.util.find_descriptor(
        dev.get_interface_altsetting(),   # first interface
        # match the first OUT endpoint
        custom_match = \
            lambda e: \
                usb.util.endpoint_direction(e.bEndpointAddress) == \
                usb.util.ENDPOINT_OUT
    )

assert ep is not None

# write the data
ep.write('test')

Voir aussi

  • http://docs.python.org/library/ctypes.html (‘ctypes is a foreign function library for Python. It provides C compatible data types, and allows calling functions in DLLs or shared libraries. It can be used to wrap these libraries in pure Python’)
  • http://pypi.python.org/pypi/jaraco.windows/1.8 (‘jaraco.windows aims to provide a pure-python interface to Windows APIs using ctypes. This package is not designed to be exhaustive, but rather to supply interfaces as they are needed by the contributors.’)

Posted in 2010, ctypes, Operating Systems, python, USB | Tagué: , | Leave a Comment »

Python packaging : Hitchhiker guide, toydist, envbuilder

Posted by patrick sur avril 22, 2010

Toujours beaucoup de mouvement en ce qui concerne la distribution de modules python.

  • http://cournape.wordpress.com/2010/04/22/first-public-release-of-toydist/ (‘The goals of toydist are simplicity and extensibility. There should be only one way to package simple packages (ideally, relying only on the toysetup.info file), while being flexible enough to handle complex softwares. The ultimate goal of toydist is to replace the hideous distutils extensions to build NumPy and SciPy. ‘)
  • http://pypi.python.org/pypi/envbuilder/0.3.0 (‘ A package for automatic generation of virtualenvs Envbuilder is a system for automatically building virtualenvs in Python. To do this, it uses a .env config file to define parcels, which are individual pieces of software to be checked out and installed into the virtualenv. It is mainly tested under Linux, but it should work under any platform that supports unix-y commands (including cygwin). In fact, you might even be able to make one config file work on both Windows and *nix if you’re careful.’)

Posted in 2010, Développement logiciel, distribute, Distribution de logiciel, Doc_sphinx, Génie logiciel, package_management, packaging, toydist | Leave a Comment »

Le service de construction de paquetages d’openSUSE : openSUSE build service (OBS)

Posted by patrick sur avril 7, 2010

  • http://en.wikipedia.org/wiki/OpenSUSE_Build_Service (« …The openSUSE Build Service is an open and complete distribution development platform designed to encourage developers to compile packages for multiple Linux distributions including openSUSE, Red Hat, Mandriva, Ubuntu, Fedora and Debian. It typically simplifies the packaging process, so developers can more easily package a single program for many distributions, and many openSUSE releases, making more packages available to users regardless of what distribution version they use. The build service software is published under the GPL. In an acknowledgement of its usefulness to the wider Linux community, the Linux Foundation has announced that the project will be added to the Linux Developer Network (LDN) »)
  • http://fr.opensuse.org/Build_Service ( » … OpenSUSE Build Service (OBS) est une plateforme complète de développement de distribution fournissant l’infrastructure nécessaire pour le développement des futures distributions basées sur openSUSE. Il comporte également les services qui permettent la compilation et la création de paquets pour les autres distributions Linux, comme Fedora, Debian, Ubuntu, et bien d’autres. Les utilisateurs d’openSUSE peuvent facilement passer en revue les différents paquets via l’interface web http://software.opensuse.org/ et télécharger les derniers paquets. Les interfaces ouvertes permettent aux services externes (par ex: SourceForge) et aux pages web d’interagir avec le Build Service et d’utiliser ses ressources…..)

Posted in 2010, command line interface, Développement logiciel, Distribution de logiciel, logiciel libre, openSUSE build service, packaging, python | Tagué: , , , , , , | Leave a Comment »