Skip to content

Commit 1506756

Browse files
authored
Add CI and pypi deployment (#8)
1 parent 8af5013 commit 1506756

File tree

10 files changed

+170
-96
lines changed

10 files changed

+170
-96
lines changed

.travis.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
language: python
2+
dist: bionic
3+
4+
addons:
5+
chrome: stable
6+
7+
services:
8+
- xvfb
9+
10+
python:
11+
- "3.6"
12+
13+
before_install:
14+
- sudo apt-get -qq update
15+
- pip freeze | grep -vw "pip" | xargs pip uninstall -y
16+
- pip install --upgrade pip
17+
18+
install:
19+
- pip install .[dependencies]
20+
- pip install .[tests]
21+
- pip install dash[testing]
22+
- npm install
23+
- wget https://chromedriver.storage.googleapis.com/76.0.3809.12/chromedriver_linux64.zip
24+
- unzip chromedriver_linux64.zip
25+
- export PATH=$PATH:$PWD
26+
27+
script:
28+
- npm run test
29+
- npm run build
30+
- pip install .
31+
- pytest
32+
33+
deploy:
34+
- provider: pypi
35+
user: webviz
36+
password:
37+
secure: "O35ATzdM5i5dEQQksZIi5JJEmgTWU4bHQBRLZiLosLZ4oDbOF6E+QlOISymJizw2EGu02vYr0b0mIDOT21hO9T0R1snq7Gl9zQMJoZyR5FV9ZD2jFZNOODVmuCZGjUZkyblnGMQD93c9Q1Mi+iFHRaokYN3qD8Jgm8MVap1qBIJgcNLwzB6qng0K8Dj1BJRlccuAIqxa01cxBoRAgjtugXSYmrUgmO8GAiMGCQBQgnk2LWMhIgZ3c8O4rDwjNfEEg1vr34t66XuO6p17oSVBt+ncE0UjAR0PEuxVayQ1M9KCV7Awgb5MQcQMcC5I6jvdiIqzLkH8A71ORtgohd9vhy3OlnersR3sLXdRumekWy+JkD1JL2KgzJoUrlQ/asOphMJhmv6Pbg8BmJTGKWDWF12zqNX9Q9b+WN2cjmXbwBSADM9K5qsQb2Bjw+tlhDBzAQPVl89hBYodVY5yhk+soMgJqRQEDcn30t7cJUCEJEoEkQUbkTPGtZberWqKzRDFYC8cr3lwYTenzm8ARVEFOslQx8AadW2bq0Nz49osYB/AXFkF5voBf3eVthplsU5JPDiik7zTgl3Ee11Tth/NMAdxoF3dtGs4F87n6zs2e369CD8EtkaFkDaPv7htb1/6fjYGF/rbYye9CmRhJARQYcjoZnj4ekLmJVFu+k+VzN0="
38+
on:
39+
tags: true

README.md

Lines changed: 53 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,91 @@
1-
# webviz-core-components
1+
[![PyPI version](https://badge.fury.io/py/webviz-core-components.svg)](https://badge.fury.io/py/webviz-core-components)
2+
[![Build Status](https://travis-ci.org/equinor/webviz-core-components.svg?branch=master)](https://travis-ci.org/equinor/webviz-core-components)
3+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/e5f81735a1a9423eb7be3fee8e2d30ee)](https://www.codacy.com/app/anders-kiaer/webviz-core-components?utm_source=github.com&utm_medium=referral&utm_content=equinor/webviz-core-components&utm_campaign=Badge_Grade)
4+
[![Python 3.6+](https://img.shields.io/badge/python-3.6+-blue.svg)](https://www.python.org/)
25

3-
webviz-core-components is a Dash component library.
6+
# Webviz core components
47

5-
Get started with:
6-
1. Install Dash and its dependencies: https://dash.plot.ly/installation
7-
2. Run `python usage.py`
8-
3. Visit http://localhost:8050 in your web browser
8+
`webviz_core_components` is a Dash component library for use in `webviz`.
9+
10+
You can quickly get started with:
11+
12+
1. Run `pip install webviz-core-components`
13+
2. Run `python usage.py`
14+
3. Visit http://localhost:8050 in your web browser
915

1016
## Contributing
1117

12-
See [CONTRIBUTING.md](./CONTRIBUTING.md)
18+
This project was generated by the
19+
[dash-component-boilerplate](https://github.com/plotly/dash-component-boilerplate).
20+
It contains the minimal set of code required to create a custom Dash component.
1321

1422
### Install dependencies
1523

1624
If you have selected install_dependencies during the prompt, you can skip this part.
1725

1826
1. Install npm packages
1927
```
20-
$ npm install
28+
npm install
2129
```
2230
2. Create a virtual env and activate.
2331
```
24-
$ virtualenv venv
25-
$ . venv/bin/activate
32+
virtualenv venv
33+
. venv/bin/activate
2634
```
2735
_Note: venv\Scripts\activate for windows_
2836
2937
3. Install python packages required to build components.
3038
```
31-
$ pip install -r requirements.txt
39+
pip install .[dependencies]
3240
```
3341
4. Install the python packages for testing (optional)
3442
```
35-
$ pip install -r tests/requirements.txt
43+
pip install .[tests]
44+
pip install dash[testing]
3645
```
46+
The second of these commands appears to be necessary as long as
47+
[this `pip` issue is open](https://github.com/pypa/pip/issues/4957).
3748
38-
### Write your component code in `src/lib/components/WebvizCoreComponents.react.js`.
49+
### Write component code in `src/lib/components/<component_name>.react.js`
3950
4051
- The demo app is in `src/demo` and you will import your example component code into your demo app.
4152
- Test your code in a Python environment:
4253
1. Build your code
4354
```
44-
$ npm run build
55+
npm run build:all
4556
```
4657
2. Run and modify the `usage.py` sample dash app:
4758
```
48-
$ python usage.py
59+
python usage.py
4960
```
50-
- Write tests for your component.
51-
- A sample test is available in `tests/test_usage.py`, it will load `usage.py` and you can then automate interactions with selenium.
52-
- Run the tests with `$ pytest tests`.
53-
- The Dash team uses these types of integration tests extensively. Browse the Dash component code on GitHub for more examples of testing (e.g. https://github.com/plotly/dash-core-components)
54-
- Add custom styles to your component by putting your custom CSS files into your distribution folder (`webviz_core_components`).
55-
- Make sure that they are referenced in `MANIFEST.in` so that they get properly included when you're ready to publish your component.
56-
- Make sure the stylesheets are added to the `_css_dist` dict in `webviz_core_components/__init__.py` so dash will serve them automatically when the component suite is requested.
57-
- [Review your code](./review_checklist.md)
58-
59-
### Create a production build and publish:
60-
61-
1. Build your code:
62-
```
63-
$ npm run build
64-
```
65-
2. Create a Python tarball
61+
- Write tests for your component.
62+
- A sample test is available in `tests/test_usage.py`, it will load
63+
`usage.py` and you can then automate interactions with selenium.
64+
65+
- Run the tests with `pytest tests`.
66+
67+
- The Dash team uses these types of integration tests extensively.
68+
Browse the Dash component code on GitHub for more examples of testing
69+
(e.g. [dash-core-components](https://github.com/plotly/dash-core-components)).
70+
71+
- Add custom styles to your component by putting your custom CSS files into
72+
your distribution folder (`webviz_subsurface_components`).
73+
- Make sure that they are referenced in `MANIFEST.in` so that they get
74+
properly included when you're ready to publish your component.
75+
76+
- Make sure the stylesheets are added to the `_css_dist` dict in
77+
`webviz_core_components/__init__.py` so dash will serve them
78+
automatically when the component suite is requested.
79+
80+
- [Review your code](./review_checklist.md)
81+
82+
### Build code and install
83+
84+
1. Build your code:
6685
```
67-
$ python setup.py sdist
86+
npm run build:all
6887
```
69-
This distribution tarball will get generated in the `dist/` folder
70-
71-
3. Test your tarball by copying it into a new environment and installing it locally:
88+
2. Install the Python package:
7289
```
73-
$ pip install webviz_core_components-0.0.1.tar.gz
90+
python setup.py install
7491
```
75-
76-
4. If it works, then you can publish the component to NPM and PyPI:
77-
1. Publish on PyPI
78-
```
79-
$ twine upload dist/*
80-
```
81-
2. Cleanup the dist folder (optional)
82-
```
83-
$ rm -rf dist
84-
```
85-
3. Publish on NPM (Optional if chosen False in `publish_on_npm`)
86-
```
87-
$ npm publish
88-
```
89-
_Publishing your component to NPM will make the JavaScript bundles available on the unpkg CDN. By default, Dash serves the component library's CSS and JS locally, but if you choose to publish the package to NPM you can set `serve_locally` to `False` and you may see faster load times._
90-
91-
5. Share your component with the community! https://community.plot.ly/c/dash
92-
1. Publish this repository to GitHub
93-
2. Tag your GitHub repository with the plotly-dash tag so that it appears here: https://github.com/topics/plotly-dash
94-
3. Create a post in the Dash community forum: https://community.plot.ly/c/dash

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "webviz_core_components",
3-
"version": "0.0.1",
43
"description": "Core components for webviz config",
54
"repository": {
65
"type": "git",

requirements.txt

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

setup.py

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,58 @@
1+
import os
2+
import json
13
from setuptools import setup
24

5+
6+
with open('README.md', 'r') as fh:
7+
long_description = fh.read()
8+
9+
with open(os.path.join('webviz_core_components', 'package-info.json')) as f:
10+
package = json.load(f)
11+
12+
package_name = package['name'].replace(' ', '_').replace('-', '_')
13+
14+
install_requires = [
15+
'dash~=1.0.1'
16+
]
17+
18+
tests_require = [
19+
'chromedriver-binary>=74.0.3729.6.0',
20+
'ipdb',
21+
'percy',
22+
'selenium',
23+
'flake8',
24+
'pylint'
25+
]
26+
27+
# 'dash[testing]' to be added in tests_require when
28+
# https://github.com/pypa/pip/issues/4957 is closed.
29+
330
setup(
4-
name="webviz_core_components",
5-
author="R&T Equinor",
6-
packages=["webviz_core_components"],
31+
name=package_name,
32+
author=package['author'],
33+
packages=[package_name],
734
include_package_data=True,
8-
license="LGPLv3",
9-
install_requires=[]
35+
license=package['license'],
36+
description=package['description'],
37+
long_description=long_description,
38+
long_description_content_type='text/markdown',
39+
url='https://github.com/equinor/webviz-core-components',
40+
install_requires=install_requires,
41+
tests_require=tests_require,
42+
extras_require={
43+
'tests': tests_require,
44+
'dependencies': install_requires
45+
},
46+
setup_requires=['setuptools_scm>=3.2.0'],
47+
use_scm_version=True,
48+
classifiers=[
49+
'Programming Language :: Python :: 3',
50+
'Operating System :: OS Independent',
51+
'Natural Language :: English',
52+
'Topic :: Multimedia :: Graphics',
53+
'Topic :: Scientific/Engineering',
54+
'Topic :: Scientific/Engineering :: Visualization',
55+
'License :: OSI Approved :: '\
56+
'GNU Lesser General Public License v3 (LGPLv3)'
57+
]
1058
)

tests/requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import dash
2+
import dash_html_components as html
3+
import webviz_core_components
4+
5+
def test_container_placeholder(dash_duo):
6+
7+
app = dash.Dash(__name__)
8+
9+
app.layout = html.Div([
10+
webviz_core_components.WebvizContainerPlaceholder(
11+
id='container',
12+
children=['Hello world']
13+
),
14+
html.Div(id='output')
15+
])
16+
17+
dash_duo.start_server(app)

tests/test_usage.py

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

webviz_core_components/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@
44
import sys as _sys
55
import json
66

7+
from pkg_resources import get_distribution, DistributionNotFound
8+
79
import dash as _dash
810

911
# noinspection PyUnresolvedReferences
1012
from ._imports_ import *
1113
from ._imports_ import __all__
1214

15+
try:
16+
__version__ = get_distribution(__name__).version
17+
except DistributionNotFound:
18+
# package is not installed
19+
pass
20+
1321
if not hasattr(_dash, 'development'):
1422
print('Dash was not successfully imported. '
1523
'Make sure you don\'t have a file '
@@ -22,7 +30,6 @@
2230
package = json.load(f)
2331

2432
package_name = package['name'].replace(' ', '_').replace('-', '_')
25-
__version__ = package['version']
2633

2734
_current_path = _os.path.dirname(_os.path.abspath(__file__))
2835

webviz_core_components/package-info.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "webviz_core_components",
3-
"version": "0.0.1",
43
"description": "Core components for webviz config",
54
"repository": {
65
"type": "git",

0 commit comments

Comments
 (0)