kylebgorman / pynini

Read-only mirror of Pynini
http://pynini.opengrm.org
Apache License 2.0
122 stars 27 forks source link

Pip install pynini==2.1.6 metadata error #77

Closed Atmelfan closed 4 months ago

Atmelfan commented 4 months ago

Trying to install pynini==2.1.6 from pip results in the following error.

nvidia@ubuntu:/tmp/openfst-1.8.3$ pip install pynini==2.1.6
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Collecting pynini==2.1.6
  Downloading pynini-2.1.6.tar.gz (789 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 789.8/789.8 KB 9.1 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
  WARNING: Requested pynini==2.1.6 from https://files.pythonhosted.org/packages/9b/69/4b59968b0fd351a153d7a3c2feaa6e7514c903c063bbd7f7e1e3f1c079b0/pynini-2.1.6.tar.gz#sha256=b09b6dda73608cedf962dbfbcfa5826b0984d1b43a8f995761972e6e032921c6, but installing version 2.1.5
Discarding https://files.pythonhosted.org/packages/9b/69/4b59968b0fd351a153d7a3c2feaa6e7514c903c063bbd7f7e1e3f1c079b0/pynini-2.1.6.tar.gz#sha256=b09b6dda73608cedf962dbfbcfa5826b0984d1b43a8f995761972e6e032921c6 (from https://pypi.org/simple/pynini/) (requires-python:>=3.6): 
Requested pynini==2.1.6 from https://files.pythonhosted.org/packages/9b/69/4b59968b0fd351a153d7a3c2feaa6e7514c903c063bbd7f7e1e3f1c079b0/pynini-2.1.6.tar.gz#sha256=b09b6dda73608cedf962dbfbcfa5826b0984d1b43a8f995761972e6e032921c6
 has inconsistent version: filename has '2.1.6', but metadata has '2.1.5'
ERROR: Could not find a version that satisfies the requirement pynini==2.1.6 (from versions: 0.4.1, 0.4.2, 0.4.3, 0.4.4, 2.0.9.post2, 2.1.4, 2.1.5, 2.1.5.post1, 2.1.5.post2, 2.1.6)
ERROR: No matching distribution found for pynini==2.1.6

Downloading the tar archive from https://files.pythonhosted.org/packages/9b/69/4b59968b0fd351a153d7a3c2feaa6e7514c903c063bbd7f7e1e3f1c079b0/pynini-2.1.6.tar.gz#sha256=b09b6dda73608cedf962dbfbcfa5826b0984d1b43a8f995761972e6e032921c6 and extracting pynini/__init__.py shows the following which seems to contain the wrong version number:

from _pynini import *

# Increment after every release.

__version__ = "2.1.5"

The pyproject.toml shows the correct version

[project]
name = "pynini"
version = "2.1.6"
kylebgorman commented 4 months ago

The metadata in question has nothing to do with the version string in __init__.py so I think that's a red herring. I have no idea why the metadata in question is something other than what's in pyproject.toml.

(I need some more information to try to replicate. What's your OS and hardware? What Python version are you installing from?)

Atmelfan commented 4 months ago

Ubuntu 20.04, aarch64, python 3.10.12

Atmelfan commented 4 months ago

Not really familiar with pip and python distribution but this in setup.py from the downloaded tar archive looks suspicious to me.

__version__ = get_version("pynini/__init__.py") # 2.1.5?

def main() -> None:
  setup(
      name="pynini",
      version=__version__,
      author="Kyle Gorman",
      author_email="kbg@google.com",
      description="Finite-state grammar compilation",
      long_description=long_description,
      long_description_content_type="text/markdown",
      url="http://pynini.opengrm.org",
      keywords=[
          "natural language processing",
          "speech recognition",
          "machine learning",
      ],
      classifiers=[
          "Programming Language :: Python :: 3.7",
          "Programming Language :: Python :: 3.8",
          "Programming Language :: Python :: 3.9",
          "Programming Language :: Python :: 3.10",
          "Programming Language :: Python :: 3.11",
          "Programming Language :: Python :: 3.12",
          "Development Status :: 5 - Production/Stable",
          "Environment :: Other Environment",
          "Environment :: Console",
          "Intended Audience :: Developers",
          "License :: OSI Approved :: Apache Software License",
          "Operating System :: OS Independent",
          "Topic :: Software Development :: Libraries :: Python Modules",
          "Topic :: Text Processing :: Linguistic",
          "Topic :: Scientific/Engineering :: Artificial Intelligence",
          "Topic :: Scientific/Engineering :: Mathematics",
      ],
      license="Apache 2.0",
      ext_modules=cythonize([pywrapfst, pynini]),
      packages=find_packages(exclude=["scripts", "tests"]),
      package_data={
          "pywrapfst": ["__init__.pyi", "py.typed"],
          "pynini": ["__init__.pyi", "py.typed"],
          "pynini.examples": ["py.typed"],
          "pynini.export": ["py.typed"],
          "pynini.lib": ["py.typed"],
      },
      zip_safe=False,
  )
kylebgorman commented 4 months ago

Oh good find. I would have thought what was in pyproject.toml would have taken precedence. I can put out a post-release to correct this: it shouldn't affect things otherwise.

pengpengtao commented 4 months ago

Ubuntu 20.04、aarch64、python 3.10.12

Hello, my friend, I am facing the same issue in my environment. Could you please share how you addressed it? I am looking forward to your reply image

Atmelfan commented 4 months ago

@pengpengtao I solved it by building and installing openfst and pynini from source. See here.

pengpengtao commented 4 months ago

我通过从源代码构建和安装 openfst 和 pynini 解决了这个问题。请看这里。

Thank you very much for your help, I have already solved this problem