You don't need this source code unless you want to modify the package. If you just want to use the Stripe Python bindings, you should run:
pip install --upgrade stripe
easy_install --upgrade stripe
See http://www.pip-installer.org/en/latest/index.html for instructions
on installing pip. If you are on a system with easy_install but not
pip, you can use easy_install instead. If you're not using virtualenv,
you may have to prefix those commands with
sudo. You can learn more
about virtualenv at http://www.virtualenv.org/
To install from source, run:
python setup.py install
Please see https://stripe.com/docs/api/python for the most up-to-date documentation.
There are a few ways to get some insight into what requests and responses the client is making and getting back from the Stripe API.
The python client can be told to emit either
debug will give more verbose information, and
info will be more compact, but omit things like request/response bodies.
You can enable logging in a few ways:
1. Set the environment variable
STRIPE_LOG to the value
debug or to
$ export STRIPE_LOG=debug
stripe.log = 'debug'
3. Set up python logging and set the logging level to the level you desire
If you are running code in production, it's preferable to set up python logging explicitly. This will give you control over filtering logs, and where the logs are output. Using the
stripe.log methods will always result in logs going to standard out, which you may or may not want.
Note that setting
stripe.log will supersede the setting of
STRIPE_LOG, but it can be turned off by setting it back to
import os import stripe print os.environ['STRIPE_LOG'] # => 'info' stripe.log = 'debug' # debug logs will also print now stripe.log = None # now only info logs will print
We commit to being compatible with Python 2.6+, Python 3.3+ and PyPy. We need to test against all of these environments to ensure compatibility. Travis CI will automatically run our tests on push. For local testing, we use tox to handle testing across environments.
Setting up tox
In theory, you should be able to
pip install tox and then simply run
tox from the project root. In reality, Tox can take a bit of finagling to get working.
You'll need an interpreter installed for each of the versions of python we test (see the envlist in tox.ini). You can find these releases on the Python site and at PyPy. If you're using OS X, it may be easier to get PyPy from Homebrew with
brew install pypy.
You may choose not to go through the hassle of installing interpreters for every Python version we support. It's useful to test at least one Python 2.x and one Python 3.x but can generally rely on Travis to find edge cases with other interpreters. You can test a specific interpreter such as Python 2.7 with
tox -e py27.
The system Python on OS X has been known to cause issues. You'll probably want to
brew install python or equivalent. If tox complains about
pkg_resources.DistributionNotFound then some of your Python libraries are probably still linked to the system python installation. To fix this for virtualenv you should
sudo pip uninstall virtualenv; pip install virtualenv.
Note that PyCurl doesn't currently play nicely with our tox configuration. Tox won't run any of the PyCurl related tests.
Running specific tests
You can specify a module, TestCase or single test to run by passing it as an argument to tox. For example, to run only the
test_save test of the
UpdateableAPIResourceTests case from the
test.resources module on Python 2.7:
tox -e py27 -- --test-suite stripe.test.resources.test_updateable.UpdateableAPIResourceTests.test_save
We enforce linting on the code with flake8. Install with
pip install flake8 and run with
flake8 stripe from the project root. Linting will also be run in Travis CI and for the Python 2.7 environment with Tox. Note that linting will fail on code that has undergone 2to3 conversion for Python 3 support.