New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cython extensions built twice? #204
Comments
This is due to our conditional checks for the C compiler. If has_c_compiler is True, then we call cython no matter what the command given to distutils is. We could have a check to see if the C file is stale and then build it if "build" is in sys.argv, but I'd rather get rid of this check entirely and fix this in a sane way for 0.5.0 |
Yet another problem with the conditional Cython hacks. It doesn't look like we ever get the Cython version of things in Python 3 at least on Linux. At least with newest Cython versions. The try_compile line returns
I still want to get rid of all this cruft and just require a compiler. That way we can also close #266, which has been hanging around a bit long for a useful contribution. |
which cython version? TravisCI looks like it's doing fine with cython. I still don't really like it because it make testing and switching branches and python versions more complicated for me. And I'm still the main test runner. |
There's no error because it's in a try/except loop. It just won't build Cython extension. It doesn't change anything for you AFAICT. You just need to do the same stuff within a SDK CMD shell. Or you can modify the build scripts I've committed. |
The difference is that currently I'm not compiling at all when I just want to quickly switch versions or branches. I will look into it. |
If you don't touch the pyx files, then you don't have to worry about it. Though I'm not certain, you'll likely have to recompile or keep different folders for Python 3 if you don't want to, though it doesn't add more than a few seconds to the build as of now. |
actually, python 3 got smarter they keep the byte code files version specific in parallel. (But I'm keeping python 3 versions in separate directories Right now I'm running python 2.7 with compiled extensions, and python 2.6 with pure python, and sometimes python 2.5 with pure python. But your right, switching branches with the same python doesn't need recompile, if I don't touch the extensions. |
@jseabold is this still an issue with latest numpy/cython? Do you happen to use Macports? |
Similar issue: luispedro/mahotas#25 |
Yes this is still an issue, but I think it's avoidable when we remove the hacked compiler checks IIRC. I see it on Linux when doing the compiler check under 64-bit on Python 3.2. (To reproduce, you actually need to remove the try/except block that's swallowing the error). I do not know what's causing it yet. Was planning to dig into this if necessary when we can finally merge #266 and require a compiler to build. |
On OSX it's a problem with setuptools dist.py (in handle_display_option). For some reason, this fails on OSX with py3.2:
|
Same for the mahotas issue, but then with |
Yes, it looks like Python 3.x bug. It's the complex bug: after As a draft workaround you can add this to setuptools/dist.py (line 660):
|
It seems my setuptools is different than yours. Can you give some context for your suggested workaround? |
This was reported before, but apparently core devs don't approve of using It's recommended in the Python docs though: http://docs.python.org/3.2/library/sys.html |
|
I have problems following here. We have statsmodels running on python 3.2 for a long time. I just checked again and it build from an sdist including compiling extensions with mingw32 on python 3.2.3 without problems. I'm using numpy 1.6.2 to install and cython 0.15.1 on py2.6 to build the sdist. Did building extensions for python 3.2 never work for Mac and Linux, or are there new problems with versions of packages newer than what I use? |
What is the expected output of this code?
On Ubuntu with Python 3.2 and on Mac with Macports Python 3.1, 3.2 and 3.3 I see the
Is that OK or a bug? For reference: mahotas and scikit-image can't be installed with Macports Python 3.2 because of this issue: Since several scientific python packages are affected, maybe the discussion on this issue should be continued somewhere more central, e.g. the python or numpy tracker? |
I get the same ValueError on Windows with python 3.2.3. |
another question: what setuptools/dist.py are you talking about? I have setuptools in distribute for python 3.2 and 3.2.3 but the dist.py file in there doesn't define python\Lib\distutils.dist.py handle_display_options doesn't use stdout. Unless all this modules are platform specific. |
@cdeil it's a Python bug, following up on the Python bug tracker would be great. There's issues being opened all over the place because of this. |
Not a Python bug. See this comment. |
Like @josef-pkt in #204 (comment) I wonder what has changed in python or numpy or somewhere else so that these problems come up now several years after Python 3 came out. Does anyone know? |
This has the best explanation (change in distribute): pypa/virtualenv#359 |
I take back the Python bug comment, I misunderstood. (happens to me sometimes if there's no docstrings.......) |
I'm glad this has been cleared up, and it's not a problem in our code. Thanks for tracking this. |
do we need this? I didn't look at the details (yet) |
Testing against numpy master may show other failures, so better to first check that since this issue doesn't prevent building statsmodels. |
I've only followed this at a high level, but, IIUC, it will prevent building when we drop having duplicate python/cython code or merge in the cython code that doesn't have python back up (which I've wanted to do for 6 months now). |
Correct. If Cython becomes a build-time dependency, copy @y-p's workaround and live with a few failures I'd say. |
just cross-linking here (I haven't looked at any details) Instead of building cython twice (if this is really the case), there is also a possible problem to get cython build at various stages (possibly not at all) |
While it's always good practice to double check me, this is and has been really the case...you can check the code as well. There's no distinction between build and install because I don't check sys.argv (and don't want to because this will, in turn, be fragile). I still want to get rid of this. From our INSTALL.txt.
Current master. Clean checkout.
Build step output
Install step. Here we go again...
|
why do you do a separate build
In the past, I always got a separate, second build with other packages, unless I specified |
Because if you do a system-wide install with sudo, then you do not have permissions to remove the local build folder that is created in this step. With compiled extensions, you're "supposed" to do it in separate steps. It should at least not be broken to use this in the manner intended. You shouldn't get a separate second build. If that were the case, numpy, scipy, and pandas users would be screaming bloody murder. |
This really shouldn't be so contentious. What if I go the next mile and offer to make every effort to add nightly windows binaries to my cron jobs, so that you can just grab a nightly build if some compiled extension changes and then you never have to install the SDK and follow the same steps from instead its shell instead of the CMD prompt (or use the build scripts already provided)? |
It's contentious because it's a big jump. Anyone who wants to install (and work on) master will need a full developement environment, or mess around with an installed version (that's what I do when I want to change anything in scipy). Currently, it's possible to use the python version for development and a binary distribution (in Linux, Mac or Windows) for "production" and performance. Once a compiler is required, we have to deal with the compilation issues, instead of avoiding them. For my testing a binary distribution would be too complicated, since tox and pip cannot install them. However, since I had problems installing pandas on Windows 64 bit, I added a 32bit python 3.3 virtualenv for which I can compile with MingW. Given the number of request for Pandas nightly binaries on the pydata mailing list, I assume that we need to provide updated binaries also. Nightly sounds a bit too much for me, but weekly or even monthly would be necessary. What I would really like to know, is whether we actually have (m)any users/developers, besides me, that run the pure python version, because building the extensions (or creating the environment for it) is too much work. |
Maybe it was contentious a year ago when we discussed this, but now it shouldn't be I don't think. This was always the plan, but now I'm forcing the issue. Setting up a development environment on Windows really isn't that bad, and I'm glad to support windows (and have so far), but I don't think it should hold back development or dictate development policy. Dealing with compilation issues is fine. We haven't heard of many yet, and I haven't run into any other than maybe a stray "you need to upgrade Cython." It works now and has always worked on all platforms. There's not going to be much to do here for people, provided they read and follow the given instructions (which are much better than many packages provide IMO). At some point though users have to help themselves if they want to work with source. (See my recent two-day journey building OpenBlas/UMFPACK on the MLs). This is the price of being on the bleeding edge. People will help each other and figure things out. That said, part of my plan for 0.6 is to implement this #372. Then people will not need to build statsmodels at all to test add-on models. There are build scripts for every supported Python version 32-bit and 64-bit on windows. Surely there is a way to incorporate them into your testing process? https://github.com/statsmodels/statsmodels/tree/master/tools My worry is that we have many people inadvertently running the pure Python version because they didn't install Cython and then we get FUD numbers out there in blog posts doing comparisons for things like KDE and ARIMA. |
Or it might not happen, It took you two days on Linux Contributing to something where the bleeding edge makes you "bleed" might scare of some potential developers. statsmodels won't be so bad, since it's just cython and a c compiler, as long as we stay away from Fortran. (I haven't tried building pymc in a loong time.) Windows users are not "Hackers" that like to spend their time on building issues. (Spending 2 days on tox and pip a few weeks ago, scared me enough that I have done more manual testing and easy_installing in virtualenvs, then fighting with tools that are build for Linux or pure python packages.) My strong aversion is because I want to do statistics and econometrics instead of fighting with build issues. |
I understand the concern, and the want to focus on stats. But if you couldn't make an R package that contained Fortran or C, then R wouldn't be anywhere, because many estimators would be unusable. You don't see it because on Windows it just downloads the binaries, but if I |
It looks like the Cython extensions get built in both the build step and the install step. Need to look into this.
The text was updated successfully, but these errors were encountered: