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

Properly package the canonicaljson module #52

Merged
merged 8 commits into from
Sep 23, 2022
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
8 changes: 2 additions & 6 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
include *.in
include *.py
prune .github
include *.md
babolivier marked this conversation as resolved.
Show resolved Hide resolved
include LICENSE
include tox.ini
include pyproject.toml
Comment on lines -4 to -6
Copy link
Contributor

Choose a reason for hiding this comment

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

These both seem like good things to include in the sdist. Are they included automatically now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per #synapse-dev, it looks like python -m build always includes all files from the repository by default when run on my machine, not sure why.

According to https://packaging.python.org/en/latest/guides/using-manifest-in/, pyproject.toml is automatically included now. I've also added the license file to license_file in setup.cfg since it seems like that will always cause it to be included.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've now replaced the content of MANIFEST.in with the suggestion from check-manifest. The only exception to this is that I've added a prune .github to remove GitHub codeowner and workflow files, which felt to me like they shouldn't live in the sdist.

prune .travis
prune debian
recursive-include tests *.py
babolivier marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ show_error_codes = true
strict = true

files = ["."]
exclude = "setup.py"

[build-system]
requires = [
"setuptools >= 35.0.2",
"setuptools_scm >= 2.0.0, <3"
]
build-backend = "setuptools.build_meta"
4 changes: 2 additions & 2 deletions releasing.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Releasing python-canonicaljson
==============================

* bump version in `canonicaljson.py`
* bump version in `src/canonicaljson/__init__.py`
* update changelog
* Build and upload to pypi:
* `rm -r dist`
* `python setup.py sdist bdist_wheel`
* `python -m build`
* `twine upload -s dist/*`
* `git tag -s v<ver>`
* `git push`
Expand Down
46 changes: 46 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
[metadata]
name = canonicaljson
description = Canonical JSON
long_description = file: README.rst
long_description_content_type = text/x-rst
version = attr: canonicaljson.__version__
keywords = json
url = https://github.com/matrix-org/python-canonicaljson
license = Apache License, Version 2.0
author = Matrix.org Team and Contributors
author_email = [email protected]
license_file = LICENSE
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
License :: OSI Approved :: Apache Software License
Programming Language :: Python :: 2
Programming Language :: Python :: 3


[options]
zip_safe = true
python_requires = >=3.7

package_dir = =src
packages =
canonicaljson

install_requires =
# simplejson versions before 3.14.0 had a bug with some characters
# (e.g. \u2028) if ensure_ascii was set to false.
simplejson>=3.14.0
# typing.Protocol was only added to the stdlib in Python 3.8
typing_extensions>=4.0.0; python_version < '3.8'


[options.extras_require]
# frozendict support can be enabled using the `canonicaljson[frozendict]` syntax
frozendict =
frozendict>=1.0


[options.package_data]
canonicaljson = py.typed


[flake8]
# see https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
# for error codes. The ones we ignore are:
Expand Down
74 changes: 0 additions & 74 deletions setup.py

This file was deleted.

3 changes: 1 addition & 2 deletions canonicaljson.py → src/canonicaljson/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-

# Copyright 2014 OpenMarket Ltd
# Copyright 2018 New Vector Ltd
# Copyright 2022 The Matrix.org Foundation C.I.C.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Empty file added src/canonicaljson/py.typed
Empty file.
13 changes: 13 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2022 The Matrix.org Foundation C.I.C.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
3 changes: 1 addition & 2 deletions test_canonicaljson.py → tests/test_canonicaljson.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright 2015 OpenMarket Ltd
# Copyright 2018 New Vector Ltd
# Copyright 2022 The Matrix.org Foundation C.I.C.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
10 changes: 6 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[tox]
envlist = packaging, pep8, black, py37, py38, py39, py310, pypy3
isolated_build = True

[testenv]
[testenv:py]
deps =
coverage
nose2
Expand All @@ -19,20 +20,21 @@ commands = check-manifest
basepython = python3.7
deps =
flake8
commands = flake8 .
commands = flake8 src tests

[testenv:black]
basepython = python3.7
deps =
black==21.9b0
# Workaround black+click incompatability, see https://github.com/psf/black/issues/2964
click==8.0.4
commands = python -m black --check --diff .
commands = python -m black --check --diff src tests

[testenv:mypy]
deps =
mypy==0.942
types-frozendict==2.0.8
types-simplejson==3.17.5
types-setuptools==57.4.14
commands = mypy
commands = mypy src tests