Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from Pipenv to Poetry #61

Closed
sco1 opened this issue Jan 19, 2020 · 4 comments
Closed

Migrate from Pipenv to Poetry #61

sco1 opened this issue Jan 19, 2020 · 4 comments
Assignees
Milestone

Comments

@sco1
Copy link
Owner

sco1 commented Jan 19, 2020

I'd like to propose for discussion migrating the management of the developer environment from Pipenv to Poetry.

I've created a branch with a complete migration of the project for investigation here: https://github.com/python-discord/flake8-annotations/tree/poetry-adventures

I will state up front that there is no major advantage to making this switch, but rather a collection of minor differences that contribute to what I believe is an overall improvement for the developer. In the fairly recent past PyDis looked into migrating all of the repositories to Poetry, as at the time there was a mix between Pipenv and Poetry utilization. It was decided to unify on Pipenv, as it provides some functionality that's very useful for local development, like pipenv run scripts and support for local .env files when executing these scripts. It also provides the useful check for an up-to-date lock file during deployment for the build to proceed. Poetry's advantages related to building & uploading to PyPI are not useful for most of our repositories since they do not live on PyPI.

Pipenv's deployment-specific advantages

As flake8-annotations is a library, Pipenv's deployment-specific advantages & .env file support are not relevant here.

Poetry's lack of a pipenv run script equivalent

While Poetry does have a poetry run command, it lacks Pipenv's capability for defining scripts in the project configuration and instead is limited to executing the project via defined entry points. While a disadvantage for some of our other repositories that utilize some fairly detailed scripts to reduce developmoent tasks to one-liners, development of flake8-annotations has no need for this enhanced functionality. Both linting (poetry run flake8) and testing (tox) are similarly simply accomplished. poetry run flake8 is also insertable into the pre-commit config, preventing us from having to sync linting dependencies in the config file; we're currently using pipenv run lint to accomplish the same.

Simplification of dependency definition

Currently, project dependencies need to be synced between the Pipfile and setup.py. While we have a CI tool to check for synchronization (pipenv-check), which helps, it only checks for version conflicts and not absolute synchronization. Migrating to Poetry allows us to utilize a singular pyproject.toml file for dependency specifications. As it is a Python standard (ish?) format, it's supported by pip for installation without requiring Poetry as well. As the support landscape expands, things like tox and flake8 would also be able to be migrated into the file as well (tox currently has support but it's as a giant string, which I feel is less readable). This is a pretty significant quality of life advantage over Pipenv.

I have plans to declare black as an explicit dev dependency (it's already run locally), which requires pyproject.toml anyway.

Poetry's build tools

Poetry also provides built-in build tools, allowing for distributions to be built via the poetry built one-liner. While the python setup.py sdist bdist_wheel isn't super challenging, and is run by CI only anyway, it's still a nice simplifying one-liner to have.

Pipenv's future?

With pipenv's transfer of ownership to PyPA, development publically seems to have stalled. While the developers have fairly recently stated that work is progressing & blocked by a myriad of issues, communication has been scarce. Poetry, on the other hand, has a very active development cycle, with a recent 1.0 release & impending addition of a plugin API to support OSS contributions of functionality that is lacking from the core tool.

@sco1 sco1 added question Request for clarification or further information devops labels Jan 19, 2020
@scragly
Copy link
Contributor

scragly commented Jan 19, 2020

I think with the libs, poetry does make a lot more sense than using pipenv. We're still getting the benefits we want, the only prior concern was with cli entrypoint scripts, however considering you only really need to invoke a module for the existing ones (flake8 instead of lint, etc), there's no significant reason to worry about the loss.

@sco1 sco1 added this to the v1.2.0 milestone Jan 30, 2020
@sco1 sco1 self-assigned this Jan 30, 2020
@sco1 sco1 added work in progress and removed question Request for clarification or further information labels Jan 30, 2020
@sco1
Copy link
Owner Author

sco1 commented Jan 30, 2020

Merged into #60

@sco1 sco1 closed this as completed Jan 30, 2020
@sco1 sco1 mentioned this issue Jan 30, 2020
@wanderrful
Copy link

wanderrful commented Jul 8, 2020

Using Python ^3.7 or ^3.8 in your pyproject.toml file prevents adding this package via poetry add:

[SolverProblemError]
The current project's Python requirement (^3.8) is not compatible with some of the required packages Python requirement:
  - flake8-annotations requires Python >=3.6.1,<3.9

Because no versions of flake8-annotations match >2.2.0,<3.0.0
 and flake8-annotations (2.2.0) requires Python >=3.6.1,<3.9, flake8-annotations is forbidden.
So, because tool-belt depends on flake8-annotations (^2.2.0), version solving failed.

Not sure if this is worth making its own issue for. Thought it was related, so I'm sharing here instead.

Could potentially be related to #85

@sco1
Copy link
Owner Author

sco1 commented Jul 8, 2020

Can you please make a new issue? This isn't really related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants