Skip to content

Commit 315a0e8

Browse files
apollo13CoolCat467jakkdl
authored
Move to src-layout. (#2798)
* Move to src-layout. The intention of this is better isolation. `trio` is no longer accidentally on the (python) path and as such requires an explicit installation for usage, this helps uncover issues in packaging data etc early on (see https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/). This serves as the basis for switching to another build system as well; refs #2790. --------- Co-authored-by: CoolCat467 <[email protected]> Co-authored-by: jakkdl <[email protected]>
1 parent b7d2054 commit 315a0e8

File tree

142 files changed

+27
-30
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+27
-30
lines changed

MANIFEST.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include README.rst
33
include LONG_DESCRIPTION.rst
44
include CODE_OF_CONDUCT.md CONTRIBUTING.md
55
include test-requirements.txt
6-
include trio/py.typed
7-
recursive-include trio/_tests/test_ssl_certs *.pem
6+
include src/trio/py.typed
7+
recursive-include src/trio/_tests/test_ssl_certs *.pem
88
recursive-include docs *
99
prune docs/build

check.sh

+12-12
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fi
1313

1414
# Test if the generated code is still up to date
1515
echo "::group::Generate Exports"
16-
python ./trio/_tools/gen_exports.py --test \
16+
python ./src/trio/_tools/gen_exports.py --test \
1717
|| EXIT_STATUS=$?
1818
echo "::endgroup::"
1919

@@ -23,10 +23,10 @@ echo "::endgroup::"
2323
# autoflake --recursive --in-place .
2424
# pyupgrade --py3-plus $(find . -name "*.py")
2525
echo "::group::Black"
26-
if ! black --check trio; then
26+
if ! black --check src/trio; then
2727
echo "* Black found issues" >> "$GITHUB_STEP_SUMMARY"
2828
EXIT_STATUS=1
29-
black --diff trio
29+
black --diff src/trio
3030
echo "::endgroup::"
3131
echo "::error:: Black found issues"
3232
else
@@ -57,16 +57,16 @@ echo "::group::Mypy"
5757
rm -f mypy_annotate.dat
5858
# Pipefail makes these pipelines fail if mypy does, even if mypy_annotate.py succeeds.
5959
set -o pipefail
60-
mypy trio --show-error-end --platform linux | python ./trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Linux \
60+
mypy src/trio --show-error-end --platform linux | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Linux \
6161
|| { echo "* Mypy (Linux) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
6262
# Darwin tests FreeBSD too
63-
mypy trio --show-error-end --platform darwin | python ./trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Mac \
63+
mypy src/trio --show-error-end --platform darwin | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Mac \
6464
|| { echo "* Mypy (Mac) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
65-
mypy trio --show-error-end --platform win32 | python ./trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Windows \
65+
mypy src/trio --show-error-end --platform win32 | python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat --platform Windows \
6666
|| { echo "* Mypy (Windows) found type errors." >> "$GITHUB_STEP_SUMMARY"; MYPY=1; }
6767
set +o pipefail
6868
# Re-display errors using Github's syntax, read out of mypy_annotate.dat
69-
python ./trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat
69+
python ./src/trio/_tools/mypy_annotate.py --dumpfile mypy_annotate.dat
7070
# Then discard.
7171
rm -f mypy_annotate.dat
7272
echo "::endgroup::"
@@ -97,11 +97,11 @@ fi
9797
codespell || EXIT_STATUS=$?
9898

9999
echo "::group::Pyright interface tests"
100-
python trio/_tests/check_type_completeness.py --overwrite-file || EXIT_STATUS=$?
101-
if git status --porcelain trio/_tests/verify_types*.json | grep -q "M"; then
100+
python src/trio/_tests/check_type_completeness.py --overwrite-file || EXIT_STATUS=$?
101+
if git status --porcelain src/trio/_tests/verify_types*.json | grep -q "M"; then
102102
echo "* Type completeness changed, please update!" >> "$GITHUB_STEP_SUMMARY"
103103
echo "::error::Type completeness changed, please update!"
104-
git --no-pager diff --color trio/_tests/verify_types*.json
104+
git --no-pager diff --color src/trio/_tests/verify_types*.json
105105
EXIT_STATUS=1
106106
fi
107107

@@ -118,8 +118,8 @@ Problems were found by static analysis (listed above).
118118
To fix formatting and see remaining errors, run
119119
120120
pip install -r test-requirements.txt
121-
black trio
122-
isort trio
121+
black src/trio
122+
ruff check src/trio
123123
./check.sh
124124
125125
in your local checkout.

ci.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ else
9595
# when installing, and then running 'certmgr.msc' and exporting the
9696
# certificate. See:
9797
# http://www.migee.com/2010/09/24/solution-for-unattendedsilent-installs-and-would-you-like-to-install-this-device-software/
98-
certutil -addstore "TrustedPublisher" trio/_tests/astrill-codesigning-cert.cer
98+
certutil -addstore "TrustedPublisher" src/trio/_tests/astrill-codesigning-cert.cer
9999
# Double-slashes are how you tell windows-bash that you want a single
100100
# slash, and don't treat this as a unix-style filename that needs to
101101
# be replaced by a windows-style filename.

docs/source/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# For our local_customization module
2323
sys.path.insert(0, os.path.abspath("."))
2424
# For trio itself
25-
sys.path.insert(0, os.path.abspath("../.."))
25+
sys.path.insert(0, os.path.abspath("../../src"))
2626

2727
# Enable reloading with `typing.TYPE_CHECKING` being True
2828
os.environ["SPHINX_AUTODOC_RELOAD_MODULES"] = "1"

pyproject.toml

+10-13
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ Changelog = "https://trio.readthedocs.io/en/latest/history.html"
6565
# doesn't look like a source file, so long as it appears in MANIFEST.in:
6666
include-package-data = true
6767

68-
[tool.setuptools.packages]
69-
find = {namespaces = false}
70-
7168
[tool.setuptools.dynamic]
7269
version = {attr = "trio._version.__version__"}
7370

@@ -84,15 +81,14 @@ force-exclude = '''
8481
ignore-words-list = 'astroid,crasher,asend'
8582

8683
[tool.ruff]
87-
target-version = "py38"
8884
respect-gitignore = true
8985
fix = true
9086

9187
allowed-confusables = [""]
9288

9389
# The directories to consider when resolving first vs. third-party imports.
9490
# Does not control what files to include/exclude!
95-
src = ["trio", "notes-to-self"]
91+
src = ["src/trio", "notes-to-self"]
9692

9793
select = [
9894
"RUF", # Ruff-specific rules
@@ -124,13 +120,13 @@ extend-exclude = [
124120
]
125121

126122
[tool.ruff.per-file-ignores]
127-
'trio/__init__.py' = ['F401']
128-
'trio/_core/__init__.py' = ['F401']
129-
'trio/_core/_tests/test_multierror_scripts/*' = ['F401']
130-
'trio/abc.py' = ['F401']
131-
'trio/lowlevel.py' = ['F401']
132-
'trio/socket.py' = ['F401']
133-
'trio/testing/__init__.py' = ['F401']
123+
'src/trio/__init__.py' = ['F401']
124+
'src/trio/_core/__init__.py' = ['F401']
125+
'src/trio/_core/_tests/test_multierror_scripts/*' = ['F401']
126+
'src/trio/abc.py' = ['F401']
127+
'src/trio/lowlevel.py' = ['F401']
128+
'src/trio/socket.py' = ['F401']
129+
'src/trio/testing/__init__.py' = ['F401']
134130

135131
[tool.ruff.isort]
136132
combine-as-imports = true
@@ -184,6 +180,7 @@ issue_format = "`#{issue} <https://github.com/python-trio/trio/issues/{issue}>`_
184180
# - At release time after bumping version number, run: towncrier
185181
# (or towncrier --draft)
186182
package = "trio"
183+
package_dir = "src"
187184
underlines = ["-", "~", "^"]
188185

189186
[[tool.towncrier.type]]
@@ -228,7 +225,7 @@ showcontent = true
228225

229226
[tool.coverage.run]
230227
branch = true
231-
source = ["trio"]
228+
source_pkgs = ["trio"]
232229
omit = [
233230
# These are run in subprocesses, but still don't work. We follow
234231
# coverage's documentation to no avail.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

trio/_tools/gen_exports.py renamed to src/trio/_tools/gen_exports.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def main() -> None: # pragma: no cover
313313
source_root = Path.cwd()
314314
# Double-check we found the right directory
315315
assert (source_root / "LICENSE").exists()
316-
core = source_root / "trio/_core"
316+
core = source_root / "src/trio/_core"
317317
to_wrap = [
318318
File(core / "_run.py", "runner", imports=IMPORTS_RUN),
319319
File(
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)