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: _sources/package-structure-code/declare-dependencies.md.txt
+28-53Lines changed: 28 additions & 53 deletions
Original file line number
Diff line number
Diff line change
@@ -58,7 +58,7 @@ There are three different types of dependencies that you will learn about on thi
58
58
2. **Feature Dependencies:** These are dependencies that are required if a user wants to access additional functionality (that is not core) to your package. Store these in the `[project.optional.dependencies]` table or your pyproject.toml file.
59
59
3. **Development Dependencies:** These dependencies are required if someone wants to develop or work on your package. These include instance linters, testing tools like pytest and mypy are examples of development dependencies. Store these in the `[project.dependency.groups]` table or your pyproject.toml file.
60
60
61
-
:::{admonition}
61
+
:::{tip}
62
62
A dependency is not part of your project's codebase. It is a package or software called
63
63
within the code of your project or used during the development of your package.
64
64
:::
@@ -85,7 +85,7 @@ dependencies = [
85
85
]
86
86
```
87
87
88
-
:::{admonition
88
+
:::{tip}
89
89
Try your best to minimize dependencies whenever possible. Remember that
90
90
fewer dependencies reduce the possibility of version conflicts in user
91
91
environments.
@@ -406,10 +406,8 @@ dependencies = [
406
406
407
407
408
408
:::{todo}
409
-
### Using conda and pixi
409
+
### Using conda and Pixi
410
410
411
-
::::{todo}
412
-
Ask Matthew to review this section...
413
411
:::
414
412
415
413
The `pyproject.toml` file works great for pure-Python packages. However,
@@ -423,64 +421,41 @@ You can maintain an `environment.yml` file to help users and contributors
423
421
set up conda environments. This is especially useful for packages with
424
422
system-level dependencies like GDAL.
425
423
426
-
**Consider pixi for conda workflows:**
424
+
**Consider Pixi for conda package focused workflows:**
425
+
426
+
[Pixi](https://pixi.sh) is a modern package manager built on top of both
427
+
the conda and Python package ecosystems.
428
+
Pixi is able to treat conda and Python package requirements with parity when
429
+
resolving environments, but uses a "conda-first" approach of using already
430
+
resolved conda packages if possible when resolving Python dependencies.
431
+
Pixi [can also use `pyproject.toml` for configuration](https://pixi.sh/latest/python/pyproject_toml/).
432
+
If your project relies heavily on conda packages, Pixi offers a streamlined
433
+
workflow with faster dependency resolution and automatic lock file support for
434
+
full environment reproducibility.
435
+
If you already have an existing conda environment definition file, like
436
+
an `environment.yml`, you can
437
+
[import the environment](https://pixi.sh/latest/tutorials/import/) into a new
438
+
Pixi workspace with
427
439
428
-
[Pixi](https://pixi.sh) is a modern package manager built on conda that
429
-
uses `pyproject.toml` for configuration. If your project relies heavily
430
-
on conda packages, pixi offers a streamlined workflow with lockfiles and
431
-
faster dependency resolution.
440
+
```
441
+
pixi init --import environment.yml
442
+
```
432
443
433
444
:::{admonition} A note for conda users
434
445
:class: tip
435
446
436
447
If you use a conda environment for development and install your package
437
-
with `python -m pip install -e .`, dependencies will be installed from
438
-
PyPI rather than conda. This can cause conflicts, especially for packages
439
-
with system dependencies.
448
+
with `python -m pip install -e .` dependencies will be installed from PyPI,
449
+
potentially overwriting conda packages that had already been installed.
450
+
This can cause conflicts, especially for packages with system dependencies.
440
451
441
452
To avoid this, install your package without dependencies:
442
-
`python -m pip install -e . --no-deps`
443
-
444
-
Then install dependencies through your conda environment.yml file.
445
-
:::
446
-
::::
447
-
448
-
### Using conda and pixi
449
-
450
-
:::{todo}
451
-
Ask matthew to review this section...
452
-
:::
453
-
454
-
The `pyproject.toml` file works great for pure-Python packages. However,
455
-
some packages (particularly in the scientific Python ecosystem) require
456
-
dependencies written in other languages like C or Fortran. Conda was
457
-
created to support the distribution of tools with non-Python dependencies.
458
453
459
-
**For conda users:**
460
-
461
-
You can maintain an `environment.yml` file to help users and contributors
462
-
set up conda environments. This is especially useful for packages with
463
-
system-level dependencies like GDAL.
464
-
465
-
**Consider pixi for conda workflows:**
466
-
467
-
[Pixi](https://pixi.sh) is a modern package manager built on conda that
468
-
uses `pyproject.toml` for configuration. If your project relies heavily
469
-
on conda packages, pixi offers a streamlined workflow with lockfiles and
470
-
faster dependency resolution.
471
-
472
-
:::{admonition} A note for conda users
473
-
:class: tip
474
-
475
-
If you use a conda environment for development and install your package
476
-
with `python -m pip install -e .`, dependencies will be installed from
477
-
PyPI rather than conda. This can cause conflicts, especially for packages
478
-
with system dependencies.
479
-
480
-
To avoid this, install your package without dependencies:
481
-
`python -m pip install -e . --no-deps`
454
+
```
455
+
python -m pip install -e . --no-deps
456
+
```
482
457
483
-
Then install dependencies through your conda environment.yml file.
458
+
Then install dependencies through your conda `environment.yml` file.
0 commit comments