Search code examples
pythonpackagingpython-packagingpython.net

how to prevent Poetry to consider .gitignore


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?


Solution

  • 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/some.dll",  # listing files explicitly
        "src/dlls/*",         # all files in "src/dlls"
        "src/dlls/**/*",      # all files in "src/dlls" and any subfolders
        "src/dlls/**/*.dll",  # all files in "src/dlls" and any subfolders
                              # with the file ending ".dll"
    ]