I'm on windowsXP, so it might not be exactly the same as on Vista
You can copy the content of the command window, by right clicking
on the header of the command window frame.
go to edit, select all, and then again with copy
(there are also shortcuts for fast edit)
> C:\Python26\Lib\site-packages\Cython\distutils>python setup.py
> build_ext --inplace
> running build_ext
> building 'helloworld' extension
> error: None
>
> C:\Python26\Lib\site-packages\Cython\distutils>
You shouldn't run your own scripts from any package directory.
It is possible that distutils gets confused by the local files.
Create a new folder outside of C:\Python26, preferably without space
in the folder path/name and move your .pyx and setup.py file there,
and try
setup.py build_ext --inplace
If it's successfull, you should see a call to gcc on the command
line. dll files in python have the extension .pyd
If it doesn't work automatically you could try to call cython directly.
>python C:\Python26\Scripts\cython.py -v helloworld.pyx
(I'm not using the latest cython, so there might be small differences)
Hope that helps,
Josef
Yes, you can... Just learn how, or use something no SO annoying as the
command windows, for example: http://sourceforge.net/projects/console/
>
> C:\Python26\Lib\site-packages\Cython\distutils>python setup.py
> build_ext --inplace
> running build_ext
> building 'helloworld' extension
> error: None
>
MinGW is not the default compiler, nor distutils try to employ it if
you have it installed... you have to additionally use the option
"--compiler=mingw32" when running "python setup.py ..."
In previous posts, I've explained how to configure distutils to use
MinGW by default. Note however that for this to work it may be
required to use cython-devel, as I've pushed some patches to make
'pyximport' work out of the box with MinGW.
>
> C:\Python26\Lib\site-packages\Cython\distutils>
>
Again, as Josef said, you do not have to run setup.py scripts inside
the install directories...
>
> I've just realised that "error: None" is probably an error (I thought
> it meant there were no errors).
>
No, it is actually and error (means that the MSVC compiler was not
found), but distutils does not properly report it.
--
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
C:\MyPy>python setup.py build_ext --inplace --compiler=mingw32
[...lots of output...]
C:\MyPy>python -c "import helloworld"
Hello, World!
BTW, make sure you have your %PATH% properly setup...
--
try:
C:\MyPy python setup.py .....
You may not have Windows set up to know that *.py is an executable -- so
you need to run python with the setup.py as your argument.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
OK, Then I'll give you a clue... When I wrote these two files, I've
actually first copy&paste from your email... Then when trying to run
setup.py, I got a failure... The problem what the quotes you used for
the 'build_ext' key in the cmdclass argument to setup() ... You have
to use single quotes like this: 'build_ext' or double quotes like
this: "build_ext" , but NOT like this ´build_ext´ (hope you can see
the difference in your mail reader)
Mmm.. I've did all my testing with cython-devel... Could you give a
try? You do not need to intall Mercurial (or TortoiseHG), just point
your browser to this link http://hg.cython.org/cython/archive/tip.zip
to que a zip file you can unpack and install.
The only place I have compiler=mingw32 specified is in
Python25\Lib\distutils\distutils.cfg
I needed to add
[build_ext]
compiler=mingw32
to distutils.cfg, because the [build] option was not used for build_ext
and I got initially a Visual Studio not found error.
After that, the helloworld compiles and runs without problems.
A numpy example ends with a compiler error, I think, because it
doesn't find the numpy header files (numpy core include).
How do I tell pyximport where the numpy files are?
Thanks,
Josef
Enter python, import numpy, print numpy.get_include(), and then add
that path under the [build_ext] section in distutils.cfg, like this:
[build_ext]
include_dirs= <NUMPY INCLUDE DIR>
compiler=mingw32
In short, if you run this:
$ python setup.py <command> --help
for each --<option-name> listed you can add a section with config
values in distutils.cfg, more or less like this:
[<command>]
options_name = value1 value2 value3
So you can add macros, library dirs, libraries, etc... Do you get the idea?
Some day I'll review these pyximport patches in the tracker... Passing
include dirs, and macros, and libraries, and any other stuff required
for building should have been a pyximport feature from the very
beginning...
With this it works without problems, additionally build_dir can
be set as an option to pyximport.install.
So my basic pyximport usage works well
(and I can drop my hardcoded hacks)
>
> In short, if you run this:
>
> $ python setup.py <command> --help
>
> for each --<option-name> listed you can add a section with config
> values in distutils.cfg, more or less like this:
>
> [<command>]
> options_name = value1 value2 value3
>
> So you can add macros, library dirs, libraries, etc... Do you get the idea?
Yes, I will keep this in mind for next time, when I try to work around
some build problems.
Thanks,
Josef
Sorry, at this point I'm confused...
1) Are you using latest Cython 0.11.3, right? If you have a previous
version, things will not work.
2) Open the file
C:\Python26\Lib\site-packages\Cython\distutils\distutils.cfg and make
sure it has at least these two lines:
[build_ext]
compiler = mingw32
3) Do you have C:\MinGW\bin (depending where you installed MinGW)
listed in your %PATH% environment variable? If not distutils will not
be able to invoke 'gcc.exe' to compile stuff... But I bet this
Ah!! Now I see in your original post that you are using Cython
0.11.2... You really need 0.11.3 for (2) to work... Please, trust
me... you do not need a binary installer... So please do this:
1) Go to add/remove programs in control panel and remove your Cython
installation.
2) Download Cython-0.11.3 release,
http://www.cython.org/release/Cython-0.11.3.zip
3) Unpack the zip file and enter the Cython-0.11.3 directory in a
console windows
4) run this command:
python setup.py build -c mingw32 bdist_msi
Now you should have a shinny new MSI binary installed inside the
"dist\" folder... So you can see that creating a Python binary
installer is not black magic (at least on the user side), right?
These are general questions for installing a python package and
not cython specific.
python setup.py build -c mingw32 bdist_msi
only creates the installer but does not actually install the package
nor add it to the python path. The messages at the end just indicate
the paths in the build and installer not in your python site packages.
The build creates a dist folder which should contain the installer
that you can use to install the package into python's site-packages.
As an alternative, for the installation of packages, I also use
python setup.py install
or I use
easy_install -U zipfileofpackage
It is also possible to add a package to the python path without
installing in site-packages, but I think that's only relevant if you
want to edit the package.
(I'm not sure about the details of an msi installer, since I usually
install from a zipfile created with bdist)
Hope that helps,
Josef
OK.
> Thanks again for all the help, and you are right,
> Lisandro, it isn't black magic (to the user) although I was having
> some doubts for a while.
Please, do not read me wrong... I was just trying to point that
getting a binary installer is REALLY easy... Of course, you have to
know how to do it ;-).
+1
This would be great if you can find the time.