Skip to content

Pysox tries to import numpy during build-time, only declared as a run-time dependency #167

Open
@Jacob-Bishop

Description

@Jacob-Bishop

I was trying to install another module that depends on pysox, and ran into the error below, which seems to indicate that in the process of building pysox the module tries to read valid formats from core.py, which incidentally imports numpy (which isn't guaranteed to be installed yet, since the module declares numpy as an installation requirement and not a setup requirement).

I can work around this by installing numpy first, but I ideally wouldn't have to manage sub-dependencies myself. I think the solution here would be to just store valid formats somewhere else, so you can read them during setup without having to run all the imports in core?

FWIW, I found the following thread useful for understanding what's going on here: pypa/pip#6193.

Collecting sox (from nemo-toolkit[all]==1.23.0)
  Downloading sox-1.5.0.tar.gz (63 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 63.9/63.9 kB 855.1 kB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [61 lines of output]
      /usr/lib/python3/dist-packages/setuptools/dist.py:723: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead
        warnings.warn(
      Traceback (most recent call last):
        File "/usr/lib/python3/dist-packages/setuptools/config.py", line 419, in _parse_attr
          return getattr(StaticModule(module_name), attr_name)
        File "/usr/lib/python3/dist-packages/setuptools/config.py", line 26, in __init__
          spec = importlib.util.find_spec(name)
        File "/usr/lib/python3.10/importlib/util.py", line 94, in find_spec
          parent = __import__(parent_name, fromlist=['__path__'])
        File "/tmp/pip-install-itwjnv3t/sox_3bc498e86177470ab7746acf9fa14cac/sox/__init__.py", line 21, in <module>
          from . import file_info
        File "/tmp/pip-install-itwjnv3t/sox_3bc498e86177470ab7746acf9fa14cac/sox/file_info.py", line 9, in <module>
          from .core import VALID_FORMATS
        File "/tmp/pip-install-itwjnv3t/sox_3bc498e86177470ab7746acf9fa14cac/sox/core.py", line 8, in <module>
          import numpy as np
      ModuleNotFoundError: No module named 'numpy'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions