Skip to content
Snippets Groups Projects
Commit 7fcefc48 authored by David Douard's avatar David Douard
Browse files

Migrate to copier-base template

This replaces the setup.py package file with pyproject.toml (keeping
setuptools and setuptool_scm) and use an implicit namespace declaration
for the swh namespace.

Also note that due to the poor support of PEP 420 in pytest, it needs a
pair of command line arguments to pass all tests (see tox.ini).
parent 318f8f74
No related branches found
No related tags found
No related merge requests found
# Changes here will be overwritten by Copier
_commit: v0.1.4
_src_path: https://gitlab.softwareheritage.org/swh/devel/swh-py-template.git
description: Software Heritage core utilities
distribution_name: swh-core
have_cli: true
have_workers: false
package_root: swh/core
project_name: swh.core
python_minimal_version: '3.7'
readme_format: rst
*.egg-info/
*.pyc
*.sw?
*~
/.coverage
/.coverage.*
.coverage
.eggs/
__pycache__
build
dist
swh.core.egg-info
version.txt
.tox
.hypothesis
.mypy_cache/
.mypy_cache
.tox
__pycache__
build/
dist/
docs/README.rst
docs/README.md
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]
......@@ -30,12 +40,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
[mypy]
namespace_packages = True
warn_unused_ignores = True
explicit_package_bases = True
# ^ Needed for mypy to detect py.typed from swh packages installed
# in editable mode
# 3rd party libraries without stubs (yet)
......@@ -20,7 +22,7 @@ ignore_missing_imports = True
[mypy-deprecated.*]
ignore_missing_imports = True
[mypy-django.*] # false positive, only used my hypotesis' extras
[mypy-django.*] # false positive, only used by hypotesis' extras
ignore_missing_imports = True
[mypy-iso8601.*]
......@@ -35,9 +37,6 @@ ignore_missing_imports = True
[mypy-pkg_resources.*]
ignore_missing_imports = True
[mypy-pytest.*]
ignore_missing_imports = True
[mypy-pytest_postgresql.*]
ignore_missing_imports = True
......@@ -46,3 +45,6 @@ ignore_missing_imports = True
[mypy-systemd.*]
ignore_missing_imports = True
# [mypy-add_your_lib_here.*]
# ignore_missing_imports = True
[project]
name = "swh.core"
authors = [
{name="Software Heritage developers", email="swh-devel@inria.fr"},
]
description = "Software Heritage core utilities"
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"}
[tool.setuptools.dynamic.optional-dependencies]
testing_core = {file = "requirements-test.txt"}
logging = {file = ["requirements-logging.txt"]}
db = {file = ["requirements-db.txt", "requirements-db-pytestplugin.txt"]}
http = {file = "requirements-http.txt"}
github = {file = ["requirements-github.txt"]}
# kitchen sink, please do not use
testing = {file = [
"requirements-test.txt",
"requirements-logging.txt",
"requirements-http.txt",
"requirements-db.txt",
"requirements-db-pytestplugin.txt",
"requirements-github.txt"]}
[project.entry-points.console_scripts]
"swh" = "swh.core.cli:main"
[project.entry-points."swh.cli.subcommands"]
"swh.core.db" = "swh.core.cli.db"
[project.entry-points.pytest11]
"pytest_swh_core" = "swh.core.pytest_plugin"
[project.urls]
"Homepage" = "https://gitlab.softwareheritage.org/swh/devel/swh-core"
"Bug Reports" = "https://gitlab.softwareheritage.org/swh/devel/swh-core/-/issues"
"Funding" = "https://www.softwareheritage.org/donate"
"Documentation" = "https://docs.softwareheritage.org/devel/swh-core/"
"Source" = "https://gitlab.softwareheritage.org/swh/devel/swh-core.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']
......
......@@ -2,3 +2,5 @@
norecursedirs = build docs .*
filterwarnings =
ignore:.*uses the 'db_with_data' fixture
asyncio_mode = strict
# requirements for swh.core.github
requests
tenacity
#!/usr/bin/env python3
# Copyright (C) 2015-2018 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
import os
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 os.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.core",
description="Software Heritage core utilities",
long_description=long_description,
long_description_content_type="text/x-rst",
python_requires=">=3.7",
author="Software Heritage developers",
author_email="swh-devel@inria.fr",
url="https://forge.softwareheritage.org/diffusion/DCORE/",
packages=find_packages(),
py_modules=["pytest_swh_core"],
scripts=[],
install_requires=parse_requirements(None, "swh"),
setup_requires=["setuptools-scm"],
use_scm_version=True,
extras_require={
"testing-core": parse_requirements("test"),
"logging": parse_requirements("logging"),
"db": parse_requirements("db", "db-pytestplugin"),
"http": parse_requirements("http"),
"github": parse_requirements("github"),
# kitchen sink, please do not use
"testing": parse_requirements(
"test", "db", "db-pytestplugin", "http", "logging"
),
},
include_package_data=True,
entry_points="""
[console_scripts]
swh=swh.core.cli:main
swh-db-init=swh.core.cli.db:db_init
[swh.cli.subcommands]
db=swh.core.cli.db
[pytest11]
pytest_swh_core = swh.core.pytest_plugin
""",
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-core",
"Documentation": "https://docs.softwareheritage.org/devel/swh-core/",
},
)
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
[tox]
minversion=4
envlist=black,flake8,mypy,py3-{core,db,server,github}
minversion = 4
envlist =
black
flake8
mypy
py3-{core,db,server,github}
[testenv]
passenv = PYTHONASYNCIODEBUG
......@@ -14,6 +18,8 @@ deps =
cover: pytest-cov
commands =
pytest --doctest-modules \
--import-mode importlib \
--rootdir {envsitepackagesdir} \
slow: --hypothesis-profile=slow \
cover: --cov={envsitepackagesdir}/swh/core --cov-branch \
core: {envsitepackagesdir}/swh/core/tests \
......@@ -21,6 +27,9 @@ commands =
server: {envsitepackagesdir}/swh/core/api/tests \
github: {envsitepackagesdir}/swh/core/github/tests \
{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:py3{,7,8,9,10,11,12,13},pypy3{,7,8,9,10,11,12,13}]
skip_install = true
......@@ -60,7 +69,6 @@ commands =
# breaking doc build
[testenv:sphinx]
allowlist_externals = make
usedevelop = true
extras =
testing-core
logging
......@@ -81,7 +89,6 @@ commands =
# of swh-docs package
[testenv:sphinx-dev]
allowlist_externals = make
usedevelop = true
extras =
testing-core
logging
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment