blog.notmyidea.org/content/Technologie/ 2010-06-04-gsoc-distutils-first-report.md
2020-01-02 16:10:21 +01:00

73 lines
3.2 KiB
Markdown

# first week working on distutils2
As I've been working on [Distutils2](http://hg.python.org/distutils2/)
during the past week, taking part of the
[GSOC](http://code.google.com/intl/fr/soc/) program, here is a short
summary of what I've done so far.
As my courses are not over yet, I've not worked as much as I wanted, and
this will continues until the end of June. My main tasks are about
making installation and uninstallation commands, to have a simple way to
install distributions via
[Distutils2](http://hg.python.org/distutils2/).
To do this, we need to rely on informations provided by the Python
Package Index ([PyPI](http://pypi.python.org/)), and there is at least
two ways to retreive informations from here: XML-RPC and the "simple"
API.
So, I've been working on porting some
[Distribute](http://bitbucket.org/tarek/distribute/) related stuff to
[Distutils2](http://hg.python.org/distutils2/), cutting off all non
distutils' things, as we do not want to depend from Distribute's
internals. My main work has been about reading the whole code, writing
tests about this and making those tests possible.
In fact, there was a need of a pypi mocked server, and, after reading
and introducing myself to the distutils behaviors and code, I've taken
some time to improve the work [Konrad](http://bitbucket.org/konrad)
makes about this mock.
## A PyPI Server mock
The mock is embeded in a thread, to make it available during the tests,
in a non blocking way. We first used [WSGI](http://wsgi.org) and
[wsgiref](http://docs.python.org/library/wsgiref.html) in order control
what to serve, and to log the requests made to the server, but finally
realised that [wsgiref](http://docs.python.org/library/wsgiref.html) is
not python 2.4 compatible (and we *need* to be python 2.4 compatible in
Distutils2).
So, we switched to
[BaseHTTPServer](http://docs.python.org/library/basehttpserver.html) and
[SimpleHTTPServer](http://docs.python.org/library/simplehttpserver.html),
and updated our tests accordingly. It's been an opportunity to realize
that [WSGI](http://wsgi.org) has been a great step forward for making
HTTP servers, and expose a really simplest way to discuss with HTTP \!
You can find [the modifications I
made](http://bitbucket.org/ametaireau/distutils2/changesets), and the
[related
docs](http://bitbucket.org/ametaireau/distutils2/src/tip/docs/source/test_framework.rst)
about this on [my bitbucket distutils2
clone](http://bitbucket.org/ametaireau/distutils2/).
## The PyPI Simple API
So, back to the main problematic: make a python library to access and
request information stored on PyPI, via the simple API. As I said, I've
just grabbed the work made from
[Distribute](http://bitbucket.org/tarek/distribute/), and played a bit
with, in order to view what are the different use cases, and started to
write the related tests.
## The work to come
So, once all use cases covered with tests, I'll rewrite a bit the
grabbed code, and do some software design work (to not expose all things
as privates methods, have a clear API, and other things like this), then
update the tests accordingly and write a documentation to make this
clear.
Next step is to a little client, as I've [already started
here](http://github.com/ametaireau/pypiclient) I'll take you updated \!