Skip to content

Circle pyenv #204

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

Merged
merged 32 commits into from
Mar 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
dacf4c3
Use `pyenv global` to set version.
theengineear Mar 13, 2015
f8af6da
explicitly use current python to show version
theengineear Mar 13, 2015
4c45757
attempt to set pyenv locally as well…
theengineear Mar 13, 2015
4abfbe3
attempt to use pyenv shell to set version.
theengineear Mar 13, 2015
af527ab
ok, all levels of pyenv are now set…
theengineear Mar 13, 2015
382cf6c
Revert "ok, all levels of pyenv are now set…"
theengineear Mar 13, 2015
4d22b0f
Revert "attempt to use pyenv shell to set version."
theengineear Mar 13, 2015
087ee62
Revert "attempt to set pyenv locally as well…"
theengineear Mar 13, 2015
f25a603
Revert "Use `pyenv global` to set version."
theengineear Mar 13, 2015
ed6860b
serve up some additional info in circle
theengineear Mar 13, 2015
8bba7d3
Ensure that shims for PYENV are first in path!
theengineear Mar 13, 2015
cf8048a
No need to set PYENV_VERSION for `system`.
theengineear Mar 13, 2015
7c3bac6
just override dependencies, don’t bother with pre
theengineear Mar 13, 2015
26b1b51
fix skipIf python 2.6 test failure.
theengineear Mar 13, 2015
64b8abb
Introduce more flexible strict JSON implementation
theengineear Mar 13, 2015
a912e2a
safely import simplejson for python 2.6
theengineear Mar 13, 2015
785c723
Try to cache all the hard work done in deps.
theengineear Mar 13, 2015
a7aa45f
Fix Python 3 attribute error in test.
theengineear Mar 13, 2015
42a7dd8
print(x) vs print x fix for python 3.
theengineear Mar 13, 2015
68999fe
Removed confusing (unnecessary?) test assertion.
theengineear Mar 13, 2015
0f2777b
`0` prefix not allowed in python 3 apparently.
theengineear Mar 13, 2015
8734384
floats serialize to a different precision in py3
theengineear Mar 13, 2015
dee8d27
number of significant digits seems to have changed
theengineear Mar 13, 2015
2b73659
compare python obj, not serialization.
theengineear Mar 13, 2015
7345c14
protect skip import
theengineear Mar 13, 2015
37ac31a
protect widgets import in test (python 2.6)
theengineear Mar 13, 2015
4792e62
assertListEqual DNE in python 2.6 TestCase
theengineear Mar 13, 2015
f020ae9
no set literals : (
theengineear Mar 13, 2015
3e39f32
assertIs DNE in python 2.6 TestCase
theengineear Mar 13, 2015
59b0082
Add note about adding pyenv shims to path
theengineear Mar 13, 2015
2a9d2d3
printout of sys.version_info —> sys.version
theengineear Mar 13, 2015
bf8591d
version bump —> 1.6.12 (strict json fix + ci fix)
theengineear Mar 13, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ machine:
PLOTLY_OPTIONAL_REQUIREMENTS_FILE: ${PLOTLY_PACKAGE_ROOT}/optional-requirements.txt
PLOTLY_OPTIONAL_REQUIREMENTS_FILE_2_6: ${PLOTLY_PACKAGE_ROOT}/optional-requirements-2-6.txt
dependencies:
pre:
override:

# run all the pre-written installers (this will take a *while*)
- bash circle/setup.sh

# install testing tools for circle's version of things
- PYENV_VERSION=2.7 && pip install nose coverage
override:
- PYENV_VERSION=2.7 && pip install -I .
- PYENV_VERSION=2.7 && cd ~ && python -c "import plotly"
- pip install nose coverage
- pip install -I .

# we need to cd out of the project root to ensure the install worked
- cd ~ && python -c "import plotly"

cache_directories:
- "~/.pyenv/versions" # attempt to just cache installed pyenv things
test:
override:

Expand All @@ -28,6 +34,6 @@ test:
# - sudo chmod 600 ${PLOTLY_CONFIG_DIR} && python -c "import plotly"

# test core things in the general 2.7 version that circle has
- PYENV_VERSION=2.7 && nosetests -xv plotly/tests --with-coverage --cover-package=plotly
- nosetests -xv plotly/tests --with-coverage --cover-package=plotly
- mkdir "${CIRCLE_ARTIFACTS}/2.7" || true
- coverage html -d "${CIRCLE_ARTIFACTS}/2.7" --title=2.7
9 changes: 9 additions & 0 deletions circle/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ function error_exit
exit 1
}

# PYENV shims need to be infront of the rest of the path to work!
echo "adding pyenv shims to the beginning of the path in this shell"
export PATH="/home/ubuntu/.pyenv/shims:$PATH"

# for each version we want, setup a functional virtual environment
for version in ${PLOTLY_PYTHON_VERSIONS[@]}; do
echo Setting up Python ${version}
Expand All @@ -20,6 +24,11 @@ for version in ${PLOTLY_PYTHON_VERSIONS[@]}; do
export PYENV_VERSION=${version}
echo "Using pyenv version $(pyenv version)"

# this was a major issue previously, sanity check that we're using the
# version we *think* we're using (that pyenv is pointing to)
echo "python -c 'import sys; print(sys.version)'"
python -c 'import sys; print(sys.version)'

# install core requirements all versions need
pip install -r ${PLOTLY_CORE_REQUIREMENTS_FILE} ||
error_exit "${LINENO}: can't install core reqs for Python ${version}"
Expand Down
10 changes: 10 additions & 0 deletions circle/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ function error_exit
exit 1
}

# PYENV shims need to be infront of the rest of the path to work!
echo "adding pyenv shims to the beginning of the path in this shell"
export PATH="/home/ubuntu/.pyenv/shims:$PATH"

# for each version we want, setup a functional virtual environment
for version in ${PLOTLY_PYTHON_VERSIONS[@]}; do
echo Testing Python ${version}
Expand All @@ -20,6 +24,12 @@ for version in ${PLOTLY_PYTHON_VERSIONS[@]}; do
export PYENV_VERSION=${version}
echo "Using pyenv version $(pyenv version)"

# this was a major issue previously, sanity check that we're using the
# version we *think* we're using (that pyenv is pointing to)
echo "python -c 'import sys; print(sys.version)'"
python -c 'import sys; print(sys.version)'


echo "install plotly (ignoring possibly cached versions)"
pip install -I ${PLOTLY_PACKAGE_ROOT} ||
error_exit "${LINENO}: can't install plotly package from project root"
Expand Down
12 changes: 10 additions & 2 deletions plotly/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@


"""
import json
import sys
import six

if sys.version[:3] == '2.6':
import simplejson as json
else:
import json

## Base Plotly Error ##

class PlotlyError(Exception):
Expand Down Expand Up @@ -49,7 +54,10 @@ def __init__(self, requests_exception):
elif content_type == 'text/plain':
self.message = requests_exception.response.content
else:
self.message = requests_exception.message
try:
self.message = requests_exception.message
except AttributeError:
self.message = 'unknown error'

def __str__(self):
return self.message
Expand Down
8 changes: 6 additions & 2 deletions plotly/grid_objs/grid_objs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
"""
from __future__ import absolute_import


import json
import sys
from collections import MutableSequence
from plotly import exceptions
from plotly import utils

if sys.version[:3] == '2.6':
import simplejson as json
else:
import json

__all__ = None


Expand Down
6 changes: 5 additions & 1 deletion plotly/plotly/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from __future__ import absolute_import

import sys
import json
import warnings
import copy
import os
Expand All @@ -30,6 +29,11 @@
else:
from urllib.parse import urlparse

if sys.version[:3] == '2.6':
import simplejson as json
else:
import json

from plotly.plotly import chunked_requests
from plotly import utils
from plotly import tools
Expand Down
28 changes: 17 additions & 11 deletions plotly/tests/test_core/test_get_figure/test_get_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from plotly import exceptions
from nose.tools import raises
import six
import json

from unittest import TestCase
from unittest import skipIf

version = six.sys.version_info[:2] # need this for conditional testing


# username for tests: 'plotlyimagetest'
Expand Down Expand Up @@ -198,12 +198,18 @@ def test_all():

class TestBytesVStrings(TestCase):

@skipIf(not six.PY3, 'Decoding and missing escapes is only seen in PY3')
def test_proper_escaping(self):
un = 'PlotlyImageTest'
ak = '786r5mecv0'
url = "https://plot.ly/~PlotlyImageTest/91/"
py.sign_in(un, ak)
print("getting: https://plot.ly/~PlotlyImageTest/91/")
print("###########################################\n\n")
fig = py.get_figure(url)
# unittest `skipIf` not supported in 2.6
if version < (2, 7) or (2, 7) < version < (3, 3):
pass
else:
from unittest import skipIf

@skipIf(not six.PY3, 'Decoding and missing escapes only seen in PY3')
def test_proper_escaping(self):
un = 'PlotlyImageTest'
ak = '786r5mecv0'
url = "https://plot.ly/~PlotlyImageTest/91/"
py.sign_in(un, ak)
print("getting: https://plot.ly/~PlotlyImageTest/91/")
print("###########################################\n\n")
fig = py.get_figure(url)
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@

import requests
import copy
import json
import six
import sys

if sys.version[:3] == '2.6':
import simplejson as json
else:
import json

default_headers = {'plotly-username': '',
'plotly-apikey': '',
Expand Down
7 changes: 6 additions & 1 deletion plotly/tests/test_core/test_utils/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import json
import sys
from unittest import TestCase

from plotly.utils import PlotlyJSONEncoder

if sys.version[:3] == '2.6':
import simplejson as json
else:
import json


class TestJSONEncoder(TestCase):

Expand Down
3 changes: 2 additions & 1 deletion plotly/tests/test_optional/test_ipython/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import threading
import six
import unittest
from unittest import skip
version = six.sys.version_info[:2] # need this for conditional testing

# unittest `skipIf` not supported in 2.6 and IPython not supported in 2.6/3.2
if version < (2, 7) or (2, 7) < version < (3, 3):
pass
else:
from unittest import skip

@skip
class TestPlotlyDisplay(unittest.TestCase):

Expand Down
15 changes: 11 additions & 4 deletions plotly/tests/test_optional/test_ipython/test_widgets.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import six
from unittest import TestCase

from plotly.widgets import GraphWidget
version = six.sys.version_info[:2] # need this for conditional testing

# unittest `skip` not supported in 2.6 and IPython not supported in 2.6/3.2
if version < (2, 7) or (2, 7) < version < (3, 3):
pass
else:
from plotly.widgets import GraphWidget

class TestWidgets(TestCase):

def test_instantiate_graph_widget(self):
widget = GraphWidget
class TestWidgets(TestCase):

def test_instantiate_graph_widget(self):
widget = GraphWidget
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ def test_pandas_time_series_date_formatter(self):

x0 = fig.axes[0].lines[0].get_xydata()[0][0]
self.assertEqual(x0, expected_x0)
self.assertListEqual(pfig['data'][0]['x'], expected_x)
self.assertEqual(pfig['data'][0]['x'], expected_x)
17 changes: 9 additions & 8 deletions plotly/tests/test_optional/test_utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import numpy as np
import json
import pandas as pd
import sys
from pandas.util.testing import assert_series_equal
import matplotlib.pyplot as plt

Expand All @@ -27,7 +28,7 @@ def test_encode_as_plotly(self):

# should *fail* when object doesn't have `to_plotly_json` attribute
objs_without_attr = [
1, 'one', {'a', 'set'}, {'a': 'dict'}, ['a', 'list']
1, 'one', set(['a', 'set']), {'a': 'dict'}, ['a', 'list']
]
for obj in objs_without_attr:
self.assertRaises(utils.NotEncodable,
Expand All @@ -48,7 +49,7 @@ def test_encode_as_list(self):

# should *fail* when object doesn't have `tolist` method
objs_without_attr = [
1, 'one', {'a', 'set'}, {'a': 'dict'}, ['a', 'list']
1, 'one', set(['a', 'set']), {'a': 'dict'}, ['a', 'list']
]
for obj in objs_without_attr:
self.assertRaises(utils.NotEncodable,
Expand All @@ -75,7 +76,7 @@ def test_encode_as_pandas(self):

# should succeed when we've got specific pandas thingies
res = utils.PlotlyJSONEncoder.encode_as_pandas(pd.NaT)
self.assertIs(res, None)
self.assertTrue(res is None)

def test_encode_as_numpy(self):

Expand Down Expand Up @@ -132,7 +133,7 @@ def test_encode_as_date(self):
utils.PlotlyJSONEncoder.encode_as_date, obj)

# should work with a date
a_date = datetime.date(2013, 10, 01)
a_date = datetime.date(2013, 10, 1)
res = utils.PlotlyJSONEncoder.encode_as_date(a_date)
self.assertEqual(res, '2013-10-01')

Expand Down Expand Up @@ -248,9 +249,8 @@ def test_pandas_json_encoding():
def test_numpy_masked_json_encoding():
l = [1, 2, np.ma.core.masked]
j1 = json.dumps(l, cls=utils.PlotlyJSONEncoder)
print j1
print(j1)
assert(j1 == '[1, 2, null]')
assert(set(l) == set([1, 2, np.ma.core.masked]))


def test_masked_constants_example():
Expand All @@ -275,8 +275,9 @@ def test_masked_constants_example():

jy = json.dumps(renderer.plotly_fig['data'][1]['y'],
cls=utils.PlotlyJSONEncoder)
assert(jy == '[-398.11793026999999, -398.11792966000002, '
'-398.11786308000001, null]')
print(jy)
array = json.loads(jy)
assert(array == [-398.11793027, -398.11792966, -398.11786308, None])


def test_numpy_dates():
Expand Down
Loading