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: docs/basic-usage.md
+24-2
Original file line number
Diff line number
Diff line change
@@ -63,8 +63,29 @@ Similarly, the traditional `MANIFEST.in` file is replaced by the `tool.poetry.re
63
63
`tool.poetry.exclude` sections. `tool.poetry.exclude` is additionally implicitly populated by your `.gitignore`. For
64
64
full documentation on the project format, see the [pyproject section]({{< relref "pyproject" >}}) of the documentation.
65
65
66
+
### Setting a Python Version
67
+
68
+
{{% note %}}
69
+
Unlike with other packages, Poetry will not automatically install a python interpreter for you.
70
+
If you want to run Python files in your package like a script or application, you must _bring your own_ python interpreter to run them.
71
+
{{% /note %}}
72
+
66
73
Poetry will require you to explicitly specify what versions of Python you intend to support, and its universal locking
67
74
will guarantee that your project is installable (and all dependencies claim support for) all supported Python versions.
75
+
Again, it's important to remember that -- unlike other dependencies -- setting a Python version is merely specifying which versions of Python you intend to support.
76
+
77
+
For example, in this `pyproject.toml` file:
78
+
79
+
```toml
80
+
[tool.poetry.dependencies]
81
+
python = "^3.7.0"
82
+
```
83
+
84
+
we are allowing any version of Python 3 that is greater than `3.7.0`.
85
+
86
+
When you run `poetry install`, you must have access to some version of a Python inrepreter that satisfies this constraint available on your system.
87
+
Poetry will not install a Python interpreter for you.
88
+
If you use a tool like `pyenv`, you can use the experimental configuration value [`virtualenvs.prefer-active-python`]({{< relref "configuration/#virtualenvsprefer-active-python-experimental" >}}).
68
89
69
90
### Initialising a pre-existing project
70
91
@@ -155,13 +176,15 @@ Likewise if you have command line tools such as `pytest` or `black` you can run
155
176
If managing your own virtual environment externally, you do not need to use `poetry run` or `poetry shell` since
156
177
you will, presumably, already have activated that virtual environment and made available the correct python instance.
157
178
For example, these commands should output the same python path:
179
+
158
180
```shell
159
181
conda activate your_env_name
160
182
which python
161
183
poetry run which python
162
184
poetry shell
163
185
which python
164
186
```
187
+
165
188
{{% /note %}}
166
189
167
190
### Activating the virtual environment
@@ -197,7 +220,7 @@ You can also combine these into a one-liner, such as `source $(poetry env info -
197
220
To deactivate this virtual environment simply use `deactivate`.
198
221
199
222
|| POSIX Shell | Windows (PowerShell) | Exit/Deactivate |
| One-liner |`source $(poetry env info --path)/bin/activate`|`& ((poetry env info --path) + "\Scripts\activate.ps1")`|`deactivate`|
@@ -273,7 +296,6 @@ the dependencies installed are still working even if your dependencies released
273
296
{{% warning %}} If you have added the recommended [`[build-system]`]({{< relref "pyproject#poetry-and-pep-517" >}}) section to your project's pyproject.toml then you _can_ successfully install your project and its dependencies into a virtual environment using a command like `pip install -e .`. However, pip will not use the lock file to determine dependency versions as the poetry-core build system is intended for library developers (see next section).
274
297
{{% /warning %}}
275
298
276
-
277
299
#### As a library developer
278
300
279
301
Library developers have more to consider. Your users are application developers, and your library will run in a Python environment you don't control.
0 commit comments