Skip to content

Commit 6e26886

Browse files
authored
Setup file for building distributions and tox integration for testing (#3)
* Added initial tox configuration; Added setup.py for packaging release distributions; Added contribution guide * Updated licensing information (removing OSS license info temporarily) * Updated project URL * Added requirements file for local setup; Updates to setup.py and documentation * Added tox to the list of tooling requirements * Updated title * Added more links to referred files * Setting minimal version for tox * Moved requirements.txt to the root of the repo * Added some info on installing pip
1 parent 9c60c17 commit 6e26886

File tree

5 files changed

+289
-73
lines changed

5 files changed

+289
-73
lines changed

.github/CONTRIBUTING.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# Contributing | Firebase Admin Python SDK
2+
3+
Thank you for contributing to the Firebase community!
4+
5+
- [Have a usage question?](#question)
6+
- [Think you found a bug?](#issue)
7+
- [Have a feature request?](#feature)
8+
- [Want to submit a pull request?](#submit)
9+
- [Need to get set up locally?](#local-setup)
10+
11+
12+
## <a name="question"></a>Have a usage question?
13+
14+
We get lots of those and we love helping you, but GitHub is not the best place for them. Issues
15+
which just ask about usage will be closed. Here are some resources to get help:
16+
17+
- Go through the [guides](https://firebase.google.com/docs/admin/setup/)
18+
- Read the full [API reference](https://firebase.google.com/docs/reference/admin/python/)
19+
20+
If the official documentation doesn't help, try asking a question on the
21+
[Firebase Google Group](https://groups.google.com/forum/#!forum/firebase-talk/) or one of our
22+
other [official support channels](https://firebase.google.com/support/).
23+
24+
**Please avoid double posting across multiple channels!**
25+
26+
27+
## <a name="issue"></a>Think you found a bug?
28+
29+
Yeah, we're definitely not perfect!
30+
31+
Search through [old issues](https://github.com/firebase/firebase-admin-python/issues) before
32+
submitting a new issue as your question may have already been answered.
33+
34+
If your issue appears to be a bug, and hasn't been reported,
35+
[open a new issue](https://github.com/firebase/firebase-admin-python/issues/new). Please use the
36+
provided bug report template and include a minimal repro.
37+
38+
If you are up to the challenge, [submit a pull request](#submit) with a fix!
39+
40+
41+
## <a name="feature"></a>Have a feature request?
42+
43+
Great, we love hearing how we can improve our products! Share you idea through our
44+
[feature request support channel](https://firebase.google.com/support/contact/bugs-features/).
45+
46+
47+
## <a name="submit"></a>Want to submit a pull request?
48+
49+
Sweet, we'd love to accept your contribution!
50+
[Open a new pull request](https://github.com/firebase/firebase-admin-python/pull/new/master) and fill
51+
out the provided template.
52+
53+
**If you want to implement a new feature, please open an issue with a proposal first so that we can
54+
figure out if the feature makes sense and how it will work.**
55+
56+
Make sure your changes pass our linter and the tests all pass on your local machine.
57+
Most non-trivial changes should include some extra test coverage. If you aren't sure how to add
58+
tests, feel free to submit regardless and ask us for some advice.
59+
60+
Finally, you will need to sign our
61+
[Contributor License Agreement](https://cla.developers.google.com/about/google-individual)
62+
before we can accept your pull request.
63+
64+
65+
## <a name="local-setup"></a>Need to get set up locally?
66+
67+
68+
### Initial Setup
69+
70+
We recommend using [pip](https://pypi.python.org/pypi/pip) for installing the necessary tools and
71+
project dependencies. Most recent versions of Python ship with pip. If your development environment
72+
does not already have pip, use the software package manager of your platform (e.g. apt-get, brew)
73+
to download and install it. Alternatively you may also follow the official
74+
[pip installation guide](https://pip.pypa.io/en/stable/installing/).
75+
76+
Once pip is installed, run the following commands from the command line to get your local
77+
environment set up:
78+
79+
```bash
80+
$ git clone https://github.com/firebase/firebase-admin-python.git
81+
$ cd firebase-admin-python # go to the firebase-admin-python directory
82+
$ pip install -r requirements.txt # Install additional tools and dependencies
83+
```
84+
85+
### Running Linters
86+
87+
We use [pylint](https://pylint.org/) for verifying source code format, and
88+
enforcing other Python programming best practices.
89+
There is a pylint configuration file ([`.pylintrc`](../.pylintrc)) at the root of this Git
90+
repository. This enables you to invoke pylint directly from the command line:
91+
92+
```
93+
pylint firebase
94+
```
95+
96+
However, it is recommended that you use the [`lint.sh`](../lint.sh) bash script to invoke
97+
pylint. This script will run the linter on both `firebase` and the corresponding
98+
`tests` module. It suprresses some of the noisy warnings that get generated
99+
when running pylint on test code. Note that by default `lint.sh` will only
100+
validate the locally modified source files. To validate all source files,
101+
pass `all` as an argument.
102+
103+
```
104+
./lint.sh # Lint locally modified source files
105+
./lint.sh all # Lint all source files
106+
```
107+
108+
Ideally you should not see any pylint errors or warnings when you run the
109+
linter. This means source files are properly formatted, and the linter has
110+
not found any issues. If you do observe any errors, fix them before
111+
committing or sending a pull request. Details on how to interpret pylint
112+
errors are available
113+
[here](https://pylint.readthedocs.io/en/latest/user_guide/output.html).
114+
115+
Our configuration files suppress the verbose reports usually generated
116+
by pylint, and only output the detected issues. If you wish to obtain the
117+
comprehensive reports, run pylint from command-line with the `-r` flag.
118+
119+
```
120+
pylint -r yes firebase
121+
```
122+
123+
### Unit Testing
124+
125+
We use [pytest](http://doc.pytest.org/en/latest/) for writing and executing
126+
unit tests. All source files containing test code is located in the `tests/`
127+
directory. Simply launch pytest from the root of the Git repository, or from
128+
within the `tests/` directory to execute all test cases.
129+
130+
```
131+
pytest
132+
```
133+
134+
Refer to the pytest [usage and invocations guide](http://doc.pytest.org/en/latest/usage.html)
135+
to learn how to run a subset of all test cases.
136+
137+
### Testing in Different Environments
138+
139+
Sometimes we may want to run unit tests in multiple environments (e.g. different
140+
Python versions), and ensure that the SDK works as expected in each of them.
141+
We use [tox](https://tox.readthedocs.io/en/latest/) for this purpose.
142+
You can execute the following command from the root of the repository to
143+
launch tox:
144+
145+
```
146+
tox
147+
```
148+
149+
This command will read a list of target environments from the [`tox.ini`](../tox.ini)
150+
file in the Git repository, and execute test cases in each of those environments.
151+
152+
### Repo Organization
153+
154+
Here are some highlights of the directory structure and notable source files
155+
156+
* `firebase/` - Source directory for the `firebase` module.
157+
* `tests/` - Unit tests.
158+
* `data/` - Provides mocks for several variables as well as mock service account keys.
159+
* `.github/` - Contribution instructions as well as issue and pull request templates.
160+
* `lint.sh` - Runs pylint to check for code quality.
161+
* `.pylintrc` - Default configuration for pylint.
162+
* `requirements.txt` - Requirements specification for installing project dependencies via pip.
163+
* `setup.py` - Python setup script for building distribution artifacts.
164+
* `tox.ini` - Tox configuration for running tests on different environments.

README.md

Lines changed: 18 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,29 @@
11
# Firebase Admin Python SDK
22

3-
The Firebase Admin Python SDK enables server-side (backend) Python developers
4-
to integrate [Firebase](https://firebase.google.com) into their services
5-
and applications. Currently this SDK provides Firebase custom authentication
6-
support.
3+
## Table of Contents
74

5+
* [Overview](#overview)
6+
* [Documentation](#documentation)
7+
* [License and Terms](#license-and-terms)
88

9-
## Unit Testing
10-
We use [pytest](http://doc.pytest.org/en/latest/) for writing and executing
11-
unit tests. Download pytest 3.0.6 or higher using pip:
9+
## Overview
1210

13-
```
14-
pip install -U pytest
15-
```
11+
[Firebase](https://firebase.google.com) provides the tools and infrastructure
12+
you need to develop apps, grow your user base, and earn money. The Firebase
13+
Admin Python SDK enables server-side (backend) Python developers to integrate
14+
Firebase into their services and applications. Currently this SDK provides
15+
Firebase custom authentication support.
1616

17-
All source files containing test code is located in the `tests/`
18-
directory. Simply launch pytest from the root of the Git repository, or from
19-
within the `tests/` directory to execute all test cases.
17+
For more information, visit the
18+
[Firebase Admin SDK setup guide](https://firebase.google.com/docs/admin/setup/).
2019

21-
```
22-
pytest
23-
```
2420

25-
Refer to the pytest [usage and invocations guide](http://doc.pytest.org/en/latest/usage.html)
26-
to learn how to run a subset of all test cases.
21+
## Documentation
2722

23+
* [Setup Guide](https://firebase.google.com/docs/admin/setup/)
24+
* [API Reference](https://firebase.google.com/docs/reference/admin/python/)
2825

29-
## Running Linters
30-
We use [pylint](https://pylint.org/) for verifying source code format, and
31-
enforcing other Python programming best practices. Install pylint 1.6.4 or
32-
higher using pip:
26+
## License and Terms
3327

34-
```
35-
pip install -U pylint
36-
```
37-
38-
Specify a pylint version explicitly if the above command installs an older
39-
version:
40-
41-
```
42-
pip install pylint==1.6.4
43-
```
44-
45-
Once installed, you can check the version of the installed binary by running
46-
the following command:
47-
48-
```
49-
pylint --version
50-
```
51-
52-
There is a pylint configuration file (`.pylintrc`) at the root of this Git
53-
repository. This enables you to invoke pylint directly from the command line:
54-
55-
```
56-
pylint firebase
57-
```
58-
59-
However, it is recommended that you use the `lint.sh` bash script to invoke
60-
pylint. This script will run the linter on both `firebase` and the corresponding
61-
`tests` module. It suprresses some of the noisy warnings that get generated
62-
when running pylint on test code. Note that by default `lint.sh` will only
63-
validate the locally modified source files. To validate all source files,
64-
pass `all` as an argument.
65-
66-
```
67-
./lint.sh # Lint locally modified source files
68-
./lint.sh all # Lint all source files
69-
```
70-
71-
Ideally you should not see any pylint errors or warnings when you run the
72-
linter. This means source files are properly formatted, and the linter has
73-
not found any issues. If you do observe any errors, fix them before
74-
committing or sending a pull request. Details on how to interpret pylint
75-
errors are available
76-
[here](https://pylint.readthedocs.io/en/latest/user_guide/output.html).
77-
78-
Our configuration files suppress the verbose reports usually generated
79-
by pylint, and only output the detected issues. If you wish to obtain the
80-
comprehensive reports, run pylint from command-line with the `-r` flag.
81-
82-
```
83-
pylint -r yes firebase
84-
```
28+
Your use of Firebase is governed by the
29+
[Terms of Service for Firebase Services](https://firebase.google.com/terms/).

requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pylint >= 1.6.4
2+
pytest >= 3.0.6
3+
tox >= 2.6.0
4+
5+
oauth2client >= 4.0.0

setup.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
"""Setup file for distribution artifacts."""
2+
from os import path
3+
from setuptools import setup, find_packages
4+
5+
6+
here = path.abspath(path.dirname(__file__))
7+
8+
long_description = ('The Firebase Admin Python SDK enables server-side (backend) Python developers '
9+
'to integrate Firebase into their services and applications.')
10+
11+
setup(
12+
name='firebase',
13+
14+
# Versions should comply with PEP440. For a discussion on single-sourcing
15+
# the version across setup.py and the project code, see
16+
# https://packaging.python.org/en/latest/single_source_version.html
17+
version='0.0.1',
18+
19+
description='Firebase Admin Python SDK',
20+
long_description=long_description,
21+
22+
url='https://firebase.google.com/docs/admin/setup/',
23+
24+
# Author details
25+
author='Firebase',
26+
27+
# Choose your license
28+
license='https://firebase.google.com/terms/',
29+
30+
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
31+
classifiers=[
32+
# How mature is this project? Common values are
33+
# 3 - Alpha
34+
# 4 - Beta
35+
# 5 - Production/Stable
36+
'Development Status :: 3 - Alpha',
37+
38+
# Indicate who your project is intended for
39+
'Intended Audience :: Developers',
40+
'Topic :: Software Development :: Build Tools',
41+
42+
# Specify the Python versions you support here. In particular, ensure
43+
# that you indicate whether you support Python 2, Python 3 or both.
44+
'Programming Language :: Python :: 2',
45+
'Programming Language :: Python :: 2.7',
46+
],
47+
48+
# What does your project relate to?
49+
keywords='firebase cloud development',
50+
51+
packages=find_packages(exclude=['tests']),
52+
53+
# List run-time dependencies here. These will be installed by pip when
54+
# your project is installed. For an analysis of "install_requires" vs pip's
55+
# requirements files see:
56+
# https://packaging.python.org/en/latest/requirements.html
57+
install_requires=['oauth2client'],
58+
59+
# List additional groups of dependencies here (e.g. development
60+
# dependencies). You can install these using the following syntax,
61+
# for example:
62+
# $ pip install -e .[dev,test]
63+
#extras_require={
64+
# 'dev': ['check-manifest'],
65+
# 'test': ['coverage'],
66+
#},
67+
68+
# If there are data files included in your packages that need to be
69+
# installed, specify them here. If using Python 2.6 or less, then these
70+
# have to be included in MANIFEST.in as well.
71+
#package_data={
72+
# 'sample': ['package_data.dat'],
73+
#},
74+
75+
# Although 'package_data' is the preferred approach, in some case you may
76+
# need to place data files outside of your packages. See:
77+
# http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files # noqa
78+
# In this case, 'data_file' will be installed into '<sys.prefix>/my_data'
79+
#data_files=[('my_data', ['data/data_file'])],
80+
81+
# To provide executable scripts, use entry points in preference to the
82+
# "scripts" keyword. Entry points provide cross-platform support and allow
83+
# pip to create the appropriate form of executable for the target platform.
84+
#entry_points={
85+
# 'console_scripts': [
86+
# 'sample=sample:main',
87+
# ],
88+
#},
89+
)

tox.ini

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Tox (https://tox.readthedocs.io/) is a tool for running tests
2+
# in multiple virtualenvs. This configuration file will run the
3+
# test suite on all supported python versions. To use it, "pip install tox"
4+
# and then run "tox" from this directory.
5+
6+
[tox]
7+
envlist = py27
8+
9+
[testenv]
10+
commands = pytest
11+
deps =
12+
pytest
13+
oauth2client

0 commit comments

Comments
 (0)