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

deps: Lock Python indirect dependency versions #138

Closed
4 tasks done
Tracked by #136
ethanjli opened this issue May 11, 2023 · 1 comment · Fixed by #175
Closed
4 tasks done
Tracked by #136

deps: Lock Python indirect dependency versions #138

ethanjli opened this issue May 11, 2023 · 1 comment · Fixed by #175
Assignees
Labels

Comments

@ethanjli
Copy link
Member

ethanjli commented May 11, 2023

Motivation

While working on #135, I was stuck in Python dependency hell for a few days because pip chooses the versions of indirect dependencies in a way that is not reproducible ("reproducible" in the sense that if we cloned the PlanktoScope repo one day and ran the install, pip would install the same dependencies as if we cloned the PlanktoScope repo a year later and ran the install). I had problems with binary compatibility and versions of scipy & numpy (which are both direct dependencies in our project), as well as issues with a version of pandas (an indirect dependency in our project) being downloaded at a version for which pip could not find a pre-built binary from piwheels. Without having a way to lock the versions of indirect dependencies, we lack a stable foundation for making sure that our software will continue to build and run correctly in an automated or semi-automated system, even if we make no changes to the software itself.

One dirty solution could be to use pip freeze --all to make requirements.txt pin the versions of all direct and indirect dependencies, but this is undesirable because then we'd have no easy way to determine which dependencies are direct vs. indirect. A more conventional solution would be to use either Poetry or PDM for handling dependencies, instead of pip.

Goals

  • Lock the version of every single Python package which needs to be installed for our Python backend to run.

Steps

  • Set up poetry with a pyproject.toml file for the Python code
  • Migrate the requirements.txt file into the pyproject.toml file
  • Resolve any further Python dependency problems
  • Reintegrate the Python scripts with the Node-RED frontend

Unresolved Questions

  • Will we be able to resolve packages from PyPI for CI and/or for operation on non-RPI computers, e.g. on amd64 or aarch64? (see deps: Lock Python indirect dependency versions #138 (comment))
  • Which dependencies imported from the requirements.txt file are actually indirect dependencies rather than direct dependencies?

Implementation History

@ethanjli
Copy link
Member Author

ethanjli commented May 16, 2023

Note: https://gitlab.com/openflexure/openflexure-microscope-server/-/merge_requests/124 reports issues with Poetry - they migrated to pipenv. This needs to be investigated before we can fully commit to using Poetry. Specifically, I need to try running Poetry on a Raspberry Pi to see if I encounter problems with using (or not using) piwheels, and try running Poetry in CI afterwards to ensure that it still works even after I make piwheels work on the Raspberry Pi. The problem is probably related to the poetry.lock file and file hashing, and it seems like it might've been fixed in 2022 (i.e. after the OpenFlexure project switched from Poetry to Pipenv). For more information, refer to:

According to https://www.piwheels.org/ and after reading https://github.com/orgs/python-poetry/discussions/7057, it looks like I need to lock on Python 3.9.

@ethanjli ethanjli changed the title Lock Python indirect dependency versions deps: Lock Python indirect dependency versions Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

1 participant