how to prevent Poetry to consider .gitignore

Viewed 1067

I am working on a python project which uses pythonnet with several C# dll's as dependencies. As I do not want to push the dll's to the git repository I adapted the .gitignore file. However, now Poetry does not include the dll's into the python package.

Is there a way to force Poetry to ignore the .gitignore?

3 Answers

Yes, the .gitignore just serves as the default-settings for poetrys inclusion/exclusion list. You can configure it manually with the include field, which is documented here.

In your case, you just need to specify the dll folder that you are excluding in your gitignore:

.gitignore

# ...
src/dlls

pyproject.toml

[tool.poetry]
# ...
include = ["src/dlls/*"]

Just to expand on the answer above, for directories that have deeper structure, use */** to recursively add contents from the Git ignored directory.

pyproject.toml

[tool.poetry]
# other configuration here
include = ["src/extra/*/**"]

Surprisingly none of the above answers worked for me. I also had a deeper structure where I wanted files not to be present in the repository, but to be recursively included upon building/publishing. The following globbing pattern worked out for me:

.gitignore

my_folder/

pyproject.toml

[tool.poetry]
...
include = ["**/my_folder/**/*.py"]
Related