diff --git a/.copier-answers.yml b/.copier-answers.yml
new file mode 100644
index 0000000000000000000000000000000000000000..2d053422340ab63fe68f8a6d5a24723a45e995bc
--- /dev/null
+++ b/.copier-answers.yml
@@ -0,0 +1,11 @@
+# Changes here will be overwritten by Copier
+_commit: v0.1.5
+_src_path: https://gitlab.softwareheritage.org/swh/devel/swh-py-template.git
+description: Software Heritage deposit server
+distribution_name: swh-deposit
+have_cli: true
+have_workers: true
+package_root: swh/deposit
+project_name: swh.deposit
+python_minimal_version: '3.7'
+readme_format: rst
diff --git a/.gitignore b/.gitignore
index 52e95c367fba61a76449ebcafb36f31c15251786..035b13951e98580e45e6b453c2bb6fa9aef9a59f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,26 +1,12 @@
+*.egg-info/
 *.pyc
-*.sw?
-*~
-/.coverage
-/.coverage.*
+.coverage
 .eggs/
+.hypothesis
+.mypy_cache
+.tox
 __pycache__
-*.egg-info/
-version.txt
 build/
 dist/
-/analysis.org
-/swh/deposit/fixtures/private_data.yaml
-/swh/deposit.json
-/test.json
-/swh/test
-db.sqlite3
-/.noseids
-*.tgz
-*.zip
-*.tar.gz
-*.tar.bz2
-*.tar.lzma
-.tox/
-.mypy_cache/
-.hypothesis/
+docs/README.rst
+docs/README.md
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 4b2ba24d114f9be8e37f46aa159fad822b018e94..6dd3da15e9c2076606f7bdde40c76bd258e68631 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -2,14 +2,24 @@ exclude: ^swh/deposit/tests/data/atom/.*$
 
 repos:
   - repo: https://github.com/pre-commit/pre-commit-hooks
-    rev: v4.3.0
+    rev: v4.4.0
     hooks:
       - id: trailing-whitespace
       - id: check-json
       - id: check-yaml
 
+  - repo: https://github.com/python/black
+    rev: 23.1.0
+    hooks:
+      - id: black
+
+  - repo: https://github.com/PyCQA/isort
+    rev: 5.12.0
+    hooks:
+      - id: isort
+
   - repo: https://github.com/pycqa/flake8
-    rev: 5.0.4
+    rev: 6.0.0
     hooks:
       - id: flake8
         additional_dependencies: [flake8-bugbear==22.9.23]
@@ -32,12 +42,3 @@ repos:
         language: system
         types: [python]
 
-  - repo: https://github.com/PyCQA/isort
-    rev: 5.11.5
-    hooks:
-      - id: isort
-
-  - repo: https://github.com/python/black
-    rev: 22.10.0
-    hooks:
-      - id: black
diff --git a/MANIFEST.in b/MANIFEST.in
deleted file mode 100644
index 03d5ef9def111754393c3c27a2ab92f76fd98fdb..0000000000000000000000000000000000000000
--- a/MANIFEST.in
+++ /dev/null
@@ -1,12 +0,0 @@
-include Makefile
-include requirements*.txt
-include version.txt
-recursive-include swh/deposit/static *
-recursive-include swh/deposit/fixtures *
-recursive-include swh/deposit/templates *
-recursive-include swh/deposit/tests/data *
-recursive-include swh/deposit/tests/*/data *
-recursive-include swh/deposit/xsd *
-recursive-include swh py.typed
-include tox.ini
-include pytest.ini
diff --git a/docs/.gitignore b/docs/.gitignore
index e379dea113fe837073c036ddca9838eb9606a2a2..58a761ead8c3be489f0e4738fac8d2173656ea7f 100644
--- a/docs/.gitignore
+++ b/docs/.gitignore
@@ -1,4 +1,3 @@
 _build/
 apidoc/
 *-stamp
-
diff --git a/docs/Makefile b/docs/Makefile
index ac10d52b69f8982f77439a86ab82cc91562f3a41..3437a48778a2638e4beaed2e9e61e9e976c20de1 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -1,4 +1,4 @@
-include ../../swh-docs/Makefile.sphinx
+include swh-docs/Makefile.sphinx
 
 APIDOC_EXCLUDES += ../swh/*/settings/*
 
diff --git a/mypy.ini b/mypy.ini
index 360983431d8c48c127ac7d56efbb017a7a60fedf..5f6c72d65eb3d28f996424baf90cc0be2f1f10b8 100644
--- a/mypy.ini
+++ b/mypy.ini
@@ -9,6 +9,9 @@ plugins = mypy_django_plugin.main
 [mypy.plugins.django-stubs]
 django_settings_module = swh.deposit.settings.testing
 
+explicit_package_bases = True
+# ^ Needed for mypy to detect py.typed from swh packages installed
+# in editable mode
 
 # 3rd party libraries without stubs (yet)
 
@@ -24,9 +27,6 @@ ignore_missing_imports = True
 [mypy-psycopg2.*]
 ignore_missing_imports = True
 
-[mypy-pytest.*]
-ignore_missing_imports = True
-
 [tenacity.*]
 ignore_missing_imports = True
 
diff --git a/pyproject.toml b/pyproject.toml
index 69b8f4dd830abf638e624eeea85dbc580c862538..0cc46a0fd9cd039108ec359f25133b556a4c9c81 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,3 +1,57 @@
+[project]
+name = "swh.deposit"
+authors = [
+    {name="Software Heritage developers", email="swh-devel@inria.fr"},
+]
+
+description = "Software Heritage deposit server"
+readme = {file = "README.rst", content-type = "text/x-rst"}
+requires-python = ">=3.7"
+classifiers = [
+    "Programming Language :: Python :: 3",
+    "Intended Audience :: Developers",
+    "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
+    "Operating System :: OS Independent",
+    "Development Status :: 5 - Production/Stable",
+]
+dynamic = ["version", "dependencies", "optional-dependencies"]
+
+[tool.setuptools.packages.find]
+include = ["swh.*"]
+
+[tool.setuptools.dynamic]
+dependencies = {file = ["requirements.txt", "requirements-swh.txt"]}
+
+[tool.setuptools.dynamic.optional-dependencies]
+server = {file = ["requirements-server.txt", "requirements-swh-server.txt"]}
+azure = {file = ["requirements-azure.txt"]}
+testing = {file = [
+    "requirements-test.txt",
+    "requirements-server.txt",
+    "requirements-swh-server.txt",
+    "requirements-azure.txt",
+    ]}
+
+[project.entry-points."swh.cli.subcommands"]
+"swh.deposit" = "swh.deposit.cli"
+
+[project.entry-points."swh.workers"]
+"swh.deposit" = "swh.deposit.loader:register"
+
+[project.urls]
+"Homepage" = "https://gitlab.softwareheritage.org/swh/devel/swh-deposit"
+"Bug Reports" = "https://gitlab.softwareheritage.org/swh/devel/swh-deposit/-/issues"
+"Funding" = "https://www.softwareheritage.org/donate"
+"Documentation" = "https://docs.softwareheritage.org/devel/swh-deposit/"
+"Source" = "https://gitlab.softwareheritage.org/swh/devel/swh-deposit.git"
+
+[build-system]
+requires = ["setuptools", "setuptools-scm"]
+build-backend = "setuptools.build_meta"
+
+[tool.setuptools_scm]
+fallback_version = "0.0.1"
+
 [tool.black]
 target-version = ['py37']
 
diff --git a/setup.py b/setup.py
deleted file mode 100755
index 68d33153c732def5dff61c7fd8799755ffc0967f..0000000000000000000000000000000000000000
--- a/setup.py
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/usr/bin/env python3
-# Copyright (C) 2015-2021  The Software Heritage developers
-# See the AUTHORS file at the top-level directory of this distribution
-# License: GNU General Public License version 3, or any later version
-# See top-level LICENSE file for more information
-
-from io import open
-from os import path
-
-from setuptools import find_packages, setup
-
-here = path.abspath(path.dirname(__file__))
-
-# Get the long description from the README file
-with open(path.join(here, "README.rst"), encoding="utf-8") as f:
-    long_description = f.read()
-
-
-def parse_requirements(*names):
-    requirements = []
-    for name in names:
-        if name:
-            reqf = "requirements-%s.txt" % name
-        else:
-            reqf = "requirements.txt"
-
-        if not path.exists(reqf):
-            return requirements
-
-        with open(reqf) as f:
-            for line in f.readlines():
-                line = line.strip()
-                if not line or line.startswith("#"):
-                    continue
-                requirements.append(line)
-    return requirements
-
-
-setup(
-    name="swh.deposit",
-    description="Software Heritage Deposit Server",
-    long_description=long_description,
-    long_description_content_type="text/markdown",
-    python_requires=">=3.7",
-    author="Software Heritage developers",
-    author_email="swh-devel@inria.fr",
-    url="https://forge.softwareheritage.org/source/swh-deposit/",
-    packages=find_packages(),
-    install_requires=parse_requirements(None, "swh"),
-    tests_require=parse_requirements("test"),
-    setup_requires=["setuptools-scm"],
-    use_scm_version=True,
-    extras_require={
-        "testing": parse_requirements("test", "server", "swh-server"),
-        "server": parse_requirements("server", "swh-server"),
-        "azure": parse_requirements("azure"),
-    },
-    include_package_data=True,
-    entry_points="""
-        [console_scripts]
-        swh-deposit=swh.deposit.cli:main
-        [swh.cli.subcommands]
-        deposit=swh.deposit.cli
-        [swh.workers]
-        deposit.worker=swh.deposit.loader:register
-    """,
-    classifiers=[
-        "Programming Language :: Python :: 3",
-        "Intended Audience :: Developers",
-        "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
-        "Operating System :: OS Independent",
-        "Development Status :: 5 - Production/Stable",
-    ],
-    project_urls={
-        "Bug Reports": "https://forge.softwareheritage.org/maniphest",
-        "Funding": "https://www.softwareheritage.org/donate",
-        "Source": "https://forge.softwareheritage.org/source/swh-deposit",
-        "Documentation": "https://docs.softwareheritage.org/devel/swh-deposit/",
-    },
-)
diff --git a/swh/__init__.py b/swh/__init__.py
deleted file mode 100644
index b36383a61027f0875a3cb103edc8f2a4528a3289..0000000000000000000000000000000000000000
--- a/swh/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from pkgutil import extend_path
-
-__path__ = extend_path(__path__, __name__)
diff --git a/tox.ini b/tox.ini
index 52e042f0b4e6ec3893d2b31aa0176ad70fc9fe53..69fc39f8ba6cb0ced1901d4a0d555262d604a1b6 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,7 +1,11 @@
 [tox]
-requires =
-  tox>4
-envlist=flake8,mypy,py3-django2,py3-django3
+minversion = 4
+envlist =
+  black
+  flake8
+  mypy
+  py3-django2
+  py3-django3
 
 [testenv]
 extras =
@@ -16,10 +20,16 @@ deps =
   django2: Django>=2,<3
   django3: Django>=3,<4
 commands =
-  pytest \
-  !dev: --cov {envsitepackagesdir}/swh/deposit --cov-branch \
-        {envsitepackagesdir}/swh/deposit \
-        {posargs}
+  pytest --doctest-modules \
+         --import-mode importlib \
+         --rootdir {envsitepackagesdir} \
+         --cov={envsitepackagesdir}/swh/deposit \
+         --cov-branch \
+         {envsitepackagesdir}/swh/deposit \
+         {posargs}
+# --rootdir and --import-mode are required to make tests that depends
+# on the test file to be a proper submodule of the swh namespace after
+# migration to PEP420 (implicit namespace).
 
 [testenv:black]
 skip_install = true
@@ -52,32 +62,14 @@ commands =
 # breaking doc build
 [testenv:sphinx]
 allowlist_externals = make
-usedevelop = true
 extras =
   testing
 deps =
-  # fetch and install swh-docs in develop mode
-  -e git+https://gitlab.softwareheritage.org/swh/devel/swh-docs.git\#egg=swh.docs
+  # fetch and install swh-docs
+  git+https://gitlab.softwareheritage.org/swh/devel/swh-docs.git\#egg=swh.docs
 setenv =
   SWH_PACKAGE_DOC_TOX_BUILD = 1
   # turn warnings into errors
   SPHINXOPTS = -W
 commands =
-  make -I ../.tox/sphinx/src/swh-docs/swh/ -C docs
-
-# build documentation only inside swh-environment using local state
-# of swh-docs package
-[testenv:sphinx-dev]
-allowlist_externals = make
-usedevelop = true
-extras =
-  testing
-deps =
-  # install swh-docs in develop mode
-  -e ../swh-docs
-setenv =
-  SWH_PACKAGE_DOC_TOX_BUILD = 1
-  # turn warnings into errors
-  SPHINXOPTS = -W
-commands =
-  make -I ../.tox/sphinx-dev/src/swh-docs/swh/ -C docs
+  make -I {env_dir}/share/ -C docs