You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24-17Lines changed: 24 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,9 @@
4
4
5
5
Simple and short code examples to find the root directory of your project in different ways. This can be useful in projects where you are reading or writing data to directories inside your project directory. All examples return a [`pathlib.Path`](https://docs.python.org/3/library/pathlib.html) object.
6
6
7
-
All code in this repository is licensed under the [MIT No Attribution (MIT-0) License](./LICENSE) and can be used without attribution.
7
+
To use, just copy and paste one of the examples into your project. Make any adjustments as needed or desired. These examples are all fairly straightforward and generally have no external dependencies. All code in this repository is licensed under the [MIT No Attribution (MIT-0) License](./LICENSE) and can be used without attribution.
8
8
9
-
If for some reason you prefer a take on a dependency instead of copy-pasting a small amount of code, see these packages: [pyprojroot](https://github.com/chendaniely/pyprojroot), [rootpath](https://github.com/grimen/python-rootpath)
9
+
If for some reason you prefer to take on a dependency or to have a function resolve a bunch of criteria automagically, see these packages as alternatives: [pyprojroot](https://github.com/chendaniely/pyprojroot), [rootpath](https://github.com/grimen/python-rootpath)
10
10
11
11
## Cookbook
12
12
@@ -20,6 +20,8 @@ Table of contents:
20
20
21
21
### Find pyproject.toml file
22
22
23
+
[`pyproject.toml`](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/) is a modern standard configuration file for packaging metadata and tools configuration. It's typically in the project root directory of Python projects.
Copy file name to clipboardExpand all lines: src/_README.md.template
+14-4Lines changed: 14 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,9 @@
4
4
5
5
Simple and short code examples to find the root directory of your project in different ways. This can be useful in projects where you are reading or writing data to directories inside your project directory. All examples return a [`pathlib.Path`](https://docs.python.org/3/library/pathlib.html) object.
6
6
7
-
All code in this repository is licensed under the [MIT No Attribution (MIT-0) License](./LICENSE) and can be used without attribution.
7
+
To use, just copy and paste one of the examples into your project. Make any adjustments as needed or desired. These examples are all fairly straightforward and generally have no external dependencies. All code in this repository is licensed under the [MIT No Attribution (MIT-0) License](./LICENSE) and can be used without attribution.
8
8
9
-
If for some reason you prefer a take on a dependency instead of copy-pasting a small amount of code, see these packages: [pyprojroot](https://github.com/chendaniely/pyprojroot), [rootpath](https://github.com/grimen/python-rootpath)
9
+
If for some reason you prefer to take on a dependency or to have a function resolve a bunch of criteria automagically, see these packages as alternatives: [pyprojroot](https://github.com/chendaniely/pyprojroot), [rootpath](https://github.com/grimen/python-rootpath)
10
10
11
11
## Cookbook
12
12
@@ -20,10 +20,14 @@ Table of contents:
20
20
21
21
### Find pyproject.toml file
22
22
23
+
[`pyproject.toml`](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/) is a modern standard configuration file for packaging metadata and tools configuration. It's typically in the project root directory of Python projects.
24
+
23
25
{find_pyproject_toml}
24
26
25
27
### Find pyproject.toml file matching project name
26
28
29
+
If you're in a monorepo with multiple Python packages, you may want to find the specific intended `pyproject.toml` file by matching on its contents.
30
+
27
31
{find_pyproject_toml_project_name}
28
32
29
33
> [!TIP]
@@ -44,12 +48,18 @@ Table of contents:
44
48
45
49
### Find .git directory
46
50
51
+
If using Git as your version control system, there will be a `.git` directory in your project root.
52
+
47
53
{find_git}
48
54
49
-
### Find a specific file containing a specific value
55
+
### Find a .here file
50
56
51
-
{find_marker_file}
57
+
Popularized by R's [here](https://here.r-lib.org/) package, some project root detection tools support finding a file named `.here`.
58
+
59
+
{find_here_file}
52
60
53
61
### Read from environment variable
54
62
63
+
Environment variables are a good way specify configuration values that vary between running environments.
0 commit comments