Skip to content

Python 3 compatibility #200

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

Closed
wants to merge 10 commits into from
Closed

Conversation

takluyver
Copy link
Contributor

No doubt there are ways this could be improved, but this gets it installing, importing, and almost passing the test suite.

There's one test failure left, and I think that's something odd with numpy, specifically the ndarray.searchsorted() method. It returns seemingly random results when it's called in panel.get_axis_dummies() - but I can't replicate those results calling searchsorted on identical arrays interactively.

It doesn't add any failures to the Python 2 test suite (one test is failing for me in master), but I've only checked this with Python 2.7.

@wesm
Copy link
Member

wesm commented Oct 8, 2011

This is really great-- thanks for doing this. It's also impetus for me to get Python3+NumPy+SciPy installed on my machine for testing purposes. I will do that, run the test suiteu, and merge this in as soon as I can.

@takluyver
Copy link
Contributor Author

You're welcome!

wesm added a commit that referenced this pull request Oct 9, 2011
* py3-compat-merge:
  All but one test now passing on Python 3.
  Sort out division for in sparse code.
  Use .iterkv() instead of .iteritems(), which gets incorrectly converted to .items() by 2to3.
  Hack so test works on Python 3.
  More changes to support Python 3 better.
  Fix up more tests for Python 3.
  Fixes so more tests pass on Python 3.
  Pandas can now be imported successfully in Python 3.
  Pandas installs on Python 3
@wesm
Copy link
Member

wesm commented Oct 9, 2011

Rebased this and merged it in. There are some test failures in what appear to be corner cases in NumPy trunk, I will have to investigate those some other time

@wesm wesm closed this Oct 9, 2011
@takluyver
Copy link
Contributor Author

Thanks Wes. For the record, I was testing with Numpy 1.6.1.

@wesm
Copy link
Member

wesm commented Oct 9, 2011

Thomas, can you help me figure out why the cython command stopped working once setuptools is introduced (for the purpose of running 2to3)? I'm talking about:

python setup.py cython

@wesm
Copy link
Member

wesm commented Oct 9, 2011

in the meantime, I kludged things so setuptools only gets imported in py3k, so no urgency

wesm@5a33038

@takluyver
Copy link
Contributor Author

I'll have a look - I'd just been doing python setup.py install.

@takluyver
Copy link
Contributor Author

It appears to work for me with setuptools 0.6 from Ubuntu repos, or with distribute 0.6.19 as installed by virtualenv.

abc
running cython
cythoning pandas/src/tseries.pyx to pandas/src/tseries.c
cythoning pandas/src/sparse.pyx to pandas/src/sparse.c

(the abc is from a print statement I added just below the setuptools import)

@wesm
Copy link
Member

wesm commented Oct 9, 2011

that's prior to my kludge, right? i was running it on win32 to see if I can distribute 3.x binaries for the imminent next release. sigh, windows, the source of so much dev unhappiness

@wesm
Copy link
Member

wesm commented Oct 9, 2011

Here's another not so awesome thing: on 3.1/3.2 on Win32 (haven't tested Win64 yet), the default csv writer writes not 1, but 2 line breaks per line. Specifying explicitly lineterminator='\n' for now which solves the problem (I think csv.reader interprets CRLF as \n\n which seems really bad)

@takluyver
Copy link
Contributor Author

I tweaked your kludge so it imported setuptools on both platforms (the abc is to check that it's getting imported).

With Windows, I think it writes \r\n by default. Unix-y programs might interpret that as two line breaks, but it's the platform default for Windows. Explicitly specifying the lineseparator is probably sensible.

I don't have Windows to hand, but I can test in Wine if you like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants