From c1ce285dd93670701dc12f590932a47508e5e41c Mon Sep 17 00:00:00 2001 From: Min RK Date: Sat, 1 Sep 2018 10:05:21 +0200 Subject: [PATCH 1/5] unconditional setuptools in setup.py - simplifies logic - add bdist_egg_disabled to disable implicit eggs - add setup_requires to ensure we have what we need for setup.py building kernelspec from sdist --- setup.py | 92 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 42 deletions(-) diff --git a/setup.py b/setup.py index cd99584dd..aef1b76d0 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,19 @@ import os import shutil -from distutils.core import setup +from setuptools import setup +from setuptools.command.bdist_egg import bdist_egg + + +class bdist_egg_disabled(bdist_egg): + """Disabled version of bdist_egg + + Prevents setup.py install from 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.") + pjoin = os.path.join here = os.path.abspath(os.path.dirname(__file__)) @@ -52,20 +64,39 @@ setup_args = dict( - name = name, - version = version_ns['__version__'], - scripts = glob(pjoin('scripts', '*')), - packages = packages, - py_modules = ['ipykernel_launcher'], - package_data = package_data, - description = "IPython Kernel for Jupyter", - author = 'IPython Development Team', - author_email = 'ipython-dev@scipy.org', - url = 'http://ipython.org', - license = 'BSD', - platforms = "Linux, Mac OS X, Windows", - keywords = ['Interactive', 'Interpreter', 'Shell', 'Web'], - classifiers = [ + name=name, + version=version_ns['__version__'], + cmdclass={ + 'bdist_egg': bdist_egg if 'bdist_egg' in sys.argv else bdist_egg_disabled, + }, + scripts=glob(pjoin('scripts', '*')), + packages=packages, + py_modules=['ipykernel_launcher'], + package_data=package_data, + description="IPython Kernel for Jupyter", + author='IPython Development Team', + author_email='ipython-dev@scipy.org', + url='https://ipython.org', + license='BSD', + platforms="Linux, Mac OS X, Windows", + keywords=['Interactive', 'Interpreter', 'Shell', 'Web'], + python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', + setup_requires=['ipython', 'jupyter_core>=4.2'], + install_requires=[ + 'ipython>=4.0.0', + 'traitlets>=4.1.0', + 'jupyter_client', + 'tornado>=4.0', + ], + extras_require={ + 'test:python_version=="2.7"': ['mock'], + 'test': [ + 'pytest', + 'pytest-cov', + 'nose', # nose because there are still a few nose.tools imports hanging around + ], + }, + classifiers=[ 'Intended Audience :: Developers', 'Intended Audience :: System Administrators', 'Intended Audience :: Science/Research', @@ -76,17 +107,6 @@ ], ) -if 'develop' in sys.argv or any(a.startswith('bdist') for a in sys.argv): - import setuptools - -setuptools_args = {} -install_requires = setuptools_args['install_requires'] = [ - 'ipython>=4.0.0', - 'traitlets>=4.1.0', - 'jupyter_client', - 'tornado>=4.0', -] - if any(a.startswith(('bdist', 'build', 'install')) for a in sys.argv): from ipykernel.kernelspec import write_kernel_spec, make_ipkernel_cmd, KERNEL_NAME @@ -97,24 +117,12 @@ write_kernel_spec(dest, overrides={'argv': argv}) setup_args['data_files'] = [ - (pjoin('share', 'jupyter', 'kernels', KERNEL_NAME), - glob(pjoin('data_kernelspec', '*'))), + ( + pjoin('share', 'jupyter', 'kernels', KERNEL_NAME), + glob(pjoin('data_kernelspec', '*')), + ) ] -setuptools_args['python_requires'] = '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*' - -extras_require = setuptools_args['extras_require'] = { - 'test:python_version=="2.7"': ['mock'], - 'test': [ - 'pytest', - 'pytest-cov', - 'nose', # nose because there are still a few nose.tools imports hanging around - ], -} - -if 'setuptools' in sys.modules: - setup_args.update(setuptools_args) - if __name__ == '__main__': setup(**setup_args) From 0c54f69c69d3aeccd0fe857a91f1a75636ce7be0 Mon Sep 17 00:00:00 2001 From: Min RK Date: Sat, 1 Sep 2018 10:13:05 +0200 Subject: [PATCH 2/5] add release process to CONTRIBUTING.md --- CONTRIBUTING.md | 59 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6b73dbf31..70def38d9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,3 +1,60 @@ # Contributing -We follow the [IPython Contributing Guide](https://github.com/ipython/ipython/blob/master/CONTRIBUTING.md). +Welcome! + +For contributing tips, follow the [Jupyter Contributing Guide](https://jupyter.readthedocs.io/en/latest/contributor/content-contributor.html). +Please make sure to follow the [Jupyter Code of Conduct](https://github.com/jupyter/governance/blob/master/conduct/code_of_conduct.md). + +## Installing ipykernel for development + +ipykernel is a pure Python package, so setting up for development is the same as most other Python projects: + +```bash +# clone the repo +git clone https://github.com/ipython/ipykernel +cd ipykernel +# do a 'development' or 'editable' install with pip: +pip install -e . +``` + +## Releasing ipykernel + +Releasing ipykernel is *almost* standard for a Python package: + +- set version for release +- make and publish tag +- publish release to PyPI +- set version back to development + +The one extra step for ipykernel is that we need to make separate wheels for Python 2 and 3 +because the bundled kernelspec has different contents for Python 2 and 3. + +The full release process is available below: + +```bash +# make sure version is set in ipykernel/_version.py +VERSION="4.9.0" +# commit the version and make a release tag +git add ipykernel/_version.py +git commit -m "release $VERSION" +git tag -am "release $VERSION" $VERSION + +# push the changes to the repo +git push +git push --tags + +# publish the release to PyPI +# note the extra `python2 setup.py bdist_wheel` for creating +# the wheel for Python 2 +pip install --upgrade twine +git clean -xfd +python3 setup.py sdist bdist_wheel +python2 setup.py bdist_wheel # the extra step! +twine upload dist/* + +# set the version back to '.dev' in ipykernel/_version.py +# e.g. 4.10.0.dev if we just released 4.9.0 +git add ipykernel/_version.py +git commit -m "back to dev" +git push +``` From f9c2dececb62e8e858a53e1554138016d248d4ab Mon Sep 17 00:00:00 2001 From: Min RK Date: Sat, 1 Sep 2018 10:19:49 +0200 Subject: [PATCH 3/5] add non-empty long description --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index aef1b76d0..d6ca1fc26 100644 --- a/setup.py +++ b/setup.py @@ -78,6 +78,7 @@ def run(self): author_email='ipython-dev@scipy.org', url='https://ipython.org', license='BSD', + long_description="The IPython kernel for Jupyter", platforms="Linux, Mac OS X, Windows", keywords=['Interactive', 'Interpreter', 'Shell', 'Web'], python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', From 70dab6d00db26d262b9099d77217c067aa425238 Mon Sep 17 00:00:00 2001 From: Min RK Date: Mon, 3 Sep 2018 10:05:29 +0200 Subject: [PATCH 4/5] update setuptools on appveyor maybe this is why it's installing an incompatible IPython? --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 61bca330b..7cdcc34ef 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,7 +18,7 @@ init: - cmd: set PATH=%python%;%python%\scripts;%PATH% install: - cmd: | - python -m pip install --upgrade pip wheel + python -m pip install --upgrade setuptools pip wheel pip --version - cmd: | pip install --pre -e . From 153c0fef86944f267a5e7b998dc6d8acab3af1e1 Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 4 Sep 2018 14:06:32 +0200 Subject: [PATCH 5/5] move setup_requires to pyproject.toml since setup_requires just doesn't work --- MANIFEST.in | 1 + pyproject.toml | 8 ++++++++ setup.py | 1 - 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 pyproject.toml diff --git a/MANIFEST.in b/MANIFEST.in index 90bc61e08..7bcad2d18 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,7 @@ include COPYING.md include CONTRIBUTING.md include README.md +include pyproject.toml # Documentation graft docs diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..e220b587e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,8 @@ +[build-system] +requires=[ + "setuptools", + "wheel", + "ipython>=5", + "jupyter_core>=4.2", + "jupyter_client", +] diff --git a/setup.py b/setup.py index d6ca1fc26..46a3c05ea 100644 --- a/setup.py +++ b/setup.py @@ -82,7 +82,6 @@ def run(self): platforms="Linux, Mac OS X, Windows", keywords=['Interactive', 'Interpreter', 'Shell', 'Web'], python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', - setup_requires=['ipython', 'jupyter_core>=4.2'], install_requires=[ 'ipython>=4.0.0', 'traitlets>=4.1.0',