This project was generated by the dash-component-boilerplate it contains the minimal set of code required to create your own custom Dash component.
N.B.: because of the current usage of postbuild_fixups.sh
build script, this project can only be build on a Linux distribution
-
Install npm packages
$ npm install
-
Create a virtual env and activate.
$ python3 -m venv venv $ . venv/bin/activate
-
Install python packages required to build components.
$ pip install wheel $ pip install -r requirements.txt # or $ pip install -r requirements.txt --upgrade
-
Install the python packages for testing (optional)
$ pip install -r tests/requirements.txt # or $ pip install -r tests/requirements.txt --upgrade
- The demo app is in
src/demo
and you will import your example component code into your demo app. - Test your code in a Python environment:
- Build your code
N.B.
$ npm run build
- We use
postbuild_fixups.sh
to re-write certain lines in the generated Julia files of this package to allow usage of Julia's Artifact system.
- We use
- Run and modify the
usage.py
sample dash app:$ python usage.py
- Build your code
- Write tests for your component.
- A sample test is available in
tests/test_usage.py
, it will loadusage.py
and you can then automate interactions with selenium. - Run the tests with
$ pytest tests
. - 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)
- A sample test is available in
Add custom styles to your component by putting your custom CSS files into your distribution folder (dash_textarea_autocomplete
).- Make sure that they are referenced in
MANIFEST.in
so that they get properly included when you're ready to publish your component. Make sure the stylesheets are added to thedoes not apply_css_dist
dict indash_textarea_autocomplete/__init__.py
so dash will serve them automatically when the component suite is requested.
- Make sure that they are referenced in
- Review your code
-
Pre-requisites
- Contact @etpinard to get write access to this repo
- Create an npmjs.com account and a pypi.org account and ask @etpinard for publish rights
- Provide your login/pass for Pypi (if you're not using a keychain-type Python module for that)
and sign-in to NPM with
npm login
- Install dependencies and activate python virtualenv ref
-
Version, build, commit and push your code:
$ git checkout main $ npm version --no-git-tag-version <patch|minor|major> $ npm run build $ git add --all $ git commit -m "X.Y.Z" $ git push
N.B.
- we use the
--no-git-tag-version
flag, becauseRegistrator.jl
won't work if a tag corresponding to the to-be-registered version already exists.
- we use the
-
Create a Python distribution
$ rm -rf dist/* $ pip install wheel $ python setup.py sdist bdist_wheel
This will create source and wheel distribution in the generated the
dist/
folder. See PyPA for more information. -
Test your tarball by copying it into a new environment and installing it locally:
$ mkdir some-tmp-dir $ cd some-tmp-dir $ python3 -m venv venv $ . venv/bin/activate $ pip install wheel $ pip install /path/to/dist/dash_textarea_autocomplete-X.Y.Z.tar.gz
-
If it works, then you can publish the component:
-
Publish on PyPI (N.B. must have PyPI token and
$HOME/.pypirc
filled correctly)$ pip install twine $ twine upload dist/*
-
Publish on NPM
$ npm publish
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
toFalse
and you may see faster load times. -
Publish to Julia's General Registry
- Go to the repo's Github's page and add the following comment on the version commit:
@JuliaRegistrator register branch=main
If something goes wrong (like a test failure), click here
- fix the problem,
- run
npm run build
, - add, commit and push (but do not bump the version!),
- redo step 2-3 and
- make another
@JuliaRegistrator register branch=main
comment on the newly pushed commit on Github. The JuliaRegistrator bot will match the version number with the openedJuliaRegistries/General
PR.
After the
JuliaRegistries/General
PR is merged, the Julia version of the package will be out-of-sync with the NPM and PyPI versions. So, it is hightly recommanded to redo the publish process from scratch starting with annpm version --no-git-tag-version patch
call. Note that we cannot simply abandoned an openedJuliaRegistries/General
PR, as the Julia registries require "sequential" version increments as of 2021-12-16. That is, going fromv1.1.0
tov1.2.1
if thev1.2.0
release is botched is not allowed.
-
-
Tag and make a Github release
- Done automatically by
TagBot
after the new version has been merged in Julia's General Registry.
- Done automatically by