-
Notifications
You must be signed in to change notification settings - Fork 78
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
Allow building ESMPy with setuptools/pip #49
Conversation
At this point any dependencies, e.g. numpy will not have been installed and so this will liklely fail.
@milliams Thanks so much for this contribution! We noticed the Python 3.10 issues while I was away for the last few weeks, so this is very well received. I just tried to pull your repo but it seems you have removed the non-ESMPy code, so I wasn't able to run the full test suite, which is required for us to merge a pr. If you have a full version let me know. Otherwise I'll try your changes on a full esmf version locally, and then merge this pr so you get the github fame and glory you are due :) |
Great :) I don't think I deleted any of the non-Python code, I can see it all at https://github.com/milliams/esmf/tree/fix_py_build. It looks like CircleCI is failing on a lot of the PRs so maybe there's some misconfiguration there? |
I've just updated this PR to also change the install docs to use The CI is still failing but that seems to be a persistent CircleCI bug. |
As of Python 3.10, upon running
python setup.py install
there is an error printedThe usual way to install packages in Python is using
pip
which follows the recommendations of PEP 632 and can use setuptools. See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for a write-up on this. However, if I try to install ESMPy with:then (after having to manually install
numpy
first) you get the error:It seems there's some subtle change with how
distutils
andsetuptools
work which causes this to fail.This PR
This PR tries to make the minimal change to ESMPy to allow it to be installed with
pip
without changing how it behaves. It makes the following changes:setuptools.setup
function explicitly to ensure modern behaviourBuildCommand
class now also derives from the pre-existingbuild
command to get access to the required state.esmfmkfile.py
file is created in the build tree, not the source treenumpy
is specified as a dependency insetup.py
so that it's automatically installed.Future possible changes
Other potential changes are (you have no issue tracker I can find to suggest/discuss these):
emsfmkfile.py
it is currently hard-coded at build-time to the value ofESMFMKFILE
. I would change this to be able to read this env var at run-time withos.getenv("ESMFMKFILE", "hard/coded/path/from/build")
. And if theESMFMKFILE
variable is not set at build-time, then it will just beos.getenv("ESMFMKFILE")
. This will allow portable builds of ESMPy which can be pointed wherever ESMF is installed.pyproject.toml
which just has the minimum from https://setuptools.pypa.io/en/latest/userguide/quickstart.html#basic-use. This explicitly flags that you are conforming to the spec.setup.py
currently does a lot and is being used like aMakefile
. This is becoming less common and I believe it is deprecated. The test suite should be run directly with some runner (I think you usenose
)wheel
of ESMPy since there's nothing but plain Python code in here. It can be easily installed and could then be distributed via PyPI like all other Python packages instead of justconda
.ESMFMKFILE
and require that it's set at runtime (the docs imply that this is possible, but it doesn't work). This would allow moving to a static build configuration like specified in PEP 621 (setuptools
/flit
/poetry
are all options)