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
Clean up python dependencies #1429
Conversation
Are you not using Black for code formatting? |
We are (and we should use mypy, etc.) So when this PR is ready for review, I'll have them back in somewhere (thinking now in the form of a dev requirements.txt). It doesn't make sense to me to be installing development dependencies (black, etc.) inside the django container where they will never be used. This whole quest came about because I tried to install the current cantusdb |
curious what you think of the My understanding is that it was added at the beginning of the project as a best practice to evaluate our test suite, and yet it hasn't been used for as long as I've been working on the project. |
Yes, that's my understanding of what it is. But since I'm not seeing it used anywhere.... (whether it would be a good idea to is another matter) |
That's what |
Right... I guess we could use this as the excuse to move to poetry.... |
Okay, so having looked into this, I think all we need is a bit of documentation on how to use |
d31143c
to
316fa78
Compare
pyproject.toml
Outdated
[tool.poetry.group.test] | ||
optional = true | ||
|
||
[tool.poetry.group.test.dependencies] |
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 think I see where you're going with this, but wouldn't it be OK to just have dev
? Do you routinely install the dev dependencies without the test ones? Or vice versa?
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 waffling on whether to have separate debug
and test
groups, because I can't think of a case where you'd install one or not the other.
Technically, what's in the dev
group currently doesn't ever need to be installed inside the container (code formatting and type checking can happen outside the container environment), whereas those dependencies that are in the debug
and test
groups do (because they extend, a la django-debug-toolbar
, the django app itself).
So, it's a Docker-induced distinction. Does it really matter that we keep them separate? (ie. does anything break if we start installing black inside the container?) No, so we could definitely combine them.
Thoughts?
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.
Thanks for cleaning up these dependencies! I'm not a poetry expert, but it seems like this is moving us in the right direction for future development.
So, was the decision about the black and mypy dependencies to install them in the container or are we having a separate dev requirements.txt file?
Thanks! I'm going to make some changes to the wiki and post them here too before I merge.
I went with having three groups:
All three groups are defined in the |
Ok, for additional documentation, I've:
|
This PR makes a number of changes to how CantusDB handles python dependencies. It introduces
poetry
as our dependency management tool, removes a number of superfluous, unnecessary, or deprecated python dependencies, and groups dependencies to more clearly divide various environments (the in-container application environment, local development enviroments, etc.)Dependencies are now divided into the following groups:
django
container for the Django application to run.debug
dependencies. This currently includesdjango_debug_toolbar
and is necessary in the container for debugging.test
dependencies. These are dependencies used inside the container for the test suite.dev
dependencies. There are dependencies that are useful in development outside the application container.When the build argument
PROJECT_ENVIRONMENT
is set toDEVELOPMENT
, the required,debug
, andtest
dependencies are installed in the application container. When that argument is not set or is set toPRODUCTION
orSTAGING
, only required dependencies are installed.The following dependencies that were previously included in
requirements.txt
are not included inpyproject.toml
as dependencies:typed_ast
-- this has been deprecated as of July 2023 (see typed_ast end of life (July 2023) python/typed_ast#179)appdirs
-- a package for defining platform-specific directories. Was not used in codebase and the application is only ever running on one platform (i.e. in the docker container).asgiref
-- a Django dependency, otherwise unused.astroid
-- a pylint dependency, otherwise unused.attrs
-- unused, unclear why included.backports.zone-info
-- unused, unclear why included.certifi
,chardet
,charset-normalizer
,idna
,urllib3
-- requests package dependencies, otherwise unused.click
-- a black dependency, otherwise unusedisort
-- an import sorter (dev dependency), we can usepylint
for thislazy-object-proxy
,wrapt
-- a pylint dependency, by way ofastroid
lxml
-- unusedmccabe
-- a pylint dependency, otherwise unusedmypy-extensions
,typing-extensions
-- a mypy dependency, otherwise unusedpsycopg2
-- will likely be deprecated at some point for django's purposes (see https://docs.djangoproject.com/en/5.0/ref/databases/#postgresql-notes), upgraded topsycopg
python-dateutil
,text-unidecode
-- a Faker dependency, otherwise unusedpytz
-- unusedregex
-- unusedsix
-- a django-extra-views and django-autocomplete-light dependency, otherwise unusedsqlparse
-- a django dependency, otherwise unusedtoml
-- unusedThis PR will require changes/additions to the wiki around setting up the local development environment.
Closes #1428.