From 6cf2cf649f505bac1344f9095da5a7ecc49c35b0 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Mon, 19 Apr 2021 12:36:36 +0200 Subject: [PATCH] Upgrade packaging --- .github/workflows/tests.yml | 17 ++++++++- MANIFEST.in | 7 +++- RELEASE.md | 28 ++++++++++++++ jupyterlab_server/_version.py | 5 ++- pyproject.toml | 25 +++++++++++++ setup.cfg | 52 ++++++++++++++++++++------ setup.py | 69 +---------------------------------- setupbase.py | 69 ----------------------------------- 8 files changed, 118 insertions(+), 154 deletions(-) create mode 100644 RELEASE.md create mode 100644 pyproject.toml delete mode 100644 setupbase.py diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d4e51f34..19507d2e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,7 +7,7 @@ defaults: shell: bash -l {0} jobs: - linux: + test: name: ${{ matrix.PLATFORM }} py${{ matrix.PYTHON_VERSION }} runs-on: ${{ matrix.PLATFORM }}-latest env: @@ -59,6 +59,12 @@ jobs: # See `setup.cfg` for full test options run: | pytest --pyargs jupyterlab_server + - name: Check manifest + run: | + set -eux + pip install check-manifest + git clean -dfx + check-manifest -v - name: Upload coverage run: | codecov @@ -67,7 +73,8 @@ jobs: run: | set -eux pip uninstall -y jupyterlab_server - python setup.py sdist + pip install build + python -m build --sdist . cd dist pip install *.tar.gz pytest --pyargs jupyterlab_server @@ -81,3 +88,9 @@ jobs: make html conda deactivate popd + - name: Check Version Bump + run: | + set -eux + pip install tbump + tbump --non-interactive --only-patch 100.1.1 + git checkout . diff --git a/MANIFEST.in b/MANIFEST.in index daed05cb..7c4b27ff 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,9 +1,12 @@ -include README.md +include *.md include LICENSE -include setupbase.py include jupyterlab_server/rest-api.yml include jupyterlab_server/templates/*.html recursive-include jupyterlab_server/tests *.json *.json.orig *.jupyterlab-workspace +recursive-include docs *.* +include docs/Makefile + +prune docs/build # prune translation test data to avoid long path limits on Windows prune jupyterlab_server/tests/translations diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 00000000..545420fe --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,28 @@ +# Making a JupyterLab Server Release +To create a release, perform the following steps... + +## Set up +``` +pip install tbump twine build +git pull origin $(git branch --show-current) +git clean -dffx +``` + +## Update the version and apply the tag +``` +echo "Enter new version" +read script_version +tbump ${script_version} +``` + +## Build the artifacts +``` +rm -rf dist +python -m build . +``` + +## Publish the artifacts to pypi +``` +twine check dist/* +twine upload dist/* +``` diff --git a/jupyterlab_server/_version.py b/jupyterlab_server/_version.py index 1f8501aa..b9c62de1 100644 --- a/jupyterlab_server/_version.py +++ b/jupyterlab_server/_version.py @@ -1,2 +1,3 @@ -version_info = (2, 4, 0) -__version__ = '.'.join(map(str, version_info[:3])) + ''.join(map(str, version_info[3:])) +from jupyter_packaging import get_version_info +__version__ = '2.4.0' +version_info = get_version_info(__version__) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..78b42097 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,25 @@ +[build-system] +requires = ["jupyter_packaging~=0.9", "jupyter_server"] +build-backend = "setuptools.build_meta" + +[tool.check-manifest] +ignore = ["tbump.toml", ".*", "*.yml", "docs/source/api/app-config.rst", "docs/source/changelog.md"] +ignore-bad-ideas = ["jupyterlab_server/tests/translations/**/*.mo"] + +[tool.tbump.version] +current = "2.4.0" +regex = ''' + (?P\d+)\.(?P\d+)\.(?P\d+) + ((?Pa|b|rc|.dev)(?P\d+))? +''' + +[tool.tbump.git] +message_template = "Bump to {new_version}" +tag_template = "v{new_version}" + +[[tool.tbump.file]] +src = "jupyterlab_server/_version.py" + +[tool.pytest.ini_options] +addopts = "--color=yes -s --tb=long -svv --cov jupyterlab_server --cov-report term-missing --cov-report term:skip-covered" +filterwarnings = ["ignore::DeprecationWarning:notebook", "ignore::DeprecationWarning:traitlets"] diff --git a/setup.cfg b/setup.cfg index 381c0abf..514fab5c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,16 +1,44 @@ [metadata] +name = jupyterlab_server +version = attr: jupyterlab_server._version.__version__ +description = A set of server components for JupyterLab and JupyterLab like applications . +long_description = file: README.md +long_description_content_type = text/markdown license_file = LICENSE +author = Jupyter Development Team +author_email = jupyter@googlegroups.com +url = https://jupyter.org +platforms = Linux, Mac OS X, Windows +keywords = jupyter, jupyterlab +classifiers = + Intended Audience :: Developers + Intended Audience :: System Administrators + Intended Audience :: Science/Research + License :: OSI Approved :: BSD License + Programming Language :: Python + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 -[tool:pytest] -addopts = - --color=yes - -s - --tb=long - -svv - --cov jupyterlab_server - --cov-report term-missing - --cov-report term:skip-covered +[options] +zip_safe = False +include_package_data = True +packages = find: +python_requires = >=3.6 +install_requires = + babel + jinja2>=2.10 + json5 + jsonschema>=3.0.1 + jupyter_packaging~=0.9,<2 + packaging + requests + jupyter_server~=1.4 -filterwarnings = - ignore::DeprecationWarning:notebook - ignore::DeprecationWarning:traitlets + +[options.extras_require] +test = codecov; ipykernel; pytest>=5.3.2; pytest-cov; jupyter_server[test]; openapi_core; pytest-console-scripts; strict-rfc3339; ruamel.yaml; wheel + +[options.packages.find] +exclude = ['docs*'] diff --git a/setup.py b/setup.py index a77452a8..8bf1ba93 100644 --- a/setup.py +++ b/setup.py @@ -1,67 +1,2 @@ -#!/usr/bin/env python -# coding: utf-8 - -# Copyright (c) Jupyter Development Team. -# Distributed under the terms of the Modified BSD License. - -from setupbase import create_cmdclass, __version__ -from setuptools import find_packages, setup -import sys - - -setup_args = dict( - name='jupyterlab_server', - version=__version__, - packages=find_packages('.'), - description='JupyterLab Server', - long_description=open('./README.md').read(), - long_description_content_type='text/markdown', - author='Jupyter Development Team', - author_email='jupyter@googlegroups.com', - url='https://jupyter.org', - license='BSD', - platforms='Linux, Mac OS X, Windows', - keywords=['Jupyter', 'JupyterLab'], - cmdclass=create_cmdclass(), - classifiers=[ - 'Intended Audience :: Developers', - 'Intended Audience :: System Administrators', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - ], - include_package_data=True -) - -if 'setuptools' in sys.modules: - setup_args['python_requires'] = '>=3.6' - setup_args['extras_require'] = { - 'test': [ - 'codecov', - 'ipykernel', - 'pytest>=5.3.2', - 'pytest-cov', - 'jupyter_server[test]', - 'openapi_core', - 'pytest-console-scripts', - 'strict-rfc3339', - 'ruamel.yaml', - 'wheel', - ], - } - setup_args['install_requires'] = [ - 'babel', - 'jinja2>=2.10', - 'json5', - 'jsonschema>=3.0.1', - 'packaging', - 'requests', - 'jupyter_server~=1.4', - ] - -if __name__ == '__main__': - setup(**setup_args) +from setuptools import setup +setup() diff --git a/setupbase.py b/setupbase.py deleted file mode 100644 index 41b287d5..00000000 --- a/setupbase.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python -# coding: utf-8 - -# Copyright (c) Jupyter Development Team. -# Distributed under the terms of the Modified BSD License. -import io -import os -from os.path import join as pjoin -from setuptools.command.build_py import build_py -from setuptools.command.sdist import sdist -from setuptools.command.develop import develop -from setuptools.command.bdist_egg import bdist_egg -import sys - -try: - from wheel.bdist_wheel import bdist_wheel -except ImportError: - bdist_wheel = None - - -# --------------------------------------------------------------------------- -# Top Level Variables -# --------------------------------------------------------------------------- - -here = os.path.abspath(os.path.dirname(__file__)) -is_repo = os.path.exists(pjoin(here, '.git')) -name = 'jupyterlab_server' - -version_ns = {} -with io.open(pjoin(here, name, '_version.py'), encoding='utf8') as f: - exec(f.read(), {}, version_ns) -__version__ = version_ns['__version__'] - - -# --------------------------------------------------------------------------- -# Public Functions -# --------------------------------------------------------------------------- - -def create_cmdclass(data_dirs=None): - """Create a command class with the given optional wrappers. - - Parameters - ---------- - wrappers: list(str), optional - The cmdclass names to run before running other commands - data_dirs: list(str), optional. - The directories containing static data. - """ - egg = bdist_egg if 'bdist_egg' in sys.argv else bdist_egg_disabled - cmdclass = dict( - build_py=build_py, - sdist=sdist, - bdist_egg=egg, - develop=develop - ) - if bdist_wheel: - cmdclass['bdist_wheel'] = bdist_wheel - return cmdclass - - -class bdist_egg_disabled(bdist_egg): - """Disabled version of bdist_egg - Prevents setup.py install performing setuptools' default easy_install, - which it should never ever do. - """ - - def run(self): - sys.exit('Aborting implicit building of eggs. Use `pip install .` ' + - ' to install from source.')