Skip to content

Commit ee5edd7

Browse files
authored
Merge pull request #29 from python-microservices/feature/pipenv
Add Pipenv support
2 parents d10728b + a630507 commit ee5edd7

File tree

8 files changed

+610
-34
lines changed

8 files changed

+610
-34
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ language: python
22
python:
33
- '3.6'
44
install:
5+
- pip install pipenv
56
- pip install -U tox coveralls
67

78
script:

Pipfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
flask = "*"
8+
jaeger-client = "==3.12.0"
9+
python-json-logger = "==0.1.10"
10+
pyyaml = "==3.13"
11+
anyconfig = "==0.9.8"
12+
swagger-ui-bundle = "==0.0.2"
13+
connexion = {extras = ["swagger-ui"],version = "==2.1.0"}
14+
flask-opentracing = "==0.2.0"
15+
16+
[dev-packages]
17+
requests-mock = "*"
18+
coverage = "*"
19+
mock = "*"
20+
nose = "*"
21+
pylint = "*"
22+
tox = "*"
23+
24+
[requires]
25+
python_version = "3.6"

Pipfile.lock

Lines changed: 508 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,49 @@ Encapsulate common rest operations between business services propagating trace h
3535

3636
### pyms/tracer
3737
Create an injector `flask_opentracing.FlaskTracer` to use in our projects
38+
39+
## Pipenv
40+
41+
### Advantages over plain pip and requirements.txt
42+
[Pipenv](https://pipenv.readthedocs.io/en/latest/) generates two files: a `Pipfile`and a `Pipfile.lock`.
43+
* `Pipfile`: Is a high level declaration of the dependencies of your project. It can contain "dev" dependencies (usually test related stuff) and "standard" dependencies which are the ones you'll need for your project to function
44+
* `Pipfile.lock`: Is the "list" of all the dependencies your Pipfile has installed, along with their version and their hashes. This prevents two things: Conflicts between dependencies and installing a malicious module.
45+
46+
### How to...
47+
48+
Here the most 'common' `pipenv` commands, for a more in-depth explanation please refer to the [official documentation](https://pipenv.readthedocs.io/en/latest/).
49+
50+
#### Install pipenv
51+
```bash
52+
pip install pipenv
53+
```
54+
55+
#### Install dependencies defined in a Pipfile
56+
```bash
57+
pipenv install
58+
```
59+
60+
#### Install both dev and "standard" dependencies defined in a Pipfile
61+
```bash
62+
pipenv install --dev
63+
```
64+
65+
#### Install a new module
66+
```bash
67+
pipenv install django
68+
```
69+
70+
#### Install a new dev module (usually test related stuff)
71+
```bash
72+
pipenv install nose --dev
73+
```
74+
75+
#### Install dependencies in production
76+
```bash
77+
pipenv install --deploy
78+
```
79+
80+
#### Start a shell
81+
```bash
82+
pipenv shell
83+
```

requirements-tests.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

requirements.txt

Lines changed: 0 additions & 13 deletions
This file was deleted.

setup.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import codecs
44
import os
55

6+
import json
67
from setuptools import setup, find_packages
78

89
author = __import__('pyms').__author__
@@ -14,9 +15,21 @@
1415
else:
1516
long_description = ''
1617

17-
# parse_requirements() returns generator of pip.req.InstallRequirement objects
18-
with open('requirements.txt') as f:
19-
required = [lib for lib in f.read().splitlines() if not lib.startswith("-e")]
18+
19+
20+
install_requires = []
21+
tests_require = []
22+
if os.path.exists('Pipfile.lock'):
23+
with open('Pipfile.lock') as fd:
24+
lock_data = json.load(fd)
25+
install_requires = [
26+
package_name + package_data['version']
27+
for package_name, package_data in lock_data['default'].items()
28+
]
29+
tests_require = [
30+
package_name + package_data['version']
31+
for package_name, package_data in lock_data['develop'].items()
32+
]
2033

2134
setup(
2235
name="py-ms",
@@ -26,18 +39,21 @@
2639
description="",
2740
long_description=long_description,
2841
classifiers=[
29-
'Development Status :: 6 - Mature',
42+
'Development Status :: 3 - Alpha',
43+
'Framework :: Flask',
3044
"Intended Audience :: Developers",
3145
"Natural Language :: English",
3246
"Programming Language :: Python :: 3.6",
47+
"Programming Language :: Python :: 3.7",
3348
],
34-
license="Proprietary",
49+
license="License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
3550
platforms=["any"],
3651
keywords="",
3752
url='',
3853
test_suite='nose.collector',
3954
packages=find_packages(),
40-
install_requires=required,
55+
install_requires=install_requires,
56+
tests_require=tests_require,
4157
include_package_data=True,
4258
zip_safe=True,
43-
)
59+
)

tox.ini

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ whitelist_externals = /bin/bash
1616

1717
[testenv:py36]
1818
basepython = python3.6
19-
deps = -rrequirements-tests.txt
20-
[testenv:py35]
21-
basepython = python3.5
22-
deps = -rrequirements-tests.txt
23-
[testenv:py27]
24-
basepython = python2.7
25-
deps = -rrequirements-tests.txt
19+
deps = pipenv
20+
commands=
21+
pipenv install --dev --ignore-pipfile
22+
python setup.py test
23+
setenv=
24+
LC_ALL=en_GB.UTF-8
25+
LANG=en_GB.UTF-8

0 commit comments

Comments
 (0)