Skip to content

Commit 64c7803

Browse files
committed
Clean up initial project structure
1 parent bd05661 commit 64c7803

5 files changed

Lines changed: 3 additions & 14 deletions

File tree

README.md

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Python Project Template
22

33

4-
## Quenstions
4+
## Questions
55

66
What is pyproject.toml?
77
Why does src exist?
@@ -23,18 +23,7 @@ The [tool] table has tool-specific subtables, e.g., [tool.hatch], [tool.black],
2323

2424
The “src layout” deviates from the flat layout by moving the code that is intended to be importable (i.e. import awesome_package, also known as import packages) into a subdirectory. This subdirectory is typically named src/, hence “src layout”.
2525

26-
Here’s a breakdown of the important behaviour differences between the src layout and the flat layout:
27-
28-
The src layout requires installation of the project to be able to run its code, and the flat layout does not.
29-
This means that the src layout involves an additional step in the development workflow of a project (typically, an editable installation is used for development and a regular installation is used for testing).
30-
31-
The src layout helps prevent accidental usage of the in-development copy of the code.
32-
This is relevant since the Python interpreter includes the current working directory as the first item on the import path. This means that if an import package exists in the current working directory with the same name as an installed import package, the variant from the current working directory will be used. This can lead to subtle misconfiguration of the project’s packaging tooling, which could result in files not being included in a distribution.
33-
34-
The src layout helps avoid this by keeping import packages in a directory separate from the root directory of the project, ensuring that the installed copy is used.
35-
3626
The src layout helps enforce that an editable installation is only able to import files that were meant to be importable.
37-
This is especially relevant when the editable installation is implemented using a path configuration file that adds the directory to the import path.
3827

3928
The flat layout would add the other project files (eg: README.md, tox.ini) and packaging/tooling configuration files (eg: setup.py, noxfile.py) on the import path. This would make certain imports work in editable installations but not regular installations.
4029

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[project]
2-
name = "python-apprentice"
2+
name = "python_apprentice"
33
version = "0.1.0"
44
description = "Exercises and projects from my Python apprenticeship program."
55
authors = [

tests/test_my_package.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from app import greet
1+
from python_apprentice import greet
22

33

44
def test_greet_returns_expected_message() -> None:

0 commit comments

Comments
 (0)