Skip to content

Commit f1bec11

Browse files
authored
Update packaging to src layout (#217)
* update to src layout * fix lock and other elements
1 parent 114e4a5 commit f1bec11

30 files changed

Lines changed: 840 additions & 708 deletions

.github/workflows/pytest.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
python-version: ${{ matrix.python-version }}
3737
- run: uv sync -q --no-default-groups --group test
3838
- run: template sys-info --developer
39-
- run: pytest template --cov=template --cov-report=xml --cov-config=pyproject.toml
39+
- run: pytest tests --cov=template --cov-report=xml --cov-config=pyproject.toml
4040
- uses: codecov/codecov-action@v5
4141
if: ${{ github.repository == 'mscheltienne/template-python' }}
4242
with:
@@ -63,7 +63,7 @@ jobs:
6363
uv sync -q --no-default-groups --group test
6464
uv pip install -q --upgrade --prerelease allow --only-binary :all: -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
6565
- run: template sys-info --developer
66-
- run: pytest template --cov=template --cov-report=xml --cov-config=pyproject.toml
66+
- run: pytest tests --cov=template --cov-report=xml --cov-config=pyproject.toml
6767
- uses: codecov/codecov-action@v5
6868
if: ${{ github.repository == 'mscheltienne/template-python' }}
6969
with:

MANIFEST.in

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Template python repository. To bootstrap a project from this template, the
1313
following steps are required:
1414

15-
- [ ] Rename the folder `template` to the package name
15+
- [ ] Rename the folder `src/template` to the package name and update imports
1616
- [ ] Edit `pyproject.toml` and all the `template` entries
1717
- [ ] Edit the GitHub workflows in `.github`
1818
- [ ] Enable `pre-commit.ci` on https://pre-commit.ci/

pyproject.toml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ doc = [
1919
]
2020
ide = [
2121
'ipykernel',
22+
'ipympl',
2223
'ipython',
2324
]
2425
style = [
@@ -99,14 +100,15 @@ branch = true
99100
cover_pylib = false
100101
omit = [
101102
'**/__init__.py',
102-
'**/conftest.py',
103103
'**/template/_version.py',
104104
'**/template/utils/_fixes.py',
105-
'**/tests/**',
106105
]
107106

108107
[tool.pytest.ini_options]
109108
addopts = ['--color=yes', '--cov-report=', '--durations=20', '--junit-xml=junit-results.xml', '--strict-config', '--tb=short', '-ra', '-v']
109+
filterwarnings = [
110+
'error',
111+
]
110112
junit_family = 'xunit2'
111113
minversion = '8.0'
112114

@@ -120,7 +122,10 @@ line-ending = "lf"
120122

121123
[tool.ruff.lint]
122124
ignore = []
123-
select = ['A', 'B', 'C4', 'D', 'E', 'F', 'G', 'I', 'LOG', 'NPY', 'PERF', 'PIE', 'PT', 'T20', 'UP', 'W']
125+
select = ['A', 'B', 'C4', 'D', 'E', 'F', 'G', 'I', 'LOG', 'NPY', 'PERF', 'PIE', 'PT', 'T20', 'TID', 'UP', 'W']
126+
127+
[tool.ruff.lint.flake8-tidy-imports]
128+
ban-relative-imports = "all"
124129

125130
[tool.ruff.lint.per-file-ignores]
126131
'*' = [
@@ -129,7 +134,6 @@ select = ['A', 'B', 'C4', 'D', 'E', 'F', 'G', 'I', 'LOG', 'NPY', 'PERF', 'PIE',
129134
'D104', # 'Missing docstring in public package'
130135
'D107', # 'Missing docstring in __init__'
131136
]
132-
'*.pyi' = ['E501']
133137
'__init__.py' = ['F401']
134138
'tutorials/*' = ['D205', 'D400', 'T201']
135139

@@ -141,11 +145,11 @@ ignore-decorators = ["template.utils._docs.copy_doc"]
141145
include-package-data = false
142146

143147
[tool.setuptools.packages.find]
144-
exclude = ['template*tests']
145148
include = ['template*']
149+
where = ['src']
146150

147151
[tool.setuptools_scm]
148-
version_file = "template/_version.py"
152+
version_file = "src/template/_version.py"
149153
version_scheme = "release-branch-semver"
150154

151155
[tool.tomlsort]

src/template/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from template import utils
2+
from template._version import __version__
3+
from template.utils.config import sys_info
4+
from template.utils.logs import add_file_handler, set_log_level
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import click
44

5-
from .sys_info import run as sys_info
5+
from template._commands.sys_info import run as sys_info
66

77

88
@click.group()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import click
44

5-
from .. import sys_info
5+
from template.utils.config import sys_info
66

77

88
@click.command(name="sys-info")

src/template/utils/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""Utilities module."""
2+
3+
from template.utils import config, logs

0 commit comments

Comments
 (0)