Skip to content

Commit

Permalink
Switch from setup.cfg/setup.py to pyproject.toml (#3359)
Browse files Browse the repository at this point in the history
* Update releasing instructions

* Replace setup.py/setup.cfg by pyproject.toml

* Use requirements.in to generate requirements.txt

* Install twine to test the package description

* setuptools-scm includes all versioned files by default

* Pass version to Docker build using build argument

* Read all pip-compile args from toml file

* Remove kinto-redis (removed in #3360)

* Fix phrasing in docs/community.rst

Co-authored-by: grahamalama <gbeckley@mozilla.com>

---------

Co-authored-by: grahamalama <gbeckley@mozilla.com>
  • Loading branch information
leplatrem and grahamalama authored Jan 25, 2024
1 parent 908c774 commit 0028db3
Show file tree
Hide file tree
Showing 12 changed files with 426 additions and 178 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
COVERALLS_FLAG_NAME: ${{ matrix.pyenv }}
COVERALLS_PARALLEL: true
run: |
pip install coveralls
pip install tomli coveralls
coveralls --service=github
finish:
Expand All @@ -111,13 +111,12 @@ jobs:
with:
python-version: "3.x"
- name: Install coveralls
run: pip install coveralls
run: pip install tomli coveralls
- name: Coveralls Finished
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: coveralls --service=github --finish


functional:
name: Functional
needs: lint
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ COPY --from=python-builder /opt/venv /opt/venv
COPY . /app
COPY --from=node-builder /kinto/plugins/admin/build ./kinto/plugins/admin/build

ENV KINTO_INI=/etc/kinto/kinto.ini \
ARG KINTO_VERSION=1
ENV SETUPTOOLS_SCM_PRETEND_VERSION_FOR_KINTO=${KINTO_VERSION} \
KINTO_INI=/etc/kinto/kinto.ini \
PORT=8888 \
PATH="/opt/venv/bin:$PATH"

Expand Down
6 changes: 0 additions & 6 deletions MANIFEST.in

This file was deleted.

16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ help:

all: install
install: $(INSTALL_STAMP)
$(INSTALL_STAMP): $(PYTHON) setup.py requirements.txt setup.cfg
$(INSTALL_STAMP): $(PYTHON) requirements.txt pyproject.toml
$(VENV)/bin/pip install -U pip
$(VENV)/bin/pip install -Ue . -c requirements.txt
touch $(INSTALL_STAMP)
Expand All @@ -55,15 +55,18 @@ install-memcached: $(INSTALL_STAMP) $(DEV_STAMP)
$(VENV)/bin/pip install -Ue ".[memcached]" -c requirements.txt

install-dev: $(INSTALL_STAMP) $(DEV_STAMP)
$(DEV_STAMP): $(PYTHON) dev-requirements.txt
$(VENV)/bin/pip install -Ur dev-requirements.txt
$(DEV_STAMP): $(PYTHON) requirements.txt
$(VENV)/bin/pip install -Ue ".[dev,test]" -c requirements.txt
touch $(DEV_STAMP)

install-docs: $(DOC_STAMP)
$(DOC_STAMP): $(PYTHON) docs/requirements.txt
$(VENV)/bin/pip install -Ur docs/requirements.txt
touch $(DOC_STAMP)

requirements.txt: requirements.in
pip-compile

build-kinto-admin: need-npm
scripts/build-kinto-admin.sh

Expand All @@ -86,7 +89,7 @@ migrate: install $(SERVER_CONFIG)
test: tests
tests-once: tests
tests: install-postgres install-monitoring install-memcached version-file install-dev
$(VENV)/bin/py.test --cov-config setup.cfg --cov-report term-missing --cov-fail-under 100 --cov kinto
$(VENV)/bin/py.test --cov-config pyproject.toml --cov-report term-missing --cov-fail-under 100 --cov kinto

tests-raw: version-file install-dev
$(VENV)/bin/py.test
Expand Down Expand Up @@ -134,9 +137,10 @@ docs: install-docs
@echo
@echo "Build finished. The HTML pages are in $(SPHINX_BUILDDIR)/html/index.html"

.PHONY: build
build:
docker build --pull -t kinto/kinto-server:latest .
docker build --build-arg="KINTO_VERSION=$(shell git describe --abbrev=0)" --pull -t kinto/kinto-server:latest .

test-description: install-dev
$(VENV)/bin/python setup.py bdist_wheel
$(VENV)/bin/python -m build
$(VENV)/bin/twine check dist/*.whl
13 changes: 0 additions & 13 deletions dev-requirements.txt

This file was deleted.

58 changes: 9 additions & 49 deletions docs/community.rst
Original file line number Diff line number Diff line change
Expand Up @@ -274,72 +274,32 @@ There are three levels of cleaning your environment:
How to release
==============

In order to prepare a new release, we are following the following steps.

The ``prerelease`` and ``postrelease`` commands are coming from `zest.releaser
<https://pypi.python.org/pypi/zest.releaser>`_, which should already be
installed along with other development requirements.
In order to prepare a new release, follow these steps:

Step 1
------

- Merge remaining pull requests
- Update ``CHANGELOG.rst``
- Update supported version in ``SECURITY.md``
- Make sure supported version is up-to-date in :file:`SECURITY.md`
- If API was updated, update API changelog in :file:`docs/api/index.rst`
- Make sure ``HTTP_API_VERSION`` is up-to-date in :file:`kinto/__init__.py`
- Update the link in :file:`docs/configuration/production.rst`
- Update the **kinto-admin** version in :file:`kinto/plugins/admin/VERSION` if needed
(`available releases <https://github.com/Kinto/kinto-admin/releases>`_)

- Update :file:`CONTRIBUTORS.rst`. The following hairy command will output the full list:
- Make sure the list of contributors is up-to-date in :file:`CONTRIBUTORS.rst`. The following hairy command will output the full list:

.. code-block:: bash
$ git shortlog -sne | awk '{$1=""; sub(" ", ""); print}' | awk -F'<' '!x[$1]++' | awk -F'<' '!x[$2]++' | sort
- Leverage zest.releaser to update setup file and changelog:

.. code-block:: bash
$ git checkout -b prepare-X.Y.Z
$ make test-description
$ prerelease
- Open a pull-request to release the new version.

.. code-block:: bash
$ git commit -a --amend
$ git push origin prepare-X.Y.Z
Step 2
------

Once the pull-request is approved, merge it and initiate a release.

.. code-block:: bash
$ git checkout main
$ git tag -a X.Y.Z -m "X.Y.Z"
$ git push origin X.Y.Z
With this tag push, a Github Action will take care of publishing the package on Pypi.
1. Create a release on Github on https://github.com/Kinto/kinto-attachment/releases/new
2. Create a new tag `X.Y.Z` (*This tag will be created from the target when you publish this release.*)
3. Generate release notes
4. Publish release

Step 3
------

As a final step:

- Add entry in GitHub releases page
- Check that the version in ReadTheDocs is up-to-date
- Check that a Pypi package was built
- Check that the version in ReadTheDocs was published
- Check that a Pypi package was published
- Tweet about it!

You can now use the ``postrelease`` command to add a new empty section in the changelog and bump the next version with a ``.dev0`` suffix.


.. note::

Dependabot will take care of upgrading the ``kinto`` package via pull-requests on the various repositories of the Kinto ecosystem.
2 changes: 1 addition & 1 deletion docs/configuration/production.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ adjustments:
.. note::

For an exhaustive list of available settings and their default values,
refer to the *Kinto* `source code <https://github.com/Kinto/kinto/blob/13.6.2/kinto/core/__init__.py#L34-L103>`_.
refer to the *Kinto* `source code <https://github.com/Kinto/kinto/blob/main/kinto/core/__init__.py>`_.


By default, nobody can read buckets list. You can change that using:
Expand Down
104 changes: 104 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,107 @@
[project]
dynamic = ["version", "readme"]
name = "kinto"
description = "Kinto Web Service - Store, Sync, Share, and Self-Host."
license = {file = "LICENSE"}
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
"License :: OSI Approved :: Apache Software License",
]
keywords = ["web", "sync", "json", "storage", "services"]
authors = [
{name = "Mozilla Services", email = "developers@kinto-storage.org"},
]
dependencies = [
"bcrypt",
"colander",
"cornice",
"cornice_swagger",
"dockerflow",
"jsonschema",
"jsonpatch",
"logging-color-formatter",
"python-dateutil",
"pyramid",
"pyramid_mailer",
"pyramid_multiauth",
"transaction",
"pyramid_tm",
"requests",
"waitress",
"python-rapidjson",
]

[project.urls]
Repository = "https://github.com/Kinto/kinto"

[project.scripts]
kinto = "kinto.__main__:main"

[project.entry-points."paste.app_factory"]
main = "kinto:main"

[tool.setuptools.packages.find]
include = ["kinto"]

[tool.setuptools.dynamic]
readme = {file = ["README.rst", "CONTRIBUTORS.rst"]}

[tool.setuptools_scm]
# can be empty if no extra settings are needed, presence enables setuptools_scm

[build-system]
requires = ["setuptools>=64", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"

[project.optional-dependencies]
redis = [
"kinto_redis",
]
memcached = [
"python-memcached",
]
postgresql = [
"SQLAlchemy < 3",
"psycopg2",
"zope.sqlalchemy",
]
monitoring = [
"newrelic",
"sentry-sdk[sqlalchemy]",
"statsd",
"werkzeug",
]
test = [
"bravado",
"pytest",
"pytest-cache",
"pytest-cov",
"selenium",
"webtest",
]
dev = [
"build",
"ruff",
"twine",
]

[tool.pip-tools]
# Pip does not support installing in editable mode with hashes.
generate-hashes = false
# Pip does not support extras in constraints.
strip-extras = true

[tool.coverage.run]
branch = true

[tool.ruff]
line-length = 99
extend-exclude = [
Expand Down
40 changes: 40 additions & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# main dependencies
bcrypt
colander
cornice
cornice_swagger
dockerflow
jsonschema
jsonpatch
logging-color-formatter
python-dateutil
pyramid
pyramid_mailer
pyramid_multiauth
transaction
pyramid_tm
requests
waitress
python-rapidjson
# optional dependencies
# memcached
python-memcached
# postgresql
SQLAlchemy < 3
psycopg2
zope.sqlalchemy
# monitoring
newrelic
sentry-sdk[sqlalchemy]
statsd
werkzeug
# test
bravado_core
pytest
pytest-cache
pytest-cov
selenium
webtest
# dev
build
ruff
Loading

0 comments on commit 0028db3

Please sign in to comment.