@@ -622,43 +622,53 @@ Poetry is clever enough to detect Python subpackages.
622
622
Thus, you only have to specify the directory where your root package resides.
623
623
{{% /note %}}
624
624
625
- ### include and exclude
625
+ ### exclude and include
626
626
627
- A list of patterns that will be included in the final package.
627
+ {{% note %}}
628
+ If you just want to include a package or module, which is not picked up automatically,
629
+ use [ packages] ({{< relref "#packages" >}}) instead of ` include ` .
630
+ {{% /note %}}
631
+
632
+ A list of patterns that will be excluded or included in the final package.
633
+
634
+ ``` toml
635
+ [tool .poetry ]
636
+ # ...
637
+ exclude = [" my_package/excluded.py" ]
638
+ include = [" CHANGELOG.md" ]
639
+ ```
628
640
629
641
You can explicitly specify to Poetry that a set of globs should be ignored or included for the purposes of packaging.
630
642
The globs specified in the exclude field identify a set of files that are not included when a package is built.
643
+ ` include ` has priority over ` exclude ` .
631
644
632
645
If a VCS is being used for a package, the exclude field will be seeded with the VCS’ ignore settings (` .gitignore ` for git for example).
633
646
634
647
{{% note %}}
635
648
Explicitly declaring entries in ` include ` will negate VCS' ignore settings.
636
649
{{% /note %}}
637
650
638
- ``` toml
639
- [tool .poetry ]
640
- # ...
641
- include = [" CHANGELOG.md" ]
642
- ```
643
-
644
651
You can also specify the formats for which these patterns have to be included, as shown here:
645
652
646
653
``` toml
647
654
[tool .poetry ]
648
655
# ...
649
656
include = [
650
657
{ path = " tests" , format = " sdist" },
651
- { path = " for_wheel .txt" , format = [" sdist" , " wheel" ] }
658
+ { path = " my_package/for_sdist_and_wheel .txt" , format = [" sdist" , " wheel" ] }
652
659
]
653
660
```
654
661
655
662
If no format is specified, ` include ` defaults to only ` sdist ` .
656
663
657
664
In contrast, ` exclude ` defaults to both ` sdist ` and ` wheel ` .
658
665
659
- ``` toml
660
- exclude = [" my_package/excluded.py" ]
661
- ```
666
+ {{% warning %}}
667
+ When a wheel is installed, its includes are unpacked straight into the ` site-packages ` directory.
668
+ Pay attention to include top level files and directories with common names like
669
+ ` CHANGELOG.md ` , ` LICENSE ` , ` tests ` or ` docs ` only in sdists and ** not** in wheels.
670
+ {{% /warning %}}
671
+
662
672
663
673
### dependencies and dependency groups
664
674
0 commit comments