Search code examples
pythonpython-poetry

Poetry build without .env file?


Using Poetry as my Python dependency manager, I build libraries I then use in other Python projects.

I noticed, when pulling my custom libs, the .env presence in my built libs. As they contain sensitive informations, I don't want them to be uploaded to my repository manager.

Is there a clean way to build a Python package while ignoring the .env ? It's location may depend on each lib.

To date, my only workaround is to manually remove the .env. Build & Publish. Then rolling back my .env.


Solution

  • I highly recommend to put the .env into the root folder of your project. It is not part of your actual package.

    The benefit of putting it into the root folder is, that it will not be included in the sdist or wheel file by default.

    As for any programming project I further recommend to use git for your project. If you put .env in your .gitignore file, Poetry will not include it into a package build as well.