Pregunta

Estoy empezando un proyecto pitón de tamaño pequeño / medio, probablemente en Test Driven Development. Mis fondos están más en C y Java que pitón (utilicé hormiga y makefile)

Yo sé que en Python puede que no necesite una herramienta de construcción, pero lo haré, porque voy a utilizar Cython y PyInstaller (la cosa debería trabajar en un par de diferentes UNIXes, sin depender directamente de pitón) y me al igual que la conveniencia de la selección de las pruebas de forma CLI, la construcción de los documentos, tal vez comprobar las dependencias, etc.

Alguien se queja de que el pitón carece de una herramienta de maquillaje similares. Sé que existen pocas herramientas, como scon y pavimentadora , pero me gustaría saber de los usuarios reales y no sólo su página web. Cómo usa nadie pavimentadora ?

¿Qué es acerca de la setup.py habitual que viene con muchos paquetes? Miré en unos cuantos para ver si hay un uso común, pero no he encontrado nada interesante (tal vez utilicé los ejemplos incorrectos)

¿Usted recomienda quedarse con las cosas que ya conozco (hormigas y Makefile) al menos para empezar? Si es así, ¿hay alguna extensión hormiga recomiendas para Python (+ Cython + + PyInstaller PyUnit)?


EDIT: para evitar más respuestas como uno de PTC, cabe destacar que, para este proyecto, que tienen una necesidad imperiosa de mi programa de ser un ejecutable independiente porque es absolutamente imposible para tener una pitón máquina virtual en la plataforma de destino donde el ejecutable se ejecutará. Tengo exactamente el mismo HW disponible para la compilación, por lo que afortunadamente no necesito a una compilación cruzada (pero me gustaría hacer el desarrollo en un sistema Linux más amigable).

También me gustaría probar si mi código compila en Cython desde el principio, no a optimizar el prematuro, pero sólo para estar seguro de que no voy demasiado lejos con el uso de características incompatibles, lo que requeriría una dolorosa refactorización si se vería seriamente necesita Cython.

Así que por favor centrarse en mi pregunta real

¿Fue útil?

Solución

Sus requisitos sugieren más bien Scons que, según su página web, tiene más control sobre gran variedad de tareas de construcción pavimentadora . En este último acabaría utilizando una gran cantidad de sh() que se extiende a los programas de línea de comandos regular.

Recientemente, he empezado a utilizar pavimentadora que es realmente grande para ejecutar las pruebas, construir documentaciones Sphinx , pero yo uso solamente Python puro. Si quieres ver lo que es posible con la pavimentadora le recomiendo estos 2 artículos: convertir-de-make-to-extendedora y de escritura-técnico- documentación por Doug Hellmann y que debe de comprobar su pavement.py archivo de configuración .

Otros consejos

If it is at all possible, I'd suggest avoiding extension modules(C/cython) in the beginning. Get your all code written in Python, use a simple distutils based configuration, run your tests using -m (python -m mypkg.test.testall, or whatever; import unittest).

Once you get your project to a comfy state, then start tackling some optimizations with cython and the extra project management that comes with that. distutils can build extension modules, so I'm not sure you'll need make/scons..

 project-dir/
  setup.py
  mypkg/
   __init__.py
   mymod.py
   test/
    __init__.py
    testall.py
    testsomething_specific.py

I've been using setuptools for this, sometimes in combination with Ant for more complex stuff, or for integrating with other builds. In general it has worked well for me, but I've heard some people at #python (freenode) complain about a generally low source quality for this package, and recommending the standard distutils.

One thing to really watch out with if you are used to Java (like me), is that python does not support split packages. That is, you cannot put site.db in src/site/db, site.view in src2/site/view, put src and src2 on PYTHONPATH and the expect everything to work. This caused major headaches for me with the build tools, it worked a bit sporadically :)

One tool I love is virtualenv: http://pypi.python.org/pypi/virtualenv

from the site: What It Does virtualenv is a tool to create isolated Python environments. The basic problem being addressed is one of dependencies and versions, and indirectly permissions. Imagine you have an application that needs version 1 of LibFoo, but another application requires version 2. How can you use both these applications? If you install everything into /usr/lib/python2.4/site-packages (or whatever your platform's standard location is), it's easy to end up in a situation where you unintentionally upgrade an application that shouldn't be upgraded.

You can also try: http://pypi.python.org/pypi/zc.buildout

from the site: The Buildout project provides support for creating applications, especially Python applications. It provides tools for assembling applications from multiple parts, Python or otherwise. An application may actually contain multiple programs, processes, and configuration settings.

Tried it a couple of times, excellent for deploying development envrionments, maybe it's too much for your needs.

I've also been told and read in a couple of places that nose is a very cool testing tool http://somethingaboutorange.com/mrl/projects/nose/0.11.1/, I'm looking for some free time to try it.

Hope It helps Cheers, Ale

to avoid further answers like jwp's one, note that, for this project, I absolutely need my program being a standalone executable because it is absolutely impossible to have a python VM on the target platform where the executable will run. I have exactly the same hw available for compiling, so luckly I don't need to cross-compile (but I'd do the development on a more friendly Linux).

I'd also like to test if my code compile in Cython from the beginning, not to premature optimize, but just to be sure that I'm not going too far with the use of incompatible features, which would require a painful refactoring if Cython would be seriously needed.

If all you're looking for is to have a stand-alone executable, you don't need to run Cython. There are a few good libraries for doing this:

However, to run Python code, you're simply going to have to install an interpreter or virtual machine on the target machine in some form or fashion. The solutions I presented involve merely embedding the interpreter to make it easier to install. In fact, I'm pretty sure (but could be wrong) that Cython won't allow you to build a stand-alone executables. It's mainly meant for creating extensions to the Python interpreter.

However, there are a couple of other alternatives. If you have a Java interpreter on the target machine, you can run Jython. There's also a IronPython for .net. However, you will still have to distribute the runtimes for these languages with your project.

In short, if you want a stand-alone executable with no dependencies, your only option is pretty much to go with straight C or C++.

If you are looking for a simple python based build tool. Check out pynt. Tasks in pynt are just (decorated) python function. It also support Rake style parameter passing to tasks.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top