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

Switch from setup.cfg/setup.py to pyproject.toml #3359

Merged
merged 9 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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
5 changes: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
COVERALLS_FLAG_NAME: ${{ matrix.pyenv }}
COVERALLS_PARALLEL: true
run: |
pip install coveralls
pip install tomli coveralls
coveralls --service=github

finish:
Expand All @@ -106,13 +106,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, we are following the following steps:
leplatrem marked this conversation as resolved.
Show resolved Hide resolved

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious, what is the difference between these dependencies and those listed in pyproject.toml?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This requirements.in is just the "source" of our constraints file.

And the dependencies in pyproject.toml are the final package dependencies (when installed from pip for example).

I will open an issue about that, because I'm not happy about a single requirements.txt as a constraints file, for both our main and our extra 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
Loading