Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add testplan to PyPI and npm to simplify install #284

Open
ryan-collingham opened this issue Sep 19, 2019 · 7 comments
Open

Add testplan to PyPI and npm to simplify install #284

ryan-collingham opened this issue Sep 19, 2019 · 7 comments
Labels
enhancement New feature or request

Comments

@ryan-collingham
Copy link
Contributor

Currently, users have to install testplan directly from the github archive (or git clone the source), and run a separate script to build the UI from source. It would be great if we could leverage the standard python/JS package distribution services and make the Testplan python package installable from PyPI via pip install testplan and the UI installable from npm via npm install -g testplan-ui.

Potentially the setup.py could automatically run the npm install command, making the entire install as simple as pip install testplan - though possibly it's better to leave the UI install as a separate step, so that users who don't want the UI can install just the Python Testplan framework.

@ryan-collingham ryan-collingham added the enhancement New feature or request label Sep 19, 2019
@ryan-collingham
Copy link
Contributor Author

This would also require us to set up some kind of release schedule & tagging of releases to upload to PyPI and npm. I think that definitely we should use the same version numbers for testplan python and testplan UI, and ideally have some mechanism to keep both in sync (e.g. python testplan 1.2.3 will by install testplan-ui 1.2.3 and not any other version).

@francoisverbeek
Copy link

I've been experimenting with this a bit, so far I have seen the following small snags

  • OverrideMeOrThereWillBeABuildError is set in .env (I haven't investigated in detail)
  • ESLint fails if CI is set (warnings become errors)

What I am trying to do internally is to build the interactive interface as part of ci and package the built version inside the wheel, so that an user only needs to install the wheel and not install node etc. on his/her machine, the javascript/css and other components are just blobs as far as python is concerned.

@yuxuan-ms
Copy link
Contributor

Hi @francoisverbeek ,

Thanks for the information. We have to improve the document.

OverrideMeOrThereWillBeABuildError is used on the beta feature: URL navigation.
You need to replace OverrideMeOrThereWillBeABuildError in .env, or export REACT_APP_API_BASE_URL="http://TEST" before building the UI.

Actually, we are considering to package the built version inside the wheel or add it to PyPI.

@francoisverbeek
Copy link

Hi @yuxuan-ms, thank you! I've been changing OverrideMeOrThereWillBeABuildError to /api and it did the trick ; looking forward to having it nice and packaged with the ui all-prebuilt on pypi 👍

@ryanc414
Copy link
Contributor

FYI, in case it helps, I figured out a good way to put together a python package with all the JS, HTML, CSS etc. files related to a web app in one of my personal projects.

First of all, you need to add a MANIFEST.in file that directs the setup tooling to include the npm build outputs, for example: https://github.com/ryanc414/pytest_commander/blob/master/MANIFEST.in

Secondly, you need to specify include_package_data=True in the setup.py setup function as described here: https://setuptools.readthedocs.io/en/latest/userguide/datafiles.html

Then, you can access the data files from python code using the pkg_resources like: https://github.com/ryanc414/pytest_commander/blob/a6941788a98c0903c30f90abb340c612cec1b539/pytest_commander/api.py#L22

To build and publish the package, you need to remember to first build all the web client files before running setup.py to generate a wheel. I used a github action to run this automatically whenever I publish a new release: https://github.com/ryanc414/pytest_commander/blob/master/.github/workflows/python-publish.yml

This gives a really nice UX since a user only has to run pip install <package name> and all of the web client files are downloaded pre-compiled as part of the wheel, there is no need for them to run any other command to compile/install the web client. Hope this helps!

@francoisverbeek
Copy link

@ryanc414 Indeed that's what I'm doing now; makes me think that I I forgot to mention above that needed to add two things : add the .env to the MANIFEST.in file and remove the node_modules and other build-time files before doing python setup.py bdist_wheel --universal to keep the size reasonable

@ryanc414
Copy link
Contributor

I don't think you should need to manually remove any node_modules if you specify the path to the build outputs in MANIFEST.in, node_modules are in a separate directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants