|
1 | | -LaunchDarkly SDK for Python |
2 | | -=========================== |
| 1 | +# LaunchDarkly Server-side SDK for Python |
3 | 2 |
|
4 | | -[](https://circleci.com/gh/launchdarkly/python-client) |
5 | | - |
6 | | -[](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Flaunchdarkly%2Fpython-client?ref=badge_shield) |
| 3 | +[](https://circleci.com/gh/launchdarkly/python-server-sdk) |
7 | 4 |
|
8 | 5 | [](https://pypi.python.org/pypi/ldclient-py) |
9 | 6 | [](https://pypi.python.org/pypi/ldclient-py) |
10 | 7 |
|
11 | | -[](https://twitter.com/intent/follow?screen_name=launchdarkly) |
12 | | - |
13 | | -Supported Python versions |
14 | | -------------------------- |
15 | | - |
16 | | -This version of the LaunchDarkly SDK is compatible with Python 2.7, and Python 3.3 through 3.7. |
17 | | - |
18 | | -Quick setup |
19 | | ------------ |
20 | | - |
21 | | -1. Install the Python SDK with `pip` |
22 | | - |
23 | | - pip install ldclient-py |
24 | | - |
25 | | -2. Configure the library with your sdk key: |
26 | | - |
27 | | - import ldclient |
28 | | - |
29 | | -3. Get the client: |
30 | | - |
31 | | - ldclient.set_sdk_key("your sdk key") |
32 | | - client = ldclient.get() |
33 | | - |
34 | | - |
35 | | -HTTPS proxy |
36 | | ------------- |
37 | | -Python's standard HTTP library provides built-in support for the use of a HTTPS proxy. If the HTTPS_PROXY environment variable is present then the SDK will proxy all network requests through the URL provided. |
| 8 | +## LaunchDarkly overview |
38 | 9 |
|
39 | | -How to set the HTTPS_PROXY environment variable on Mac/Linux systems: |
40 | | -``` |
41 | | -export HTTPS_PROXY=https://web-proxy.domain.com:8080 |
42 | | -``` |
43 | | - |
44 | | - |
45 | | -How to set the HTTPS_PROXY environment variable on Windows systems: |
46 | | -``` |
47 | | -set HTTPS_PROXY=https://web-proxy.domain.com:8080 |
48 | | -``` |
49 | | - |
50 | | -Or it can be set from within python: |
51 | | -``` |
52 | | -os.environ["https_proxy"] = "https://web-proxy.domain.com:8080" |
53 | | -``` |
54 | | - |
55 | | -If your proxy requires authentication then you can prefix the URN with your login information: |
56 | | -``` |
57 | | -export HTTPS_PROXY=http://user:pass@web-proxy.domain.com:8080 |
58 | | -``` |
59 | | -or |
60 | | -``` |
61 | | -set HTTPS_PROXY=http://user:pass@web-proxy.domain.com:8080 |
62 | | -``` |
63 | | - |
64 | | - |
65 | | -Your first feature flag |
66 | | ------------------------ |
67 | | - |
68 | | -1. Create a new feature flag on your [dashboard](https://app.launchdarkly.com) |
69 | | -2. In your application code, use the feature's key to check whether the flag is on for each user: |
70 | | - |
71 | | - if client.variation("your.flag.key", {"key": "user@test.com"}, False): |
72 | | - # application code to show the feature |
73 | | - else: |
74 | | - # the code to run if the feature is off |
75 | | - |
76 | | -Supported Python versions |
77 | | -------------------------- |
78 | | - |
79 | | -The SDK is tested with the most recent patch releases of Python 2.7, 3.3, 3.4, 3.5, and 3.6. Python 2.6 is no longer supported. |
80 | | - |
81 | | -Database integrations |
82 | | ---------------------- |
| 10 | +[LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves over 100 billion feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/docs/getting-started) using LaunchDarkly today! |
| 11 | + |
| 12 | +[](https://twitter.com/intent/follow?screen_name=launchdarkly) |
83 | 13 |
|
84 | | -Feature flag data can be kept in a persistent store using Consul, DynamoDB, or Redis. These adapters are implemented in the `Consul`, `DynamoDB` and `Redis` classes in `ldclient.integrations`; to use them, call the `new_feature_store` method in the appropriate class, and put the returned object in the `feature_store` property of your client configuration. See [`ldclient.integrations`](https://launchdarkly-python-sdk.readthedocs.io/en/latest/api-integrations.html#module-ldclient.integrations) and the [SDK reference guide](https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store) for more information. |
| 14 | +## Supported Python versions |
85 | 15 |
|
86 | | -Note that Consul is not supported in Python 3.3 or 3.4. |
| 16 | +This version of the LaunchDarkly SDK is compatible with Python 2.7 and 3.3 through 3.7. It is tested with the most recent patch releases of those versions. Python 2.6 is no longer supported. |
87 | 17 |
|
88 | | -Using flag data from a file |
89 | | ---------------------------- |
| 18 | +## Getting started |
90 | 19 |
|
91 | | -For testing purposes, the SDK can be made to read feature flag state from a file or files instead of connecting to LaunchDarkly. See [`ldclient.integrations.Files`](https://launchdarkly-python-sdk.readthedocs.io/en/latest/api-integrations.html#ldclient.integrations.Files) and the [SDK reference guide](https://docs.launchdarkly.com/v2.0/docs/reading-flags-from-a-file) for more details. |
| 20 | +Refer to the [SDK reference guide](https://docs.launchdarkly.com/docs/python-sdk-reference) for instructions on getting started with using the SDK. |
92 | 21 |
|
93 | | -Learn more |
94 | | ----------- |
| 22 | +## Learn more |
95 | 23 |
|
96 | 24 | Check out our [documentation](http://docs.launchdarkly.com) for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the [complete reference guide for this SDK](http://docs.launchdarkly.com/docs/python-sdk-reference). |
97 | 25 |
|
98 | 26 | Generated API documentation is on [readthedocs.io](https://launchdarkly-python-sdk.readthedocs.io/en/latest/). |
99 | 27 |
|
100 | | -Testing |
101 | | -------- |
| 28 | +## Testing |
102 | 29 |
|
103 | 30 | We run integration tests for all our SDKs using a centralized test harness. This approach gives us the ability to test for consistency across SDKs, as well as test networking behavior in a long-running application. These tests cover each method in the SDK, and verify that event sending, flag evaluation, stream reconnection, and other aspects of the SDK all behave correctly. |
104 | 31 |
|
105 | | -[](https://codeclimate.com/github/launchdarkly/python-client/coverage) The Code Climate coverage does not include the coverage provided by this integration test harness. |
106 | | - |
107 | | -Contributing |
108 | | ------------- |
| 32 | +## Contributing |
109 | 33 |
|
110 | | -See [CONTRIBUTING](CONTRIBUTING.md) for more information. |
| 34 | +We encourage pull requests and other contributions from the community. Check out our [contributing guidelines](CONTRIBUTING.md) for instructions on how to contribute to this SDK. |
111 | 35 |
|
112 | | -About LaunchDarkly |
113 | | ------------------- |
| 36 | +## About LaunchDarkly |
114 | 37 |
|
115 | 38 | * LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can: |
116 | 39 | * Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases. |
117 | 40 | * Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?). |
118 | 41 | * Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file. |
119 | 42 | * Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline. |
120 | | -* LaunchDarkly provides feature flag SDKs for |
121 | | - * [Java](http://docs.launchdarkly.com/docs/java-sdk-reference "LaunchDarkly Java SDK") |
122 | | - * [JavaScript](http://docs.launchdarkly.com/docs/js-sdk-reference "LaunchDarkly JavaScript SDK") |
123 | | - * [PHP](http://docs.launchdarkly.com/docs/php-sdk-reference "LaunchDarkly PHP SDK") |
124 | | - * [Python](http://docs.launchdarkly.com/docs/python-sdk-reference "LaunchDarkly Python SDK") |
125 | | - * [Go](http://docs.launchdarkly.com/docs/go-sdk-reference "LaunchDarkly Go SDK") |
126 | | - * [Node.JS](http://docs.launchdarkly.com/docs/node-sdk-reference "LaunchDarkly Node SDK") |
127 | | - * [Electron](http://docs.launchdarkly.com/docs/electron-sdk-reference "LaunchDarkly Electron SDK") |
128 | | - * [.NET](http://docs.launchdarkly.com/docs/dotnet-sdk-reference "LaunchDarkly .Net SDK") |
129 | | - * [Ruby](http://docs.launchdarkly.com/docs/ruby-sdk-reference "LaunchDarkly Ruby SDK") |
130 | | - * [iOS](http://docs.launchdarkly.com/docs/ios-sdk-reference "LaunchDarkly iOS SDK") |
131 | | - * [Android](http://docs.launchdarkly.com/docs/android-sdk-reference "LaunchDarkly Android SDK") |
132 | | - * [C/C++](http://docs.launchdarkly.com/docs/c-sdk-reference "LaunchDarkly C/C++ SDK") |
| 43 | +* LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Check out [our documentation](https://docs.launchdarkly.com/docs) for a complete list. |
133 | 44 | * Explore LaunchDarkly |
134 | | - * [launchdarkly.com](http://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information |
135 | | - * [docs.launchdarkly.com](http://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDKs |
136 | | - * [apidocs.launchdarkly.com](http://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation |
137 | | - * [blog.launchdarkly.com](http://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates |
| 45 | + * [launchdarkly.com](https://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information |
| 46 | + * [docs.launchdarkly.com](https://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDK reference guides |
| 47 | + * [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation |
| 48 | + * [blog.launchdarkly.com](https://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates |
138 | 49 | * [Feature Flagging Guide](https://github.com/launchdarkly/featureflags/ "Feature Flagging Guide") for best practices and strategies |
0 commit comments