Add '--exclude' option
In my project I need to exclude a list of specified packages with their dependencies when exporting. Then I use exported requirements.txt to install all exported deps and install a list of specified packages from whl files which were built locally in the same job.
Adding the exclude option solves my issue.
I hope it can be useful in other cases and will be integrated into the official release.
Quality Gate passed
Kudos, no new issues were introduced!
0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code
sounds like you should be making use of either groups or extras, depending on what your use case is. I doubt that poetry export should introduce a third mechanism.
@dimbleby Thanks for your reply!
No, I can't use extras or groups. Packages that I need to exclude have to be required by default when building whl of my project.
If dependency groups could be required, it also would help with my case.
Apparently PR also could solve this issue https://github.com/python-poetry/poetry-plugin-export/issues/40
poetry export -f requirements.txt --exclude black --exclude flake8 --output requirements.txt
#40 seems already to be solved by using groups
I cannot understand your use case. If you have dependencies that are definitely always required by your project, then an export that does not mention those dependencies does not make sense to me: it seems plainly to be a faulty export
Probably you would be better served by post-processing the exported requirements.txt, rather than trying to make poetry export the wrong thing.
@dimbleby
I have two Python packages: packageA and packageB. packageB is declared as a required dependency for packageA.
For local development of packageA, I use the latest version of packageB from a PyPI repository.
The poetry.lock file contains a link to the PyPI repository for packageB.
For building as a part of monorepo project, I need to exclude packageB with its dependencies during export and install packageB from previosly built whl.
I could use poetry remove packageB before poetry export, but the poetry remove command requires internet access and modifies files in the repository - neither of which is allowed there.
I solve this by processing poetry.lock in the temporally folder and after use poetry export on it.
Could you possibly provide me some suggestions for this case or post-processing only true way?