CAST-genomics / haptools

Ancestry and haplotype aware simulation of genotypes and phenotypes for complex trait analysis
https://haptools.readthedocs.io
MIT License
18 stars 4 forks source link

feat: support for python 3.11 #207

Closed aryarm closed 8 months ago

aryarm commented 1 year ago

This PR finally adds support for python 3.11 to haptools!

Hopefully, we can get this PR merged before bioconda tries to test our package with 3.11 in January (source).

Note: This PR also upgrades the versions of poetry and python that we use in our development environment. Once this is merged, haptools developers will need to create a new development environment by following the updated directions in the contributing docs.

aryarm commented 1 year ago

we're currently blocked by https://github.com/cjolowicz/nox-poetry/issues/1116

Otherwise, if we can't find a solution there, we'll have to drop support for python 3.7 in order to support python 3.11

aryarm commented 9 months ago

I almost can't believe I finally got all of the checks to pass lol

@mlamkin7, when you have a chance, can you review this?

Also just a heads up that the approach I took isn't great. Because of the issue I mentioned in https://github.com/CAST-genomics/haptools/pull/207#issuecomment-1514241521, I wasn't able to lock our dependencies for the python 3.11 check. This means that our CI may occasionally fail for python 3.11 at random times because of reasons that are out of our control. Specifically, if one of our dependencies uploads a new release with a bug in it, our python 3.11 check will be run with that bug. If that happens, we won't have any way to deal with it except to wait until the bug gets patched. We can also override that check if we really need to get the PR merged, of course.

Fortunately, I have an idea for a longer term solution: multiple constraint dependencies! We can constrain numpy>=0.20.0 for python==3.7 but constrain numpy>=0.21.5 for python>=3.8. That will allow us to maintain two different versions of numpy in our lock file. That won't currently work because of https://github.com/python-poetry/poetry-plugin-export/issues/183, but once that gets resolved, we should be able to revert this code in our Noxfile and update the macos check to run on py 3.11 instead of py3.9 as it does now.

One other note: You might notice that I made some changes to clump.py, test_clump.py, and test_data.py in this PR. Those changes aren't strictly necessary, so we can revert them if you'd like. I originally added them on a hunch that they may be contributing to a platform-specific error that I was observing, but the error turned out to be due to a bug that was patched in numpy 1.21.4, instead.