Skip to content
This repository was archived by the owner on Mar 13, 2024. It is now read-only.

Commit 8e53cb5

Browse files
authored
Merge pull request #57 from DiamondLightSource/dev
Update to latest python3-pip-skeleton
2 parents 2d61731 + c72f6ac commit 8e53cb5

File tree

9 files changed

+165
-157
lines changed

9 files changed

+165
-157
lines changed

.devcontainer/devcontainer.json

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// For format details, see https://aka.ms/devcontainer.json
1+
// For format details, see https://containers.dev/implementors/json_reference/
22
{
33
"name": "Python 3 Developer Container",
44
"build": {
@@ -12,24 +12,37 @@
1212
"remoteEnv": {
1313
"DISPLAY": "${localEnv:DISPLAY}"
1414
},
15+
// Add the URLs of features you want added when the container is built.
16+
"features": {
17+
"ghcr.io/devcontainers/features/common-utils:1": {
18+
"username": "none",
19+
"upgradePackages": false
20+
}
21+
},
1522
// Set *default* container specific settings.json values on container create.
1623
"settings": {
1724
"python.defaultInterpreterPath": "/venv/bin/python"
1825
},
19-
// Add the IDs of extensions you want installed when the container is created.
20-
"extensions": [
21-
"ms-python.python",
22-
"ms-python.vscode-pylance"
23-
],
26+
"customizations": {
27+
"vscode": {
28+
// Add the IDs of extensions you want installed when the container is created.
29+
"extensions": [
30+
"ms-python.python",
31+
"tamasfe.even-better-toml",
32+
"redhat.vscode-yaml",
33+
"ryanluker.vscode-coverage-gutters"
34+
]
35+
}
36+
},
2437
// Make sure the files we are mapping into the container exist on the host
2538
"initializeCommand": "bash -c 'for i in $HOME/.inputrc; do [ -f $i ] || touch $i; done'",
2639
"runArgs": [
2740
"--net=host",
28-
"--security-opt=label=type:container_runtime_t",
29-
"-v=${localEnv:HOME}/.ssh:/root/.ssh",
30-
"-v=${localEnv:HOME}/.inputrc:/root/.inputrc"
41+
"--security-opt=label=type:container_runtime_t"
3142
],
3243
"mounts": [
44+
"source=${localEnv:HOME}/.ssh,target=/root/.ssh,type=bind",
45+
"source=${localEnv:HOME}/.inputrc,target=/root/.inputrc,type=bind",
3346
// map in home directory - not strictly necessary but useful
3447
"source=${localEnv:HOME},target=${localEnv:HOME},type=bind,consistency=cached"
3548
],

.github/workflows/code.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
path: dist
103103

104104
- name: Check for packaging errors
105-
run: pipx run twine check dist/*
105+
run: pipx run twine check --strict dist/*
106106

107107
- name: Install python packages
108108
uses: ./.github/actions/install_requirements
@@ -165,6 +165,7 @@ jobs:
165165
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
166166
load: ${{ ! (github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) }}
167167
tags: ${{ steps.meta.outputs.tags }}
168+
labels: ${{ steps.meta.outputs.labels }}
168169
context: .devcontainer
169170
# If you have a long docker build, uncomment the following to turn on caching
170171
# For short build times this makes it a little slower
@@ -179,6 +180,8 @@ jobs:
179180
needs: [lint, dist, test]
180181
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
181182
runs-on: ubuntu-latest
183+
env:
184+
HAS_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN != '' }}
182185

183186
steps:
184187
- uses: actions/download-artifact@v3
@@ -201,6 +204,7 @@ jobs:
201204
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
202205

203206
- name: Publish to PyPI
207+
if: ${{ env.HAS_PYPI_TOKEN }}
204208
uses: pypa/gh-action-pypi-publish@release/v1
205209
with:
206210
password: ${{ secrets.PYPI_TOKEN }}

.github/workflows/linkcheck.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ on:
88

99
jobs:
1010
docs:
11-
strategy:
12-
fail-fast: false
13-
matrix:
14-
python: ["3.10"]
15-
1611
runs-on: ubuntu-latest
1712

1813
steps:

.vscode/extensions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"recommendations": [
33
"ms-vscode-remote.remote-containers",
4-
"ms-python.vscode-pylance",
54
"ms-python.python",
5+
"tamasfe.even-better-toml",
6+
"redhat.vscode-yaml",
67
"ryanluker.vscode-coverage-gutters"
78
]
89
}

docs/conf.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
# list see the documentation:
55
# https://www.sphinx-doc.org/en/master/usage/configuration.html
66

7+
import sys
78
from pathlib import Path
89
from subprocess import check_output
910

11+
import requests
12+
1013
import python3_pip_skeleton
1114

1215
# -- General configuration ------------------------------------------------
@@ -126,8 +129,26 @@
126129
html_theme = "pydata_sphinx_theme"
127130
github_repo = project
128131
github_user = "DiamondLightSource"
132+
switcher_json = f"https://{github_user}.github.io/{github_repo}/switcher.json"
133+
switcher_exists = requests.get(switcher_json).ok
134+
if not switcher_exists:
135+
print(
136+
"*** Can't read version switcher, is GitHub pages enabled? \n"
137+
" Once Docs CI job has successfully run once, set the "
138+
"Github pages source branch to be 'gh-pages' at:\n"
139+
f" https://github.com/{github_user}/{github_repo}/settings/pages",
140+
file=sys.stderr,
141+
)
129142

130143
# Theme options for pydata_sphinx_theme
144+
# We don't check switcher because there are 3 possible states for a repo:
145+
# 1. New project, docs are not published so there is no switcher
146+
# 2. Existing project with latest skeleton, switcher exists and works
147+
# 3. Existing project with old skeleton that makes broken switcher,
148+
# switcher exists but is broken
149+
# Point 3 makes checking switcher difficult, because the updated skeleton
150+
# will fix the switcher at the end of the docs workflow, but never gets a chance
151+
# to complete as the docs build warns and fails.
131152
html_theme_options = dict(
132153
logo=dict(
133154
text=project,
@@ -142,9 +163,10 @@
142163
)
143164
],
144165
switcher=dict(
145-
json_url=f"https://{github_user}.github.io/{github_repo}/switcher.json",
166+
json_url=switcher_json,
146167
version_match=version,
147168
),
169+
check_switcher=False,
148170
navbar_end=["theme-switcher", "icon-links", "version-switcher"],
149171
external_links=[
150172
dict(

pyproject.toml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,111 @@
22
requires = ["setuptools>=64", "setuptools_scm[toml]>=6.2", "wheel"]
33
build-backend = "setuptools.build_meta"
44

5+
[project]
6+
name = "python3-pip-skeleton"
7+
classifiers = [
8+
"Development Status :: 3 - Alpha",
9+
"License :: OSI Approved :: Apache Software License",
10+
"Programming Language :: Python :: 3.8",
11+
"Programming Language :: Python :: 3.9",
12+
"Programming Language :: Python :: 3.10",
13+
"Programming Language :: Python :: 3.11",
14+
]
15+
description = "One line description of your module"
16+
dependencies = [] # Add project dependencies here, e.g. ["click", "numpy"]
17+
dynamic = ["version"]
18+
license.file = "LICENSE"
19+
readme = "README.rst"
20+
requires-python = ">=3.8"
21+
22+
[project.optional-dependencies]
23+
dev = [
24+
"black",
25+
"mypy",
26+
"flake8-isort",
27+
"Flake8-pyproject",
28+
"pipdeptree",
29+
"pre-commit",
30+
"pydata-sphinx-theme>=0.12",
31+
"pytest-cov",
32+
"sphinx-autobuild",
33+
"sphinx-copybutton",
34+
"sphinx-design",
35+
"toml",
36+
"tox-direct",
37+
"types-mock",
38+
"types-toml",
39+
]
40+
41+
[project.scripts]
42+
python3-pip-skeleton = "python3_pip_skeleton.__main__:main"
43+
44+
[project.urls]
45+
GitHub = "https://github.com/DiamondLightSource/python3-pip-skeleton-cli"
46+
47+
[[project.authors]] # Further authors may be added by duplicating this section
48+
49+
name = "Firstname Lastname"
50+
51+
552
[tool.setuptools_scm]
653
write_to = "src/python3_pip_skeleton/_version.py"
54+
55+
[tool.mypy]
56+
ignore_missing_imports = true # Ignore missing stubs in imported modules
57+
58+
[tool.isort]
59+
float_to_top = true
60+
profile = "black"
61+
62+
[tool.flake8]
63+
extend-ignore = [
64+
"E203", # See https://github.com/PyCQA/pycodestyle/issues/373
65+
"F811", # support typing.overload decorator
66+
"F722", # allow Annotated[typ, some_func("some string")]
67+
]
68+
max-line-length = 88 # Respect black's line length (default 88),
69+
exclude = [".tox", "venv"]
70+
71+
72+
[tool.pytest.ini_options]
73+
# Run pytest with all our checkers, and don't spam us with massive tracebacks on error
74+
addopts = """
75+
--tb=native -vv --doctest-modules --doctest-glob="*.rst"
76+
--cov=python3_pip_skeleton --cov-report term --cov-report xml:cov.xml
77+
"""
78+
# https://iscinumpy.gitlab.io/post/bound-version-constraints/#watch-for-warnings
79+
filterwarnings = "error"
80+
# Doctest python code in docs, python code in src docstrings, test functions in tests
81+
testpaths = "docs src tests"
82+
83+
[tool.coverage.run]
84+
data_file = "/tmp/python3_pip_skeleton.coverage"
85+
86+
[tool.coverage.paths]
87+
# Tests are run from installed location, map back to the src directory
88+
source = ["src", "**/site-packages/"]
89+
90+
# tox must currently be configured via an embedded ini string
91+
# See: https://github.com/tox-dev/tox/issues/999
92+
[tool.tox]
93+
legacy_tox_ini = """
94+
[tox]
95+
skipsdist=True
96+
97+
[testenv:{pre-commit,mypy,pytest,docs}]
98+
# Don't create a virtualenv for the command, requires tox-direct plugin
99+
direct = True
100+
passenv = *
101+
allowlist_externals =
102+
pytest
103+
pre-commit
104+
mypy
105+
sphinx-build
106+
sphinx-autobuild
107+
commands =
108+
pytest: pytest {posargs}
109+
mypy: mypy src tests {posargs}
110+
pre-commit: pre-commit run --all-files {posargs}
111+
docs: sphinx-{posargs:build -EW --keep-going} -T docs build/html
112+
"""

setup.cfg

Lines changed: 0 additions & 125 deletions
This file was deleted.

0 commit comments

Comments
 (0)