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

Can't install satpy with pip #2130

Closed
peterdudfield opened this issue Jun 22, 2022 · 13 comments
Closed

Can't install satpy with pip #2130

peterdudfield opened this issue Jun 22, 2022 · 13 comments
Labels

Comments

@peterdudfield
Copy link

peterdudfield commented Jun 22, 2022

Describe the bug
Get errors when install satpy with pip

Has anyone else found this? I'm really sorry if it is just my computer

To Reproduce

pip install satpy

Note it does work with

pip install git+https:/pytroll/satpy.git

Expected behavior
the package to install

Actual results

has inconsistent version: filename has '0.31.0', but metadata has '0.0'

Screenshot 2022-06-22 at 07 54 10

Environment Info:

  • OS: MAC
  • Satpy Version: [e.g. 0.36.0]
@djhoese
Copy link
Member

djhoese commented Jun 22, 2022

😕 That is very strange since the newest version is 0.36.0. Just to be sure can you add a -U flag between install and git+ and see if that changes the results? What kind of environment are you installing this on (pip-based, conda-base)? Did this environment have satpy installed in it before? What version of Python?

@djhoese
Copy link
Member

djhoese commented Jun 22, 2022

Oh sorry, I misread your message. I thought the git install wasn't working. What version of python are you using?

@pdebuyl
Copy link
Contributor

pdebuyl commented Jun 27, 2022

Using python3.9, pip install satpy gives me version 0.33.1

Relevant log

(tis) pierre@pierre-hp:/tmp/tmp$ pip install satpy
Collecting satpy
  Downloading satpy-0.36.0.tar.gz (1.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 3.5 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Discarding https://files.pythonhosted.org/packages/78/63/fb97b0cc15c43058cc6c2942bd9a1deb89864800d7c5ae048633226fd096/satpy-0.36.0.tar.gz#sha256=f1c201f1d53dfda27856576461079eb9d78531e21ddc055baea20cb47f114107 (from https://pypi.org/simple/satpy/) (requires-python:>=3.7): Requested satpy from https://files.pythonhosted.org/packages/78/63/fb97b0cc15c43058cc6c2942bd9a1deb89864800d7c5ae048633226fd096/satpy-0.36.0.tar.gz#sha256=f1c201f1d53dfda27856576461079eb9d78531e21ddc055baea20cb47f114107 has inconsistent version: filename has '0.36.0', but metadata has '0.0'
  Downloading satpy-0.35.0.tar.gz (1.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 3.7 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Discarding https://files.pythonhosted.org/packages/06/e8/a7d340e00486f507527b608399dbac8227ecb2ca21148cc0809461715395/satpy-0.35.0.tar.gz#sha256=05bdbc947a5be22f3b9d45f1cf2a4e9b1ca69346cb629fada009a0d3261b3a63 (from https://pypi.org/simple/satpy/) (requires-python:>=3.7): Requested satpy from https://files.pythonhosted.org/packages/06/e8/a7d340e00486f507527b608399dbac8227ecb2ca21148cc0809461715395/satpy-0.35.0.tar.gz#sha256=05bdbc947a5be22f3b9d45f1cf2a4e9b1ca69346cb629fada009a0d3261b3a63 has inconsistent version: filename has '0.35.0', but metadata has '0.0'
  Downloading satpy-0.34.0.tar.gz (1.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 3.6 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Discarding https://files.pythonhosted.org/packages/44/df/96e824f8232b50d22c714965abf9b0622454fefea87c68c05c60502f38b8/satpy-0.34.0.tar.gz#sha256=225d11062def129459a87810fa766cef8f1107a6e58dc99da29791f7dfcc963b (from https://pypi.org/simple/satpy/) (requires-python:>=3.7): Requested satpy from https://files.pythonhosted.org/packages/44/df/96e824f8232b50d22c714965abf9b0622454fefea87c68c05c60502f38b8/satpy-0.34.0.tar.gz#sha256=225d11062def129459a87810fa766cef8f1107a6e58dc99da29791f7dfcc963b has inconsistent version: filename has '0.34.0', but metadata has '0.0'
  Using cached satpy-0.33.1-py2.py3-none-any.whl

@pdebuyl
Copy link
Contributor

pdebuyl commented Jun 27, 2022

BTW, I can't find a version info in setup.py or setup.cfg. There used to be use_scm_version in setup.py but it disappeared.

The way to store version info in pyproject.toml is:

[project]
name = "satpy"
version = "0.36.0"
(...)

https://peps.python.org/pep-0621/#version

@djhoese
Copy link
Member

djhoese commented Jun 27, 2022

It seems like @mraspaud removed the setup.py options in #1848 but then never moved them to pyproject.toml as described in the setuptools-scm docs:

https://pypi.org/project/setuptools-scm/

For example:

[tool.setuptools_scm]
write_to = "pkg/_version.py"

@pdebuyl How would you feel about make a PR to add this information to the pyproject.toml?

@djhoese djhoese changed the title Can install satpy with pip Can't install satpy with pip Jun 27, 2022
@djhoese djhoese added the bug label Jun 27, 2022
@pdebuyl
Copy link
Contributor

pdebuyl commented Jun 27, 2022

I overlooked the commit. Actually there is write_to = "satpy/version.py" in the pyproject.toml. So the question is how to make sure that it is picked up by PyPI.

@djhoese
Copy link
Member

djhoese commented Jun 27, 2022

Ah there is. Not sure how I missed that. That's what I get for commenting before I've fully woken up. Last week when you first made this issue I looked at the .tar.gz from PyPI and I didn't see anything suspicious (like a version of 0.0) but I may have been looking in the wrong places. So step 1 is I need to reproduce this. Step 2 is figure out what we can check in the .tar.gz to verify that the version is correct. In other pytroll packages that generate wheels we have extra checks to import the package and verify the version, but we've never needed that on an sdist .tar.gz before.

@djhoese
Copy link
Member

djhoese commented Jun 27, 2022

So according to this stackoverflow answer this is a change in pip and can be temporarily worked around by using --use-deprecated=legacy-resolver on the pip install command. I'll see what I can learn as far as what we need to change in our packaging to resolve this.

@djhoese
Copy link
Member

djhoese commented Jun 27, 2022

Ok, here's how I'm testing all of this:

conda create -y -n test_satpy_version python=3.9 setuptools pip build satpy
conda activate test_satpy_version
conda uninstall --force -y satpy

This produces a usable environment. If you do pip install satpy after the above then you get the warnings and failure to install. If you do the legacy-resolver line in my previous comment then it works. If you download the tarball and build a wheel from that then it also has the 0.0 in the filename.

wget "https://files.pythonhosted.org/packages/78/63/fb97b0cc15c43058cc6c2942bd9a1deb89864800d7c5ae048633226fd096/satpy-0.36.0.tar.gz#sha256=f1c201f1d53dfda27856576461079eb9d78531e21ddc055baea20cb47f114107"
tar -xzf satpy-0.36.0.tar.gz
cd satpy-0.36.0

cat satpy/version.py
# coding: utf-8
# file generated by setuptools_scm
# don't change, don't track in version control
version = '0.36.0'
version_tuple = (0, 36, 0)

python -m build -w .
# ...
Successfully built satpy-0.0-py2.py3-none-any.whl

cat satpy/version.py
# coding: utf-8
# file generated by setuptools_scm
# don't change, don't track in version control
__version__ = version = '0.0'
__version_tuple__ = version_tuple = (0, 0)

So apparently setuptools-scm doesn't have all the information in the tarball to work properly or at least it doesn't think it does. It is then recreating satpy/version.py with the wrong metadata.

@djhoese
Copy link
Member

djhoese commented Jun 27, 2022

$ python -m setuptools_scm
/home/davidh/miniconda3/envs/test_satpy_version/lib/python3.9/site-packages/setuptools_scm/git.py:283: UserWarning: git archive did not support describe output
  warnings.warn("git archive did not support describe output")
0.0

@djhoese
Copy link
Member

djhoese commented Jun 27, 2022

I can reproduce this by making the sdist with my own clone. I can also get a successfully working wheel if I edit the pyproject.toml from the tarball and use setuptools_scm version 6.3.2. My guess is that version 7.x which added git support directly now requires the .git directory in the sdist...at least that's my guess.

Edit: Version 6.4.2 seems to fail too. Nevermind, I did it wrong. 6.4.2 is fine.

@djhoese
Copy link
Member

djhoese commented Jun 27, 2022

See pypa/setuptools-scm#735

@djhoese
Copy link
Member

djhoese commented Jul 1, 2022

setuptools-scm 7.0.4 was just released and it looks like it fixes this. Running the same instructions as above now works. I'm going to close this, but if you try this out again and it still doesn't work comment here and we can reopen it.

@djhoese djhoese closed this as completed Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants