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

Better releases #593

Merged
merged 14 commits into from
May 24, 2017
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,18 @@
We follow the
[Jupyter Contribution Workflow](https://jupyter.readthedocs.io/en/latest/contributor/content-contributor.html)
and the [IPython Contributing Guide](https://github.com/ipython/ipython/blob/master/CONTRIBUTING.md).

# Testing

In order to test all the features of nbconvert you need to have `pandoc` and
`TexLive` installed.

In your environment `pip install nbconvert[all]` will be needed to be able to
run all of the tests and to test all of the features.

If you only want to run some of the tests run `pip install nbconvert[test]`.

# Releasing

If you are going to release a version of `nbconvert` you should also be capable
of testing it. Please follow the instructions in [Testing](#testing).
80 changes: 80 additions & 0 deletions docs/source/development_release.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
.. _nbconvert_release:

Making an ``nbconvert`` release
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked a built copy of this? I can't remember if backticks in headings work.

Copy link
Member Author

@mpacer mpacer May 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they do work.

===============================

This document guides a contributor through creating a release of ``nbconvert``.


Assign all merged PRs to milestones
-----------------------------------

Go to GitHub and assign all PRs that have been merged to milestones.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea.

This will be helpful when you update the changelog.

Check installed tools
---------------------

Review ``CONTRIBUTING.md``, particularly the testing and release sections.

Clean the repository
--------------------

You can remove all non-tracked files with:

.. code:: bash

git clean -xfdi

This would ask you for confirmation before removing all untracked files.

Make sure the ``dist/`` folder is clean and avoid stale builds from
previous attempts.

Create the release
------------------

#. Update the changelog to account for all the PRs assigned to this milestone.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this explicitly mention where the changelog file is?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relative to the top level? or relative to the location of this file?


#. Update version number in ``notebook/_version.py``.

#. Commit and tag the release with the current version number:

.. code:: bash

git commit -am "release $VERSION"
git tag $VERSION

#. You are now ready to build the ``sdist`` and ``wheel``:

.. code:: bash

python setup.py sdist
python setup.py bdist_wheel

#. You can now test the ``wheel`` and the ``sdist`` locally before uploading
to PyPI. Make sure to use `twine <https://github.com/pypa/twine>`_ to
upload the archives over SSL.

.. code:: bash

twine upload dist/*

Release the new version
-----------------------

#. Push directly on master, including --tags separately

.. code:: bash

git push upstream
git push upstream --tags

#. Push tages on master forgetting to push ``--tags`` too.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a confused copy of the point immediately above?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes i think I was in the middle of splitting one thing in the original notebook, but then realised that I could just have the raw code as two lines.



Return to development state
---------------------------

#. If all went well, change the ``notebook/_version.py`` back adding the
``.dev`` suffix.
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ batch of notebook files to another format.

architecture
api/index
development_release

.. toctree::
:maxdepth: 2
Expand Down
9 changes: 7 additions & 2 deletions nbconvert/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
version_info = (5, 2, 0,'.dev')
__version__ = '.'.join(map(str, version_info[0:3])) + ''.join(version_info[3:])
from nbconvert._version_tools import create_valid_version

version_info = (5, 2, 0)
pre_info = ''
dev_info = '.dev'
__version__ = create_valid_version(version_info, pre_input=pre_info, dev_input=dev_info)

83 changes: 83 additions & 0 deletions nbconvert/_version_tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# import pep440 # cannot be imported as described below
import re
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file looks like it's copied from somewhere - can we have a comment at the top clearly saying where, including what version (or commit, if necessary)? We may also need to include a copyright notice and license text.

Copy link
Member Author

@mpacer mpacer May 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's @Carreau's pep440, github (to which you've committed, which is why I assumed this would be caught), we can add a copyright notice if you like. Basically I'd just use it directly but for the fact that it can't be built with setuptools. That seemed like it was a design choice and if not I was going to make a PR today.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I should mention I thought that I had included that comment at the top and in the main text, I guess the only thing that's missing is a github link I will fix that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, put an explicit Github link and a commit ID, for good measure.

I don't personally mind about the copyright notice & license text, and @Carreau may well not mind either. In general, though, if we're including code from another project, we should include those things - it's a typical condition of the licenses which allow you to redistribute that code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may also just copy past the is_cannonical from pep 440 itself that was added recently to make this kind of things easier.

I'll make my pep440 easier to vendor.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it from pep440 itself Appendix B.


def create_valid_version(release_info, epoch=None, pre_input='', dev_input=''):
'''
Creates a pep440 valid version of version number given a tuple integers
and optional epoch, prerelease and developmental info.

Parameters
----------
release_info : Tuple(Int)
epoch : Int, default None
pre_input : Str, default ''
dev_input : Str, default ''
'''

pep440_err = "The version number is not a pep 440 compliant version number"


if epoch is not None:
epoch_seg = str(epoch) + '!'
else:
epoch_seg = ''

release_seg = '.'.join(map(str, release_info))

_magic_pre = ['a','b','rc']
if pre_input!='' and not any([pre_input.startswith(prefix) for prefix in _magic_pre]):
raise ValueError(pep440_err + "\n please fix your prerelease segment.")
else:
pre_seg = pre_input

if dev_input=='':
dev_seg = dev_input
elif not dev_input.startswith('.') and dev_input.startswith('dev'):
dev_seg = ''.join(['.', dev_input])
elif dev_input.startswith('.dev'):
dev_seg = dev_input
elif dev_input!='':
raise ValueError(pep440_err + "\n please fix your development segment.")

if dev_input!='' and not any([dev_seg.endswith(str(n)) for n in range(10)]):
dev_seg = ''.join([dev_seg,'0'])

out_version = ''.join([epoch_seg, release_seg, pre_seg, dev_seg])

if is_canonical(out_version):
return out_version
else:
raise ValueError(pep440_err)

# This has been ported directly from the pep440 package since it cannot be
# installed as part of a setuptools based install without using pyproject.toml

posint = '(0|[1-9]\d*)'

# 0!0.0.0rc0.post0.dev0

tpl_string_re = ('^' # Start
'([1-9]\d*!)?' # [N!]
'{posint}' # N
'(\.{posint})*' # (.N)*
'((a|b|rc){posint})?' # [{a|b|rc}N]
'(\.post{posint})?' # [.postN]
'(\.dev{postdev})?' # [.devN]
'$')
string_re = tpl_string_re.format(posint=posint, postdev=posint)
loose440re = re.compile(tpl_string_re.format(posint=posint, postdev=(posint+'?')))
pep440re = re.compile(string_re)

def is_canonical(version, loosedev=False):
"""
Return whether or not the version string is canonical according to Pep 440
"""
if loosedev:
return loose440re.match(version) is not None
return pep440re.match(version) is not None


# this is the end of the direct port from pep440



11 changes: 9 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,20 @@ def run(self):
'testpath',
]

extras_require = setuptools_args['extras_require'] = {
extra_requirements = {
# FIXME: tests still require nose for some utility calls,
# but we are running with pytest
'test': ['pytest', 'pytest-cov', 'nose', 'ipykernel', 'jupyter_client'],
'test': ['pytest', 'pytest-cov', 'nose', 'ipykernel', 'jupyter_client>=4.2'],
'serve': ['tornado>=4.0'],
'execute': ['jupyter_client>=4.2'],
}
s = []
[s.extend(values) for values in extra_requirements.values()]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like using list comprehensions for side effects. I'd either do this with a regular for loop:

for reqs in extra_requirements.values():
    s.extend(reqs)

Or get clever with sum:

s = sum(extra_requirements.values(), [])

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not know that sum could be applied to lists. I'm intrigued because that could allow: extra_requirements['all'] = sum(extra_requirements.values(), []). Which is perhaps a bit too clever but totally does the trick.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I think that would be OK.

I believe that sum can accept anything which you can combine with the + operator. If you're not using it for numbers, though, you need to give the second argument for the starting value.

extra_requirements['all'] = list(set(s))

extras_require = setuptools_args['extras_require'] = {
**extra_requirements
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax is new in Python 3.5. If we need a copy of the dictionary, I think extra_requirements.copy() should work. I'm not sure that we do need a copy, though - I think you can just set them to the same object.

}

if 'setuptools' in sys.modules:
from setuptools.command.develop import develop
Expand Down