Skip to content

Commit

Permalink
Migrate from setup.py to pyproject.toml (#315)
Browse files Browse the repository at this point in the history
* Add npm scripts for building

* Convert project to use hatch jupyter builder

* Replace setup.py jsversion with tbump

* Fix javascript version not consistent with project version

* Update manual release instructions

* Update cache hash key

* Fix issues with build scripts

* Fix hatch-jupyter-build requires Python 3.8+

* Move copy build step to js script

* Apply pyproject-fmt
  • Loading branch information
danyeaw authored Jan 30, 2025
1 parent 4e81dab commit dafc920
Show file tree
Hide file tree
Showing 16 changed files with 258 additions and 946 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-pip-
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
if: startsWith(runner.os, 'Linux')
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python }}-${{ hashFiles('**/requirements.txt', 'setup.py') }}
key: ${{ runner.os }}-pip-${{ matrix.python }}-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-13]
python-version: [ '3.7', '3.8', '3.9', '3.10']
python-version: [ '3.8', '3.9', '3.10', '3.11' ]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-13, windows-2022]
python-version: ["3.7", "3.8", "3.9", "3.10"]
exclude:
- os: ubuntu-22.04
python-version: "3.7"
- os: macos-13
python-version: "3.7"
python-version: [ '3.8', '3.9', '3.10', '3.11' ]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -57,8 +52,8 @@ jobs:
# - name: Base Setup
# uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
# with:
# python_version: "3.7"
# - name: Install miniumum versions
# python_version: "3.8"
# - name: Install minimum versions
# uses: jupyterlab/maintainer-tools/.github/actions/install-minimums@v1
# - name: Run the unit tests
# run: pytest -vv || pytest -vv --lf
Expand Down
50 changes: 0 additions & 50 deletions MANIFEST.in

This file was deleted.

11 changes: 3 additions & 8 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@ yet support "next" or "patch" when dev versions are used.

## Manual Release

To create a release, update the version number in `nbclassic/__version__.py`, then run the following:
To create a release, run the following:

```
git clean -dffx
python setup.py sdist
python setup.py bdist_wheel
export script_version=`python setup.py --version 2>/dev/null`
git commit -a -m "Release $script_version"
git tag $script_version
git push --all
git push --tags
python -m build
tbump <new version number>
pip install twine
twine check dist/*
twine upload dist/*
Expand Down
4 changes: 2 additions & 2 deletions git-hooks/post-checkout
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ if [[
! -z "$(git diff $PREVIOUS_HEAD nbclassic/static/*/js/**.js)"
]]; then
echo "rebuilding javascript"
python setup.py js || echo "fail to rebuild javascript"
npm run build:js || echo "fail to rebuild javascript"
fi

if [[
! -z "$(git diff $PREVIOUS_HEAD nbclassic/static/*/less/**.less)"
]]; then
echo "rebuilding css sourcemaps"
python setup.py css || echo "fail to recompile css"
npm run build:css || echo "fail to recompile css"
fi
4 changes: 2 additions & 2 deletions nbclassic/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
parts.append(match['rest'])
version_info = tuple(parts)

# Downstream maintainer, when running `python.setup.py jsversion`,
# the version string is propagated to the JavaScript files, do not forget to
# Downstream maintainer, when running `tbump <new version>`,
# the version string is propagated to the JavaScript files, do not forget to
# patch the JavaScript files in `.postN` release done by distributions.
2 changes: 1 addition & 1 deletion nbclassic/static/base/js/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ define(function(){
// tree
jglobal('SessionList','tree/js/sessionlist');

Jupyter.version = "1.2.0";
Jupyter.version = "1.3.0.dev0";
Jupyter._target = '_blank';

return Jupyter;
Expand Down
24 changes: 21 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,29 @@
"url": "https://github.com/jupyter/nbclassic.git"
},
"scripts": {
"bower": "bower install",
"build": "python setup.py js css",
"bower:copy-marked": "node tools/copy-marked.js",
"bower": "bower install && npm run bower:copy-marked",
"build:webpack": "webpack --mode production",
"build:notebook": "node tools/build-main.js notebook",
"build:tree": "node tools/build-main.js tree",
"build:edit": "node tools/build-main.js edit",
"build:terminal": "node tools/build-main.js terminal",
"build:auth": "node tools/build-main.js auth",
"build:fr-translation": "po2json -p -F -f jed1.x -d nbjs nbclassic/i18n/fr_FR/LC_MESSAGES/nbjs.po nbclassic/i18n/fr_FR/LC_MESSAGES/nbjs.json",
"build:ja-translation": "po2json -p -F -f jed1.x -d nbjs nbclassic/i18n/ja_JP/LC_MESSAGES/nbjs.po nbclassic/i18n/ja_JP/LC_MESSAGES/nbjs.json",
"build:nl-translation": "po2json -p -F -f jed1.x -d nbjs nbclassic/i18n/nl/LC_MESSAGES/nbjs.po nbclassic/i18n/nl/LC_MESSAGES/nbjs.json",
"build:ru-translation": "po2json -p -F -f jed1.x -d nbjs nbclassic/i18n/ru_RU/LC_MESSAGES/nbjs.po nbclassic/i18n/ru_RU/LC_MESSAGES/nbjs.json",
"build:zh-translation": "po2json -p -F -f jed1.x -d nbjs nbclassic/i18n/zh_CN/LC_MESSAGES/nbjs.po nbclassic/i18n/zh_CN/LC_MESSAGES/nbjs.json",
"build:translations": "npm run build:fr-translation && npm run build:ja-translation && npm run build:nl-translation && npm run build:ru-translation && npm run build:zh-translation",
"build:js": "npm run build:notebook && npm run build:tree && npm run build:edit && npm run build:terminal && npm run build:auth && npm run build:translations",
"build:css-ipython": "lessc --source-map --include-path='nbclassic/static/style' nbclassic/static/style/ipython.less nbclassic/static/style/ipython.min.css",
"build:css-style": "lessc --source-map --include-path='nbclassic/static/style' nbclassic/static/style/style.less nbclassic/static/style/style.min.css",
"build:css": "npm run build:css-ipython && npm run build:css-style",
"build": "npm run bower && npm run build:webpack && npm run build:js && npm run build:css",
"build:watch": "npm run watch",
"watch": "onchange 'nbclassic/static/**/!(*.min).js' 'nbclassic/static/**/*.less' 'bower.json' -- npm run build"
"watch:css": "onchange 'nbclassic/static/**/*.less' -- npm run build:css",
"watch:js": "onchange 'nbclassic/static/**/!(*.min).js' 'bower.json' -- npm run build:js",
"watch": "npm-run-all --parallel watch:*"
},
"devDependencies": {
"@babel/core": "^7.15.0",
Expand Down
Loading

0 comments on commit dafc920

Please sign in to comment.