Skip to content
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

Automatically run 2to3 when installing on Python 3 #3

Merged
merged 9 commits into from Apr 19, 2013
Merged

Automatically run 2to3 when installing on Python 3 #3

merged 9 commits into from Apr 19, 2013

Conversation

dan-blanchard
Copy link
Contributor

I added a couple lines to setup.py to make 2to3 get run automatically by Distribute on Python 3 because we were running into some issues installing this on 3.3. I just followed the recommended steps here.

@benhamner
Copy link
Owner

Looking at the Travis build, this prevented pandas from being installed -

https://travis-ci.org/benhamner/Metrics/builds/5992585

ERROR: test.test_auc (unittest.loader.ModuleImportFailure)

ImportError: Failed to import test module: test.test_auc
Traceback (most recent call last):
File "/usr/lib/python2.7/unittest/loader.py", line 252, in _find_tests
module = self._get_module_from_name(name)
File "/usr/lib/python2.7/unittest/loader.py", line 230, in _get_module_from_name
import(name)
File "/home/travis/build/benhamner/Metrics/Python/ml_metrics/test/test_auc.py", line 4, in
import ml_metrics as metrics
File "ml_metrics/init.py", line 1, in
from quadratic_weighted_kappa import *
File "ml_metrics/quadratic_weighted_kappa.py", line 4, in
import pandas as pd
ImportError: No module named pandas

Can you fix it?

@dan-blanchard
Copy link
Contributor Author

I think this may be a misconfiguration of Travis, rather than an issue of my changes breaking something, because I noticed that the build details say that it can't find requirements.txt, which is what tells it to install pandas in the first place.

It might be necessary to change

requirements = [x.strip() for x in open("requirements.txt")]

to

requirements = [x.strip() for x in open(os.path.join(os.path.dirname(__file__), "requirements.txt"))]

so that it looks for requirements.txt in the right place, but this shouldn't have changed from what I did.

I'll make the change on my end and see if your automatic travis build passes then.

@dan-blanchard
Copy link
Contributor Author

Well, that doesn't appear to have cut it. I think it's something you have to change with the Travis config, because of the error message "Could not locate requirements.txt. Override the install: key in your .travis.yml to install dependencies."

This should fix things for installing python dependencies.
Seems like what I added previously was unnecessary, so I reverted that. I also changed this so it wasn't hard-coded for python 2.7.
I believe the way things were setup before my deactivating and re-activating the virtual environment lead to it using Python 2.7 even when it said it was going to use Python 3.3. For now, I can't come up with a good way to test on Python 3 without recompiling numpy each time, which is insanely time consuming.
@dan-blanchard
Copy link
Contributor Author

Alright, after a lot of messing around with it, I believe I've fixed the YAML file. Annoyingly, there doesn't seem to be a simple way to get numpy working with Python 3.3 on Travis, so I gave up on getting this testing working for 3.3. It just tests 2.7, but the tests all pass now.

@dan-blanchard
Copy link
Contributor Author

I hate to be a pest, but this PR should be good to go now, and I'd really like to not have to install this using a custom git repository URL, so could you please pull this?

@benhamner
Copy link
Owner

Thanks for the reminder, merged!

benhamner added a commit that referenced this pull request Apr 19, 2013
Automatically run 2to3 when installing on Python 3
@benhamner benhamner merged commit fb86a99 into benhamner:master Apr 19, 2013
@dan-blanchard
Copy link
Contributor Author

Could you please update the version of ml_metrics that is on pypi to include these fixes? You may have to bump the version number up to get it to recognize the changes. Currently when I try to install via pip with python 3 it does not actually run 2to3 automatically like it's supposed to.

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.

None yet

2 participants