-
Notifications
You must be signed in to change notification settings - Fork 87
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
Use jupyter-packaging for npm build #211
Conversation
650890f
to
bcf9873
Compare
@manics nice!!! This looks great! Do we need to update MANIFEST.in somehow? This is the current MANIFEST.in file. I consider pyproject.toml and/or package.json
UPDATE: I think I've concluded that we should not include pyporject.toml or package.json, but we should use a try/catch block within setup.py as I note in a comment below. |
from jupyter_packaging import wrap_installers, npm_builder | ||
from setuptools import find_packages, setup | ||
from distutils.util import convert_path | ||
import subprocess | ||
import os.path | ||
|
||
HERE = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
# Representative files that should exist after a successful build | ||
jstargets = [ | ||
os.path.join(HERE, "nbgitpuller", "static", "dist", "bundle.js"), | ||
] | ||
|
||
# https://github.com/jupyter/jupyter-packaging/blob/0.10.4/README.md#as-a-build-requirement | ||
jsdeps = npm_builder(build_cmd="webpack") | ||
cmdclass = wrap_installers( | ||
pre_develop=jsdeps, pre_dist=jsdeps, | ||
ensured_targets=jstargets, skip_if_exists=jstargets) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should wrap this in a try catch block, so that you don't assume jupyter_packaging to be available.
See this example from the jupyter_packaging readme file https://github.com/jupyter/jupyter-packaging#as-a-build-requirement
I'm thinking that if we have built the package so that the bundle.js stuff is available, then we are fine. If we on the other hand just want to install things from a package source distribution, we don't need pyproject.toml, package.json, or anything - we just need the bundle to be available and keep working as normal in setup.py.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally followed the example, but that means setup.py can silently ignores the js build which didn't seem particularly great.
It looks like pyproject.toml
is included anyway in the sdist (at least it is when I tested locally, and pip install ~/path/to/nbgitpuller/dist/nbgitpuller-1.0.1.dev0.tar.gz
works without errors).
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Long discussion here which I don't fully understand pypa/setuptools#1650
... but it looks like this project assumes pep517 anyway
nbgitpuller/.github/workflows/publish.yml
Line 27 in 4ffd009
python -m build --sdist --wheel . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice investigation @manics! Okay my understanding now:
- pyproject.toml will always ship with the source when we package the source with
build --sdist --wheel .
This means thatjupyter_packaging
can be assumed in setup.py, so we don't need to wrap the import statement etc in a try block. - The nbgitpuller/static/dist content will also be shipped, and jupyter_packaging will not attempt to do a npm setup unless bundle.js isn't around anyhow because of
skip_if_exists=jstargets
. This means that we currently can dopip install .
from the source file. If you on the other hand wants to rebuild the bundle.js file you won't be able to do so because then we miss package.json. I've verified this part.
I suggest we include package.json in our MANIFEST.in file as part of this PR.
I can't make a convenient code suggestion about that so I pushed a commit. If it LGTY also @manics then go for a merge! This LGTM now!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks @manics for fixing the mess I've created 😬
This looks good to me too and I think we should merge it and release a new version as soon as possible.
P.S. jupyter-packaging
seems very cool and I wish I knew about it before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - note that I pushed a commit to include package.json in the source distribution!
Sounds fine to me! What's everyone's thoughts on switching to setuptools-scm in a follow-up PR? Main benefits include:
|
Is the version in Line 3 in 4ffd009
|
@manics I don't yet understand the tool, but I react with aversion of it because of how I perceive it to increase the complexity of things given that one need to understand what it does. Sometimes, it's fine to not need to understand how things work, but we just come out of a situation where we needed to understand the details of this. I think unless we look to automate everything in the release process to a single button click or similar, then I'd like to accept the work of following the current RELEASE.md procedure. Regarding package.json's version, I noted that being outdated as well and submitted #212. |
Thanks @manics!!!
We all had to learn more about this complexity, and thanks to your efforts to move this onwards we arrived in a situation were we realized that! Thank you for your work @GeorgianaElena! Without your work, the JMTE hub's user image failed btw, so it also had a direct value to JMTE. |
This is one possible way of solving #210
Needs some testing.
Closes #210