-
Notifications
You must be signed in to change notification settings - Fork 448
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
[WIP] Use poetry #715
[WIP] Use poetry #715
Conversation
Currently |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of comments!
I wrote this a couple of months ago and forgot to update this, but feel free to take some pointers from here if you are struggling with the documentation.
"Anita Borg", | ||
"Poetry", | ||
"Flask", | ||
"Women in Technology"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a hard time digesting poetry
's suitable for just dependency management when using with Django, because of the way it enforces package information, which is largely redundant here for the most part.
This is why my mind says to go with pip-tools
when working with Django, even though I myself really like Poetry! 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have much experience with Django so you're probably right😁Idk how the situation looks like when using Flask
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I mean both Django/Flask, apologies, anything that is not a Python package, basically.
urllib3 = "^1.22" | ||
wcwidth = "^0.1.7" | ||
websocket-client = "^0.48.0" | ||
Werkzeug = "^0.15.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need all of the pacakages here? I am pretty sure some of them are actually sub deps of other packages, that have creep'd into here (more reason for doing this 🙂 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll go through them and remove the subdeps:)
@@ -1,74 +0,0 @@ | |||
alembic==1.4.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need to exacly remove this file, this file can still be used, especially with Docker!
Accurate dependency resolution is a hard problem, and poetry does it really well, so it takes a toll on time required for doing poetry install
, instead we can make sure to always export our dependencies to a requirements.txt
file, which would contain pinned versions and hash checks.
We can then re-use this file for people who absolutely still cannot use poetry for some reason, and we should also use this file for things like CI and deployment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would simply auto-generating this file (during a e.g CI) be a good solution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the dev would generate and commit it (there are even git commit hooks for that) whenever the dev adds/updates/removes a package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why? If it's the only purpose would be to be utilized by CI, then I think it's better to hide it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only reason is because it is simpler, there are enough issues on the Poetry repo about the dependency resolution taking ages sometimes, because it's a costly operation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was taking a shower when I realized that my question (above) is stupid and the reason is obvious. I agree totally with this.
@@ -0,0 +1,11 @@ | |||
# This is a temporary workaround till Poetry supports scripts, see | |||
# https://github.com/sdispater/poetry/issues/241. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish this was done soon enough with poetry, but they have been prioritizing with other things.
|
||
|
||
def test(): | ||
check_call(["python", "-m", "unittest", "discover", "tests"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also add scripts for linting / autoformatting 🙂
3. Install all the dependencies in `requirements.txt` file: | ||
`pip install -r requirements.txt` | ||
3. Activate the virtual environment (auto-crated by Poetry): | ||
`poetry shell` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also document briefly about poetry run
or poetry shell
, that would be helpful for people who still use virtualenv driven dev, so to speak 🙂
missing ending Co-authored-by: Isabel Costa <isabelcmdcosta@gmail.com>
@isabelcosta @SanketDG Please review the newest changes:)
|
I also tested this with Python 3.8 and all tests pass, so I think it's a great idea to bump the recommended Python version to 3.8 |
Dropping this here, seems useful Edit (for caching): python-poetry/poetry#366 (comment) |
Thank you @SanketDG. I'm busy right now but will surely find some time in the future to finish this PR |
I'd like to finish this issue (hey, it's Hacktoberfest!) as soon as I get my laptop back. Just pinging so it doesn't get closed:) |
@bartekpacia ack |
a new PR #914 is up, so I'm closing this:) |
Description
Migrated to Poetry as our default dependency management tool. It's simple, yet powerful.
pyproject.toml
requirements.txt
Docker is currently broken I'm not sure how to fix this!
fixes #691
Type of Change:
Code/Quality Assurance Only
How Has This Been Tested?
Run the test suite, all tests pass.
Checklist:
Update requirements.txtNot anymore! Updatedpyproject.toml
hahaCode/Quality Assurance Only