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

Switch to "pyproject.toml" and src layout: Installing from source is not easy on WSL Linux and MacOS #336

Open
omid-b opened this issue Sep 8, 2023 · 10 comments

Comments

@omid-b
Copy link

omid-b commented Sep 8, 2023

Issue explanation

Trying to install discretize from source using the recommended/typical instructions does not work on Linux (tested on WSL linux) and MacOS. This is easily replicable when trying to install using the following methods even in a fresh Conda environment (installing discretize in a fresh python environment, using virtualenv or venv, is even more difficult):

  • python setup.py install (suggested in current documentation)
  • pip install .

Before I demonstrate the issue, I create a fresh conda environment using the following commands:

conda create -p env python=3.10 && conda activate env/

Example to show the issue

My first try...

$ python setup.py install
Traceback (most recent call last):
  File "/mnt/c/Users/baghom/Desktop/discretize-main/setup.py", line 80, in <module>
    from Cython.Build import cythonize
ModuleNotFoundError: No module named 'Cython'

Okay, let's install cython first...

$ pip install cython
Collecting cython
  Obtaining dependency information for cython from https://files.pythonhosted.org/packages/e8/1a/26113a7a220b360a13f1a060deb1461bf55d433673dc79e523b6648ccc2d/Cython-3.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
  Using cached Cython-3.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.1 kB)
Using cached Cython-3.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB)
Installing collected packages: cython
Successfully installed cython-3.0.2

Try again ...

$ python setup.py install
Traceback (most recent call last):
  File "/mnt/c/Users/baghom/Desktop/discretize-main/setup.py", line 81, in <module>
    import numpy as np
ModuleNotFoundError: No module named 'numpy'

Okay, we need numpy too, and python setup.py install cannot figure out the install dependencies!

$ pip install numpy
Collecting numpy
  Obtaining dependency information for numpy from https://files.pythonhosted.org/packages/71/3c/3b1981c6a1986adc9ee7db760c0c34ea5b14ac3da9ecfcf1ea2a4ec6c398/numpy-1.25.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
  Using cached numpy-1.25.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (5.6 kB)
Using cached numpy-1.25.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.2 MB)
Installing collected packages: numpy
Successfully installed numpy-1.25.2

Try again...

$ python setup.py install
Compiling discretize/_extensions/interputils_cython.pyx because it depends on /mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd.
Compiling discretize/_extensions/tree_ext.pyx because it depends on /mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd.
Compiling discretize/_extensions/simplex_helpers.pyx because it depends on /mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/numpy/__init__.cython-30.pxd.
[1/3] Cythonizing discretize/_extensions/interputils_cython.pyx
/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/Cython/Compiler/Main.py:384: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /mnt/c/Users/baghom/Desktop/discretize-main/discretize/_extensions/interputils_cython.pxd
  tree = Parsing.p_module(s, pxd, full_module_name)
[2/3] Cythonizing discretize/_extensions/simplex_helpers.pyx
[3/3] Cythonizing discretize/_extensions/tree_ext.pyx
/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/__init__.py:84: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!

        ********************************************************************************
        Requirements should be satisfied by a PEP 517 installer.
        If you are using pip, you can try `pip install --use-pep517`.
        ********************************************************************************

!!
  dist.fetch_build_eggs(dist.setup_requires)
Traceback (most recent call last):
  File "/mnt/c/Users/baghom/Desktop/discretize-main/setup.py", line 130, in <module>
    setup(**metadata)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/__init__.py", line 107, in setup
    return distutils.core.setup(**attrs)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 147, in setup
    _setup_distribution = dist = klass(attrs)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/dist.py", line 486, in __init__
    _Distribution.__init__(
  File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 283, in __init__
    self.finalize_options()
  File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/dist.py", line 925, in finalize_options
    ep(self)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/dist.py", line 945, in _finalize_setup_keywords
    ep.load()(self, ep.name, value)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/.eggs/setuptools_scm-7.1.0-py3.10.egg/setuptools_scm/integration.py", line 91, in version_keyword
    _assign_version(dist, config)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/.eggs/setuptools_scm-7.1.0-py3.10.egg/setuptools_scm/integration.py", line 63, in _assign_version
    _version_missing(config)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/.eggs/setuptools_scm-7.1.0-py3.10.egg/setuptools_scm/__init__.py", line 108, in _version_missing
    raise LookupError(
LookupError: setuptools-scm was unable to detect version for /mnt/c/Users/baghom/Desktop/discretize-main.

Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.

For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj

Let's use the pip method...

$ pip install .
Processing /mnt/c/Users/baghom/Desktop/discretize-main
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [38 lines of output]
      /mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/__init__.py:84: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
      !!

              ********************************************************************************
              Requirements should be satisfied by a PEP 517 installer.
              If you are using pip, you can try `pip install --use-pep517`.
              ********************************************************************************

      !!
        dist.fetch_build_eggs(dist.setup_requires)
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/mnt/c/Users/baghom/Desktop/discretize-main/setup.py", line 130, in <module>
          setup(**metadata)
        File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/__init__.py", line 107, in setup
          return distutils.core.setup(**attrs)
        File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 147, in setup
          _setup_distribution = dist = klass(attrs)
        File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/dist.py", line 486, in __init__
          _Distribution.__init__(
        File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 283, in __init__
          self.finalize_options()
        File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/dist.py", line 925, in finalize_options
          ep(self)
        File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/dist.py", line 945, in _finalize_setup_keywords
          ep.load()(self, ep.name, value)
        File "/mnt/c/Users/baghom/Desktop/discretize-main/.eggs/setuptools_scm-7.1.0-py3.10.egg/setuptools_scm/integration.py", line 91, in version_keyword
          _assign_version(dist, config)
        File "/mnt/c/Users/baghom/Desktop/discretize-main/.eggs/setuptools_scm-7.1.0-py3.10.egg/setuptools_scm/integration.py", line 63, in _assign_version
          _version_missing(config)
        File "/mnt/c/Users/baghom/Desktop/discretize-main/.eggs/setuptools_scm-7.1.0-py3.10.egg/setuptools_scm/__init__.py", line 108, in _version_missing
          raise LookupError(
      LookupError: setuptools-scm was unable to detect version for /mnt/c/Users/baghom/Desktop/discretize-main.

      Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.

      For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Add flag --use-pep517

$ pip install . --use-pep517
Processing /mnt/c/Users/baghom/Desktop/discretize-main
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [45 lines of output]
      /tmp/pip-build-env-yrpdzwnt/normal/lib/python3.10/site-packages/Cython/Compiler/Main.py:384: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /mnt/c/Users/baghom/Desktop/discretize-main/discretize/_extensions/interputils_cython.pxd
        tree = Parsing.p_module(s, pxd, full_module_name)
      Compiling discretize/_extensions/interputils_cython.pyx because it depends on /tmp/pip-build-env-yrpdzwnt/normal/lib/python3.10/site-packages/Cython/Includes/cpython/object.pxd.
      Compiling discretize/_extensions/tree_ext.pyx because it depends on /tmp/pip-build-env-yrpdzwnt/normal/lib/python3.10/site-packages/Cython/Includes/libcpp/vector.pxd.
      Compiling discretize/_extensions/simplex_helpers.pyx because it depends on /tmp/pip-build-env-yrpdzwnt/normal/lib/python3.10/site-packages/Cython/Includes/libcpp/pair.pxd.
      [1/3] Cythonizing discretize/_extensions/simplex_helpers.pyx
      [2/3] Cythonizing discretize/_extensions/tree_ext.pyx
      [3/3] Cythonizing discretize/_extensions/interputils_cython.pyx
      Traceback (most recent call last):
        File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
        File "/tmp/pip-build-env-yrpdzwnt/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 396, in prepare_metadata_for_build_wheel
          self.run_setup()
        File "/tmp/pip-build-env-yrpdzwnt/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 507, in run_setup
          super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
        File "/tmp/pip-build-env-yrpdzwnt/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in run_setup
          exec(code, locals())
        File "<string>", line 130, in <module>
        File "/tmp/pip-build-env-yrpdzwnt/overlay/lib/python3.10/site-packages/setuptools/__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
        File "/tmp/pip-build-env-yrpdzwnt/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 147, in setup
          _setup_distribution = dist = klass(attrs)
        File "/tmp/pip-build-env-yrpdzwnt/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 302, in __init__
          _Distribution.__init__(
        File "/tmp/pip-build-env-yrpdzwnt/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 283, in __init__
          self.finalize_options()
        File "/tmp/pip-build-env-yrpdzwnt/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 692, in finalize_options
          ep(self)
        File "/tmp/pip-build-env-yrpdzwnt/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 712, in _finalize_setup_keywords
          ep.load()(self, ep.name, value)
        File "/tmp/pip-build-env-yrpdzwnt/normal/lib/python3.10/site-packages/setuptools_scm/integration.py", line 91, in version_keyword
          _assign_version(dist, config)
        File "/tmp/pip-build-env-yrpdzwnt/normal/lib/python3.10/site-packages/setuptools_scm/integration.py", line 63, in _assign_version
          _version_missing(config)
        File "/tmp/pip-build-env-yrpdzwnt/normal/lib/python3.10/site-packages/setuptools_scm/__init__.py", line 108, in _version_missing
          raise LookupError(
      LookupError: setuptools-scm was unable to detect version for /mnt/c/Users/baghom/Desktop/discretize-main.

      Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.

      For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

What if I try developer mode installation?

$ pip install -e . --use-pep517
Obtaining file:///mnt/c/Users/baghom/Desktop/discretize-main
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Installing backend dependencies ... done
  Preparing editable metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing editable metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [47 lines of output]
      /tmp/pip-build-env-ku5la0_8/normal/lib/python3.10/site-packages/Cython/Compiler/Main.py:384: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /mnt/c/Users/baghom/Desktop/discretize-main/discretize/_extensions/interputils_cython.pxd
        tree = Parsing.p_module(s, pxd, full_module_name)
      Compiling discretize/_extensions/interputils_cython.pyx because it depends on /tmp/pip-build-env-ku5la0_8/normal/lib/python3.10/site-packages/Cython/Includes/cpython/object.pxd.
      Compiling discretize/_extensions/tree_ext.pyx because it depends on /tmp/pip-build-env-ku5la0_8/normal/lib/python3.10/site-packages/Cython/Includes/libcpp/vector.pxd.
      Compiling discretize/_extensions/simplex_helpers.pyx because it depends on /tmp/pip-build-env-ku5la0_8/normal/lib/python3.10/site-packages/Cython/Includes/libcpp/pair.pxd.
      [1/3] Cythonizing discretize/_extensions/simplex_helpers.pyx
      [2/3] Cythonizing discretize/_extensions/tree_ext.pyx
      [3/3] Cythonizing discretize/_extensions/interputils_cython.pyx
      Traceback (most recent call last):
        File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 181, in prepare_metadata_for_build_editable
          return hook(metadata_directory, config_settings)
        File "/tmp/pip-build-env-ku5la0_8/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 473, in prepare_metadata_for_build_editable
          return self.prepare_metadata_for_build_wheel(
        File "/tmp/pip-build-env-ku5la0_8/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 396, in prepare_metadata_for_build_wheel
          self.run_setup()
        File "/tmp/pip-build-env-ku5la0_8/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 507, in run_setup
          super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
        File "/tmp/pip-build-env-ku5la0_8/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in run_setup
          exec(code, locals())
        File "<string>", line 130, in <module>
        File "/tmp/pip-build-env-ku5la0_8/overlay/lib/python3.10/site-packages/setuptools/__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
        File "/tmp/pip-build-env-ku5la0_8/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 147, in setup
          _setup_distribution = dist = klass(attrs)
        File "/tmp/pip-build-env-ku5la0_8/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 302, in __init__
          _Distribution.__init__(
        File "/tmp/pip-build-env-ku5la0_8/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 283, in __init__
          self.finalize_options()
        File "/tmp/pip-build-env-ku5la0_8/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 692, in finalize_options
          ep(self)
        File "/tmp/pip-build-env-ku5la0_8/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 712, in _finalize_setup_keywords
          ep.load()(self, ep.name, value)
        File "/tmp/pip-build-env-ku5la0_8/normal/lib/python3.10/site-packages/setuptools_scm/integration.py", line 91, in version_keyword
          _assign_version(dist, config)
        File "/tmp/pip-build-env-ku5la0_8/normal/lib/python3.10/site-packages/setuptools_scm/integration.py", line 63, in _assign_version
          _version_missing(config)
        File "/tmp/pip-build-env-ku5la0_8/normal/lib/python3.10/site-packages/setuptools_scm/__init__.py", line 108, in _version_missing
          raise LookupError(
      LookupError: setuptools-scm was unable to detect version for /mnt/c/Users/baghom/Desktop/discretize-main.

      Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.

      For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

What if I first compile in-place ?

$ python setup.py build_ext --inplace
/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/__init__.py:84: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!

        ********************************************************************************
        Requirements should be satisfied by a PEP 517 installer.
        If you are using pip, you can try `pip install --use-pep517`.
        ********************************************************************************

!!
  dist.fetch_build_eggs(dist.setup_requires)
Traceback (most recent call last):
  File "/mnt/c/Users/baghom/Desktop/discretize-main/setup.py", line 130, in <module>
    setup(**metadata)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/__init__.py", line 107, in setup
    return distutils.core.setup(**attrs)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 147, in setup
    _setup_distribution = dist = klass(attrs)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/dist.py", line 486, in __init__
    _Distribution.__init__(
  File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 283, in __init__
    self.finalize_options()
  File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/dist.py", line 925, in finalize_options
    ep(self)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/dist.py", line 945, in _finalize_setup_keywords
    ep.load()(self, ep.name, value)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/.eggs/setuptools_scm-7.1.0-py3.10.egg/setuptools_scm/integration.py", line 91, in version_keyword
    _assign_version(dist, config)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/.eggs/setuptools_scm-7.1.0-py3.10.egg/setuptools_scm/integration.py", line 63, in _assign_version
    _version_missing(config)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/.eggs/setuptools_scm-7.1.0-py3.10.egg/setuptools_scm/__init__.py", line 108, in _version_missing
    raise LookupError(
LookupError: setuptools-scm was unable to detect version for /mnt/c/Users/baghom/Desktop/discretize-main.

Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.

For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj

Could it be due to setuptools_scm cannot figure out the program version? I modify the code to a manual version 0.0.0 to see if that helps!

$ python setup.py build_ext --inplace
/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/__init__.py:84: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!

        ********************************************************************************
        Requirements should be satisfied by a PEP 517 installer.
        If you are using pip, you can try `pip install --use-pep517`.
        ********************************************************************************

!!
  dist.fetch_build_eggs(dist.setup_requires)
Traceback (most recent call last):
  File "/mnt/c/Users/baghom/Desktop/discretize-main/setup.py", line 130, in <module>
    setup(**metadata)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/__init__.py", line 107, in setup
    return distutils.core.setup(**attrs)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 147, in setup
    _setup_distribution = dist = klass(attrs)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/dist.py", line 486, in __init__
    _Distribution.__init__(
  File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 283, in __init__
    self.finalize_options()
  File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/dist.py", line 925, in finalize_options
    ep(self)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/dist.py", line 945, in _finalize_setup_keywords
    ep.load()(self, ep.name, value)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/.eggs/setuptools_scm-7.1.0-py3.10.egg/setuptools_scm/integration.py", line 91, in version_keyword
    _assign_version(dist, config)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/.eggs/setuptools_scm-7.1.0-py3.10.egg/setuptools_scm/integration.py", line 63, in _assign_version
    _version_missing(config)
  File "/mnt/c/Users/baghom/Desktop/discretize-main/.eggs/setuptools_scm-7.1.0-py3.10.egg/setuptools_scm/__init__.py", line 108, in _version_missing
    raise LookupError(
LookupError: setuptools-scm was unable to detect version for /mnt/c/Users/baghom/Desktop/discretize-main.

Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.

For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj
(/mnt/c/Users/baghom/Desktop/discretize-main/env) Ubuntu [12:39:02] /mnt/c/Users/baghom/Desktop/discretize-main:
$ python setup.py build_ext --inplace
/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/setuptools/__init__.py:84: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!

        ********************************************************************************
        Requirements should be satisfied by a PEP 517 installer.
        If you are using pip, you can try `pip install --use-pep517`.
        ********************************************************************************

!!
  dist.fetch_build_eggs(dist.setup_requires)
running build_ext
building 'discretize._extensions.interputils_cython' extension
creating build
creating build/temp.linux-x86_64-cpython-310
creating build/temp.linux-x86_64-cpython-310/discretize
creating build/temp.linux-x86_64-cpython-310/discretize/_extensions
gcc -pthread -B /mnt/c/Users/baghom/Desktop/discretize-main/env/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /mnt/c/Users/baghom/Desktop/discretize-main/env/include -fPIC -O2 -isystem /mnt/c/Users/baghom/Desktop/discretize-main/env/include -fPIC -I/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/numpy/core/include -I/mnt/c/Users/baghom/Desktop/discretize-main/env/include/python3.10 -c discretize/_extensions/interputils_cython.c -o build/temp.linux-x86_64-cpython-310/discretize/_extensions/interputils_cython.o
In file included from /mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/numpy/core/include/numpy/ndarraytypes.h:1929,
                 from /mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                 from /mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/numpy/core/include/numpy/arrayobject.h:5,
                 from discretize/_extensions/interputils_cython.c:1176:
/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
   17 | #warning "Using deprecated NumPy API, disable it with " \
      |  ^~~~~~~
creating build/lib.linux-x86_64-cpython-310
creating build/lib.linux-x86_64-cpython-310/discretize
creating build/lib.linux-x86_64-cpython-310/discretize/_extensions
gcc -pthread -B /mnt/c/Users/baghom/Desktop/discretize-main/env/compiler_compat -shared -Wl,-rpath,/mnt/c/Users/baghom/Desktop/discretize-main/env/lib -Wl,-rpath-link,/mnt/c/Users/baghom/Desktop/discretize-main/env/lib -L/mnt/c/Users/baghom/Desktop/discretize-main/env/lib -Wl,-rpath,/mnt/c/Users/baghom/Desktop/discretize-main/env/lib -Wl,-rpath-link,/mnt/c/Users/baghom/Desktop/discretize-main/env/lib -L/mnt/c/Users/baghom/Desktop/discretize-main/env/lib build/temp.linux-x86_64-cpython-310/discretize/_extensions/interputils_cython.o -o build/lib.linux-x86_64-cpython-310/discretize/_extensions/interputils_cython.cpython-310-x86_64-linux-gnu.so
building 'discretize._extensions.tree_ext' extension
gcc -pthread -B /mnt/c/Users/baghom/Desktop/discretize-main/env/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /mnt/c/Users/baghom/Desktop/discretize-main/env/include -fPIC -O2 -isystem /mnt/c/Users/baghom/Desktop/discretize-main/env/include -fPIC -Idiscretize/_extensions -I/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/numpy/core/include -I/mnt/c/Users/baghom/Desktop/discretize-main/env/include/python3.10 -c discretize/_extensions/tree.cpp -o build/temp.linux-x86_64-cpython-310/discretize/_extensions/tree.o -std=c++17
discretize/_extensions/tree.cpp: In member function ‘void Cell::shift_centers(double*)’:
discretize/_extensions/tree.cpp:362:28: warning: comparison of integer expressions of different signedness: ‘int_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
  362 |         for(int_t i = 0; i < (1<<n_dim); ++i){
      |                          ~~^~~~~~~~~~~~
discretize/_extensions/tree.cpp: In member function ‘void Cell::refine_line(node_map_t&, double*, double*, double*, int_t, double*, double*, double*, bool)’:
discretize/_extensions/tree.cpp:519:28: warning: comparison of integer expressions of different signedness: ‘int_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
  519 |         for(int_t i = 0; i < (1<<n_dim); ++i){
      |                          ~~^~~~~~~~~~~~
discretize/_extensions/tree.cpp: In member function ‘void Cell::refine_triangle(node_map_t&, double*, double*, double*, double*, double*, double*, double*, int_t, double*, double*, double*, bool)’:
discretize/_extensions/tree.cpp:672:24: warning: comparison of integer expressions of different signedness: ‘int_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
  672 |     for(int_t i = 0; i < (1<<n_dim); ++i){
      |                      ~~^~~~~~~~~~~~
discretize/_extensions/tree.cpp: In member function ‘void Cell::refine_vert_triang_prism(node_map_t&, double*, double*, double*, double, double*, double*, double*, double*, int_t, double*, double*, double*, bool)’:
discretize/_extensions/tree.cpp:829:24: warning: comparison of integer expressions of different signedness: ‘int_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
  829 |     for(int_t i = 0; i < (1<<n_dim); ++i){
      |                      ~~^~~~~~~~~~~~
discretize/_extensions/tree.cpp: In member function ‘void Cell::refine_tetra(node_map_t&, double*, double*, double*, double*, double (*)[3], double (*)[3], int_t, double*, double*, double*, bool)’:
discretize/_extensions/tree.cpp:921:24: warning: comparison of integer expressions of different signedness: ‘int_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
  921 |     for(int_t i = 0; i < (1<<n_dim); ++i){
      |                      ~~^~~~~~~~~~~~
discretize/_extensions/tree.cpp: In member function ‘void Cell::refine_func(node_map_t&, function, double*, double*, double*, bool)’:
discretize/_extensions/tree.cpp:939:24: warning: comparison of integer expressions of different signedness: ‘int’ and ‘int_t’ {aka ‘long unsigned int’} [-Wsign-compare]
  939 |         if (test_level <= level){
      |             ~~~~~~~~~~~^~~~~~~~
discretize/_extensions/tree.cpp:946:24: warning: comparison of integer expressions of different signedness: ‘int_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
  946 |     for(int_t i = 0; i < (1<<n_dim); ++i){
      |                      ~~^~~~~~~~~~~~
discretize/_extensions/tree.cpp: In member function ‘void Cell::build_cell_vector(cell_vec_t&)’:
discretize/_extensions/tree.cpp:1245:24: warning: comparison of integer expressions of different signedness: ‘int_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
 1245 |     for(int_t i = 0; i < (1<<n_dim); ++i){
      |                      ~~^~~~~~~~~~~~
discretize/_extensions/tree.cpp: In member function ‘void Cell::find_overlapping_cells(int_vec_t&, double, double, double, double, double, double)’:
discretize/_extensions/tree.cpp:1278:24: warning: comparison of integer expressions of different signedness: ‘int_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
 1278 |     for(int_t i = 0; i < (1<<n_dim); ++i){
      |                      ~~^~~~~~~~~~~~
discretize/_extensions/tree.cpp: In destructor ‘Cell::~Cell()’:
discretize/_extensions/tree.cpp:1287:27: warning: comparison of integer expressions of different signedness: ‘int_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
 1287 |         for(int_t i = 0; i< (1<<n_dim); ++i){
      |                          ~^~~~~~~~~~~~
discretize/_extensions/tree.cpp: In member function ‘void Tree::initialize_roots()’:
discretize/_extensions/tree.cpp:1400:40: warning: comparison of integer expressions of different signedness: ‘int_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
 1400 |                     for(int_t i = 0; i < (1<<n_dim); ++i){
      |                                      ~~^~~~~~~~~~~~
gcc -pthread -B /mnt/c/Users/baghom/Desktop/discretize-main/env/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /mnt/c/Users/baghom/Desktop/discretize-main/env/include -fPIC -O2 -isystem /mnt/c/Users/baghom/Desktop/discretize-main/env/include -fPIC -Idiscretize/_extensions -I/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/numpy/core/include -I/mnt/c/Users/baghom/Desktop/discretize-main/env/include/python3.10 -c discretize/_extensions/tree_ext.cpp -o build/temp.linux-x86_64-cpython-310/discretize/_extensions/tree_ext.o -std=c++17
In file included from /mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/numpy/core/include/numpy/ndarraytypes.h:1929,
                 from /mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                 from /mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/numpy/core/include/numpy/arrayobject.h:5,
                 from discretize/_extensions/tree_ext.cpp:1193:
/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
   17 | #warning "Using deprecated NumPy API, disable it with " \
      |  ^~~~~~~
discretize/_extensions/tree_ext.cpp: In function ‘PyObject* __pyx_pf_10discretize_11_extensions_8tree_ext_8TreeCell_9neighbors___get__(__pyx_obj_10discretize_11_extensions_8tree_ext_TreeCell*)’:
discretize/_extensions/tree_ext.cpp:25707:35: warning: comparison of integer expressions of different signedness: ‘Py_ssize_t’ {aka ‘long int’} and ‘int_t’ {aka ‘long unsigned int’} [-Wsign-compare]
25707 |     for (__pyx_temp=0; __pyx_temp < __pyx_v_self->_dim; __pyx_temp++) {
      |                        ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
discretize/_extensions/tree_ext.cpp: In function ‘PyObject* __pyx_pf_10discretize_11_extensions_8tree_ext_9_TreeMesh_8refine_ball(__pyx_obj_10discretize_11_extensions_8tree_ext__TreeMesh*, PyObject*, PyObject*, PyObject*, PyObject*, PyObject*)’:
discretize/_extensions/tree_ext.cpp:30707:35: warning: comparison of integer expressions of different signedness: ‘int_
’ {aka ‘long unsigned int’} and ‘Py_ssize_t’ {aka ‘long int’} [-Wsign-compare]
30707 |   for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
      |                        ~~~~~~~~~~~^~~~~~~~~~~~
discretize/_extensions/tree_ext.cpp: In function ‘PyObject* __pyx_pf_10discretize_11_extensions_8tree_ext_9_TreeMesh_26_set_origin(__pyx_obj_10discretize_11_extensions_8tree_ext__TreeMesh*, PyObject*)’:
discretize/_extensions/tree_ext.cpp:37638:39: warning: comparison of integer expressions of different signedness: ‘Py_ssize_t’ {aka ‘long int’} and ‘int_t’ {aka ‘long unsigned int’} [-Wsign-compare]
37638 |       for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_20; __pyx_t_13+=1) {
      |                            ~~~~~~~~~~~^~~~~~~~~~~~
discretize/_extensions/tree_ext.cpp:37709:39: warning: comparison of integer expressions of different signedness: ‘Py_ssize_t’ {aka ‘long int’} and ‘int_t’ {aka ‘long unsigned int’} [-Wsign-compare]
37709 |       for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_20; __pyx_t_13+=1) {
      |                            ~~~~~~~~~~~^~~~~~~~~~~~
discretize/_extensions/tree_ext.cpp:37780:39: warning: comparison of integer expressions of different signedness: ‘Py_ssize_t’ {aka ‘long int’} and ‘int_t’ {aka ‘long unsigned int’} [-Wsign-compare]
37780 |       for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_20; __pyx_t_13+=1) {
      |                            ~~~~~~~~~~~^~~~~~~~~~~~
discretize/_extensions/tree_ext.cpp:37862:41: warning: comparison of integer expressions of different signedness: ‘Py_ssize_t’ {aka ‘long int’} and ‘int_t’ {aka ‘long unsigned int’} [-Wsign-compare]
37862 |         for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_20; __pyx_t_13+=1) {
      |                              ~~~~~~~~~~~^~~~~~~~~~~~
discretize/_extensions/tree_ext.cpp:37933:41: warning: comparison of integer expressions of different signedness: ‘Py_ssize_t’ {aka ‘long int’} and ‘int_t’ {aka ‘long unsigned int’} [-Wsign-compare]
37933 |         for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_20; __pyx_t_13+=1) {
      |                              ~~~~~~~~~~~^~~~~~~~~~~~
discretize/_extensions/tree_ext.cpp:38004:41: warning: comparison of integer expressions of different signedness: ‘Py_ssize_t’ {aka ‘long int’} and ‘int_t’ {aka ‘long unsigned int’} [-Wsign-compare]
38004 |         for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_20; __pyx_t_13+=1) {
      |                              ~~~~~~~~~~~^~~~~~~~~~~~
discretize/_extensions/tree_ext.cpp:38075:41: warning: comparison of integer expressions of different signedness: ‘Py_ssize_t’ {aka ‘long int’} and ‘int_t’ {aka ‘long unsigned int’} [-Wsign-compare]
38075 |         for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_20; __pyx_t_13+=1) {
      |                              ~~~~~~~~~~~^~~~~~~~~~~~
discretize/_extensions/tree_ext.cpp: In function ‘PyObject* __pyx_pf_10discretize_11_extensions_8tree_ext_9_TreeMesh_14max_used_level___get__(__pyx_obj_10discretize_11_extensions_8tree_ext__TreeMesh*)’:
discretize/_extensions/tree_ext.cpp:38567:28: warning: comparison of integer expressions of different signedness: ‘int_
’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
38567 |     __pyx_t_6 = (__pyx_t_3 > __pyx_t_4);
      |                  ~~~~~~~~~~^~~~~~~~~~~
discretize/_extensions/tree_ext.cpp: In function ‘PyObject* __pyx_pf_10discretize_11_extensions_8tree_ext_9_TreeMesh_100_vol_avg_from_tens(__pyx_obj_10discretize_11_extensions_8tree_ext__TreeMesh*, PyObject*, PyObject*, PyObject*)’:
discretize/_extensions/tree_ext.cpp:107592:29: warning: comparison of integer expressions of different signedness: ‘int_t’ {aka ‘long unsigned int’} and ‘__pyx_t_5numpy_int64_t’ {aka ‘long int’} [-Wsign-compare]
107592 |     __pyx_t_12 = (__pyx_t_6 < __pyx_t_26);
       |                   ~~~~~~~~~~^~~~~~~~~~~~
discretize/_extensions/tree_ext.cpp:107629:29: warning: comparison of integer expressions of different signedness: ‘int_t’ {aka ‘long unsigned int’} and ‘__pyx_t_5numpy_int64_t’ {aka ‘long int’} [-Wsign-compare]
107629 |     __pyx_t_12 = (__pyx_t_6 < __pyx_t_27);
       |                   ~~~~~~~~~~^~~~~~~~~~~~
discretize/_extensions/tree_ext.cpp:107677:31: warning: comparison of integer expressions of different signedness: ‘int_t’ {aka ‘long unsigned int’} and ‘__pyx_t_5numpy_int64_t’ {aka ‘long int’} [-Wsign-compare]
107677 |       __pyx_t_12 = (__pyx_t_6 < __pyx_t_26);
       |                     ~~~~~~~~~~^~~~~~~~~~~~
discretize/_extensions/tree_ext.cpp: In function ‘PyObject* __pyx_pf_10discretize_11_extensions_8tree_ext_9_TreeMesh_74_getEdgeP(__pyx_obj_10discretize_11_extensions_8tree_ext__TreeMesh*, PyObject*, PyObject*, PyObject*)’:
discretize/_extensions/tree_ext.cpp:86878:151: warning: ‘__pyx_v_edges[2]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
86878 | __pyx_v_J3.data + __pyx_t_18 * __pyx_v_J3.strides[0]) )) = ((__pyx_v_cell->edges[((2 * __pyx_v_epc) + (__pyx_v_edges[2]))])->index + (*((__pyx_t_5numpy_int64_t *) ( /* dim=0 */ (__pyx_v_offsets.data + __pyx_t_13 * __pyx_v_offsets.strides[0]) ))));
      |                                                                                  ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

discretize/_extensions/tree_ext.cpp: In function ‘PyObject* __pyx_pf_10discretize_11_extensions_8tree_ext_9_TreeMesh_80_getEdgeIntMat(__pyx_obj_10discretize_11_extensions_8tree_ext__TreeMesh*, PyObject*, PyObject*, PyObject*)’:
discretize/_extensions/tree_ext.cpp:90113:139: warning: ‘__pyx_v_i111’ may be used uninitialized in this function [-Wmaybe-uninitialized]
90113 |  /* dim=0 */ (__pyx_v_row_inds.data + __pyx_t_16 * __pyx_v_row_inds.strides[0]) )) = (__pyx_v_i111->index + __pyx_v_offset);
      |                                                                                       ~~~~~~~~~~~~~~^~~~~

discretize/_extensions/tree_ext.cpp:90053:139: warning: ‘__pyx_v_i100’ may be used uninitialized in this function [-Wmaybe-uninitialized]
90053 |  /* dim=0 */ (__pyx_v_row_inds.data + __pyx_t_16 * __pyx_v_row_inds.strides[0]) )) = (__pyx_v_i100->index + __pyx_v_offset);
      |                                                                                       ~~~~~~~~~~~~~~^~~~~

discretize/_extensions/tree_ext.cpp:90073:139: warning: ‘__pyx_v_i101’ may be used uninitialized in this function [-Wmaybe-uninitialized]
90073 |  /* dim=0 */ (__pyx_v_row_inds.data + __pyx_t_16 * __pyx_v_row_inds.strides[0]) )) = (__pyx_v_i101->index + __pyx_v_offset);
      |                                                                                       ~~~~~~~~~~~~~~^~~~~

discretize/_extensions/tree_ext.cpp:90093:139: warning: ‘__pyx_v_i110’ may be used uninitialized in this function [-Wmaybe-uninitialized]
90093 |  /* dim=0 */ (__pyx_v_row_inds.data + __pyx_t_16 * __pyx_v_row_inds.strides[0]) )) = (__pyx_v_i110->index + __pyx_v_offset);
      |                                                                                       ~~~~~~~~~~~~~~^~~~~

discretize/_extensions/tree_ext.cpp: In function ‘PyObject* __pyx_pf_10discretize_11_extensions_8tree_ext_9_TreeMesh_68_getFaceP(__pyx_obj_10discretize_11_extensions_8tree_ext__TreeMesh*, PyObject*, PyObject*, PyObject*)’:
discretize/_extensions/tree_ext.cpp:85065:135: warning: ‘__pyx_v_faces[2]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
85065 |  ( /* dim=0 */ (__pyx_v_J3.data + __pyx_t_15 * __pyx_v_J3.strides[0]) )) = ((__pyx_v_cell->faces[(4 + (__pyx_v_faces[2]))])->index + (*((__pyx_t_5numpy_int64_t *) ( /* dim=0 */ (__pyx_v_offsets.data + __pyx_t_10 * __pyx_v_offsets.strides[0]) ))));
      |                                                                                                  ~~~^~~~~~~~~~~~~~~~~~~~~

discretize/_extensions/tree_ext.cpp: In function ‘PyObject* __pyx_pf_10discretize_11_extensions_8tree_ext_9_TreeMesh_100_vol_avg_from_tens(__pyx_obj_10discretize_11_extensions_8tree_ext__TreeMesh*, PyObject*, PyObject*, PyObject*)’:
discretize/_extensions/tree_ext.cpp:107657:88: warning: ‘__pyx_v_z1m’ may be used uninitialized in this function [-Wmaybe-uninitialize
]
107657 |       __pyx_t_26 = __pyx_f_10discretize_11_extensions_18interputils_cython__bisect_left(__pyx_v_nodes_z, __pyx_v_z1m); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6563, __pyx_L1_error)
       |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
discretize/_extensions/tree_ext.cpp:108087:9: warning: ‘__pyx_v_z1p’ may be used uninitialized in this function [-Wmaybe-uninitialized]
108087 |         if (__pyx_t_12) {
       |         ^~
discretize/_extensions/tree_ext.cpp: In function ‘PyObject* __pyx_pf_10discretize_11_extensions_8tree_ext_9_TreeMesh_96_vol_avg_from_tree(__pyx_obj_10discretize_11_extensions_8tree_ext__TreeMesh*, __pyx_obj_10discretize_11_extensions_8tree_ext__TreeMesh*, PyObject*, PyObject*)’:
discretize/_extensions/tree_ext.cpp:102653:81: warning: ‘__pyx_v_z1m’ may be used uninitialized in this function [-Wmaybe-uninitialize
]
102653 |     __pyx_v_overlapping_cell_inds = __pyx_v_meshin->tree->find_overlapping_cells(__pyx_v_x1m, __pyx_v_x1p, __pyx_v_y1m, __pyx_v_y1p, __pyx_v_z1m, __pyx_v_z1p);
       |                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
discretize/_extensions/tree_ext.cpp:102972:9: warning: ‘__pyx_v_z1p’ may be used uninitialized in this function [-Wmaybe-uninitialized]
102972 |         if (__pyx_t_11) {
       |         ^~
discretize/_extensions/tree_ext.cpp:102291:5: warning: ‘__pyx_v_n_unvisited’ may be used uninitialized in this function [-Wmaybe-uninitialized]
102291 |     if (__pyx_t_11) {
       |     ^~
g++ -pthread -B /mnt/c/Users/baghom/Desktop/discretize-main/env/compiler_compat -shared -Wl,-rpath,/mnt/c/Users/baghom/Desktop/discretize-main/env/lib -Wl,-rpath-link,/mnt/c/Users/baghom/Desktop/discretize-main/env/lib -L/mnt/c/Users/baghom/Desktop/discretize-main/env/lib -Wl,-rpath,/mnt/c/Users/baghom/Desktop/discretize-main/env/lib -Wl,-rpath-link,/mnt/c/Users/baghom/Desktop/discretize-main/env/lib -L/mnt/c/Users/baghom/Desktop/discretize-main/env/lib build/temp.linux-x86_64-cpython-310/discretize/_extensions/tree.o build/temp.linux-x86_64-cpython-310/discretize/_extensions/tree_ext.o -o build/lib.linux-x86_64-cpython-310/discretize/_extensions/tree_ext.cpython-310-x86_64-linux-gnu.so
building 'discretize._extensions.simplex_helpers' extension
gcc -pthread -B /mnt/c/Users/baghom/Desktop/discretize-main/env/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /mnt/c/Users/baghom/Desktop/discretize-main/env/include -fPIC -O2 -isystem /mnt/c/Users/baghom/Desktop/discretize-main/env/include -fPIC -Idiscretize/_extensions -I/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/numpy/core/include -I/mnt/c/Users/baghom/Desktop/discretize-main/env/include/python3.10 -c discretize/_extensions/simplex_helpers.cpp -o build/temp.linux-x86_64-cpython-310/discretize/_extensions/simplex_helpers.o
In file included from /mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/numpy/core/include/numpy/ndarraytypes.h:1929,
                 from /mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                 from /mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/numpy/core/include/numpy/arrayobject.h:5,
                 from discretize/_extensions/simplex_helpers.cpp:1209:
/mnt/c/Users/baghom/Desktop/discretize-main/env/lib/python3.10/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
   17 | #warning "Using deprecated NumPy API, disable it with " \
      |  ^~~~~~~
discretize/_extensions/simplex_helpers.cpp: In function ‘PyObject* __pyx_pf_10discretize_11_extensions_15simplex_helpers_16_build_adjacency(PyObject*, __Pyx_memviewslice, PyObject*)’:
discretize/_extensions/simplex_helpers.cpp:27609:37: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘long int’ [-Wsign-compare]
27609 |     for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
      |                          ~~~~~~~~~~~^~~~~~~~~~~~
discretize/_extensions/simplex_helpers.cpp:27642:37: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘long int’ [-Wsign-compare]
27642 |       __pyx_t_16 = (__pyx_v_i_other == -1L);
      |                     ~~~~~~~~~~~~~~~~^~~~~~
discretize/_extensions/simplex_helpers.cpp:27698:35: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
27698 |           __pyx_t_18 = (__pyx_v_k < (__pyx_v_dim + 1));
      |                         ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
discretize/_extensions/simplex_helpers.cpp: In function ‘PyObject* __pyx_pf_10discretize_11_extensions_15simplex_helpers_18_build_adjacency(PyObject*, __Pyx_memviewslice, PyObject*)’:
discretize/_extensions/simplex_helpers.cpp:28060:35: warning: comparison of integer expressions of different signedness: ‘__pyx_t_5numpy_int32_t’ {aka ‘int’} and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
28060 |   for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      |                        ~~~~~~~~~~~^~~~~~~~~~~
discretize/_extensions/simplex_helpers.cpp: In function ‘PyObject* __pyx_pf_10discretize_11_extensions_15simplex_helpers_20_build_adjacency(PyObject*, __Pyx_memviewslice, PyObject*)’:
discretize/_extensions/simplex_helpers.cpp:28561:35: warning: comparison of integer expressions of different signedness: ‘__pyx_t_5numpy_int64_t’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
28561 |   for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      |                        ~~~~~~~~~~~^~~~~~~~~~~
discretize/_extensions/simplex_helpers.cpp: In function ‘PyObject* __pyx_pf_10discretize_11_extensions_15simplex_helpers_50_interp_cc(PyObject*, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice)’:
discretize/_extensions/simplex_helpers.cpp:44857:33: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘Py_ssize_t’ {aka ‘long int’} [-Wsign-compare]
44857 |   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
      |                       ~~~~~~~~~~^~~~~~~~~~~
discretize/_extensions/simplex_helpers.cpp:45098:33: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘Py_ssize_t’ {aka ‘long int’} [-Wsign-compare]
45098 |   for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
      |                       ~~~~~~~~~~^~~~~~~~~~~
discretize/_extensions/simplex_helpers.cpp:45260:39: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
45260 |       for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_18; __pyx_t_17+=1) {
      |                            ~~~~~~~~~~~^~~~~~~~~~~~
discretize/_extensions/simplex_helpers.cpp:45493:41: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
45493 |         for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_18; __pyx_t_17+=1) {
      |                              ~~~~~~~~~~~^~~~~~~~~~~~
discretize/_extensions/simplex_helpers.cpp:46076:41: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
46076 |         for (__pyx_t_21 = 0; __pyx_t_21 < __pyx_t_18; __pyx_t_21+=1) {
      |                              ~~~~~~~~~~~^~~~~~~~~~~~
In file included from discretize/_extensions/simplex_helpers.cpp:1215:
discretize/_extensions/triplet.h: In instantiation of ‘triplet<T, U, V>::triplet() [with T = long unsigned int; U = long unsigned int; V = long unsigned int]’:
discretize/_extensions/simplex_helpers.cpp:21538:34:   required from here
discretize/_extensions/triplet.h:15:12: warning: converting to non-pointer type ‘long unsigned int’ from NULL [-Wconversion-null]
   15 |         v1 = NULL;
      |            ^
discretize/_extensions/triplet.h:16:12: warning: converting to non-pointer type ‘long unsigned int’ from NULL [-Wconversion-null]
   16 |         v2 = NULL;
      |            ^
discretize/_extensions/triplet.h:17:12: warning: converting to non-pointer type ‘long unsigned int’ from NULL [-Wconversion-null]
   17 |         v3 = NULL;
      |            ^
discretize/_extensions/triplet.h: In instantiation of ‘triplet<T, U, V>::triplet() [with T = int; U = int; V = int]’:
discretize/_extensions/simplex_helpers.cpp:23146:82:   required from here
discretize/_extensions/triplet.h:15:12: warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
   15 |         v1 = NULL;
      |            ^
discretize/_extensions/triplet.h:16:12: warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
   16 |         v2 = NULL;
      |            ^
discretize/_extensions/triplet.h:17:12: warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
   17 |         v3 = NULL;
      |            ^
discretize/_extensions/triplet.h: In instantiation of ‘triplet<T, U, V>::triplet() [with T = long int; U = long int; V = long int]’:
discretize/_extensions/simplex_helpers.cpp:24771:82:   required from here
discretize/_extensions/triplet.h:15:12: warning: converting to non-pointer type ‘long int’ from NULL [-Wconversion-null]
   15 |         v1 = NULL;
      |            ^
discretize/_extensions/triplet.h:16:12: warning: converting to non-pointer type ‘long int’ from NULL [-Wconversion-null]
   16 |         v2 = NULL;
      |            ^
discretize/_extensions/triplet.h:17:12: warning: converting to non-pointer type ‘long int’ from NULL [-Wconversion-null]
   17 |         v3 = NULL;
      |            ^
g++ -pthread -B /mnt/c/Users/baghom/Desktop/discretize-main/env/compiler_compat -shared -Wl,-rpath,/mnt/c/Users/baghom/Desktop/discretize-main/env/lib -Wl,-rpath-link,/mnt/c/Users/baghom/Desktop/discretize-main/env/lib -L/mnt/c/Users/baghom/Desktop/discretize-main/env/lib -Wl,-rpath,/mnt/c/Users/baghom/Desktop/discretize-main/env/lib -Wl,-rpath-link,/mnt/c/Users/baghom/Desktop/discretize-main/env/lib -L/mnt/c/Users/baghom/Desktop/discretize-main/env/lib build/temp.linux-x86_64-cpython-310/discretize/_extensions/simplex_helpers.o -o build/lib.linux-x86_64-cpython-310/discretize/_extensions/simplex_helpers.cpython-310-x86_64-linux-gnu.so
copying build/lib.linux-x86_64-cpython-310/discretize/_extensions/interputils_cython.cpython-310-x86_64-linux-gnu.so -> discretize/_extensions
copying build/lib.linux-x86_64-cpython-310/discretize/_extensions/tree_ext.cpython-310-x86_64-linux-gnu.so -> discretize/_extensions
copying build/lib.linux-x86_64-cpython-310/discretize/_extensions/simplex_helpers.cpython-310-x86_64-linux-gnu.so -> discretize/_extensions

YES Finally! Now, let's attempt to install the package!

$ pip install .
Processing /mnt/c/Users/baghom/Desktop/discretize-main
  Preparing metadata (setup.py) ... done
Requirement already satisfied: numpy>=1.20 in ./env/lib/python3.10/site-packages (from discretize==0.0.0) (1.25.2)
Requirement already satisfied: cython>=0.29.31 in ./env/lib/python3.10/site-packages (from discretize==0.0.0) (3.0.2)
Collecting setuptools_scm (from discretize==0.0.0)
  Using cached setuptools_scm-7.1.0-py3-none-any.whl (43 kB)
Collecting scipy>=1.8 (from discretize==0.0.0)
  Obtaining dependency information for scipy>=1.8 from https://files.pythonhosted.org/packages/a8/cc/c36f3439f5d47c3b13833ce6687b43a040cc7638c502ac46b41e2d4f3d6f/scipy-1.11.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
  Using cached scipy-1.11.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (59 kB)
Collecting packaging>=20.0 (from setuptools_scm->discretize==0.0.0)
  Using cached packaging-23.1-py3-none-any.whl (48 kB)
Requirement already satisfied: setuptools in ./env/lib/python3.10/site-packages (from setuptools_scm->discretize==0.0.0) (68.0.0)
Collecting typing-extensions (from setuptools_scm->discretize==0.0.0)
  Obtaining dependency information for typing-extensions from https://files.pythonhosted.org/packages/ec/6b/63cc3df74987c36fe26157ee12e09e8f9db4de771e0f3404263117e75b95/typing_extensions-4.7.1-py3-none-any.whl.metadata
  Using cached typing_extensions-4.7.1-py3-none-any.whl.metadata (3.1 kB)
Collecting tomli>=1.0.0 (from setuptools_scm->discretize==0.0.0)
  Using cached tomli-2.0.1-py3-none-any.whl (12 kB)
Using cached scipy-1.11.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (36.3 MB)
Using cached typing_extensions-4.7.1-py3-none-any.whl (33 kB)
Building wheels for collected packages: discretize
  Building wheel for discretize (setup.py) ... done
  Created wheel for discretize: filename=discretize-0.0.0-cp310-cp310-linux_x86_64.whl size=1211983 sha256=1ca341561ca21158a85d2ad72fde3b6048961506e10b0f57c272b086651a67c2
  Stored in directory: /home/omid-b/.cache/pip/wheels/77/e8/70/7591fec00a719e13e9bad116de1e4b83ebb8edd4510d4fe727
Successfully built discretize
Installing collected packages: typing-extensions, tomli, scipy, packaging, setuptools_scm, discretize
Successfully installed discretize-0.0.0 packaging-23.1 scipy-1.11.2 setuptools_scm-7.1.0 tomli-2.0.1 typing-extensions-4.7.1

A simple test to see if discretize is importable from root directory:

$ cd /
$ python -c "import discretize"
$ python -c "import discretize._extensions"
$ python -c "import discretize.tests"

Terrific! No errors!

Recommendation

I recommend switching discretize over to pyproject.toml and src-layout configuration. In my experience, the current package layout and configuration is very limiting and definitely not future-proof....

Following my discussion with @jcapriot on Slack, I will make 2 PRs that if merged, will make installation of discretize hassle-free even on a fresh python environment.

@jcapriot
Copy link
Member

jcapriot commented Sep 8, 2023

Thanks for the detailed information here! I see two problems here, the first will be reliable fixed by moving to a pyproject.toml file.

  1. cython, numpy, and setuptools_scm are all required for building discretize from source and is not installed in a fresh environment by using python setup.py install. (But they should be when doing pip install . in a fresh environment, which doesn’t appear to be something that was listed here). We should be more clear that using python setup.py is not a recommended path to installation, and pip install would be better.

  2. as you hinted setuptools_scm is unable to determine the package version. It uses info from got tags to determine the version automatically instead of it being hardcoded in. It has a hint suggestion in its error report about what is possibly causing this issue:

LookupError: setuptools-scm was unable to detect version for /mnt/c/Users/baghom/Desktop/discretize-main.

Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.

what method did you use to obtain the source for your installation?

@omid-b
Copy link
Author

omid-b commented Sep 8, 2023

Thank you very much for your speedy reply!

For the example above, I downloaded the package from main repository by clicking on CODE -> Download Zip , as this is the method most people would go for...

Since I have already forked discretize, I'm gonna try a similar demonstration using the cloning method below:

$ git clone git@github.com:omid-b/discretize
Cloning into 'discretize'...
remote: Enumerating objects: 34285, done.
remote: Counting objects: 100% (3976/3976), done.
remote: Compressing objects: 100% (1077/1077), done.
remote: Total 34285 (delta 2964), reused 3835 (delta 2879), pack-reused 30309
Receiving objects: 100% (34285/34285), 54.92 MiB | 514.00 KiB/s, done.
Resolving deltas: 100% (24698/24698), done.

$ cd discretize/

Create a fresh env ...

$ virtualenv env --python=3.10 && source env/bin/activate
created virtual environment CPython3.10.12.final.0-64 in 3058ms
  creator CPython3Posix(dest=/mnt/c/Users/baghom/Desktop/Tests/env, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/omid-b/.local/share/virtualenv)
    added seed packages: pip==22.0.2, setuptools==59.6.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

Now install ...

$ pip install .
Processing /mnt/c/Users/baghom/Desktop/Tests/discretize
  Preparing metadata (setup.py) ... done
Collecting cython>=0.29.31
  Using cached Cython-3.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB)
Collecting numpy>=1.20
  Using cached numpy-1.25.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.2 MB)
Collecting scipy>=1.8
  Using cached scipy-1.11.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (36.3 MB)
Collecting setuptools_scm
  Using cached setuptools_scm-7.1.0-py3-none-any.whl (43 kB)
Collecting tomli>=1.0.0
  Using cached tomli-2.0.1-py3-none-any.whl (12 kB)
Collecting packaging>=20.0
  Using cached packaging-23.1-py3-none-any.whl (48 kB)
Collecting typing-extensions
  Using cached typing_extensions-4.7.1-py3-none-any.whl (33 kB)
Requirement already satisfied: setuptools in /mnt/c/Users/baghom/Desktop/Tests/env/lib/python3.10/site-packages (from setuptools_scm->discretize==0.1.dev5527+g58043b9) (59.6.0)
Building wheels for collected packages: discretize
  Building wheel for discretize (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/mnt/c/Users/baghom/Desktop/Tests/discretize/setup.py", line 80, in <module>
          from Cython.Build import cythonize
      ModuleNotFoundError: No module named 'Cython'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for discretize
  Running setup.py clean for discretize
Failed to build discretize
Installing collected packages: typing-extensions, tomli, packaging, numpy, cython, setuptools_scm, scipy, discretize

@omid-b
Copy link
Author

omid-b commented Sep 8, 2023

$ pip install cython
Requirement already satisfied: cython in /mnt/c/Users/baghom/Desktop/Tests/env/lib/python3.10/site-packages (3.0.2)

This is weird!

@omid-b
Copy link
Author

omid-b commented Sep 8, 2023

Following #332 , I downgraded my cython

$ pip install cython==0.29.35
Collecting cython==0.29.35
  Using cached Cython-0.29.35-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (1.9 MB)
Installing collected packages: cython
  Attempting uninstall: cython
    Found existing installation: Cython 3.0.2
    Uninstalling Cython-3.0.2:
      Successfully uninstalled Cython-3.0.2
Successfully installed cython-0.29.35

try again...

$ pip install .
Processing /mnt/c/Users/baghom/Desktop/Tests/discretize
  Preparing metadata (setup.py) ... done
Requirement already satisfied: cython>=0.29.31 in /mnt/c/Users/baghom/Desktop/Tests/env/lib/python3.10/site-packages (from discretize==0.1.dev5527+g58043b9) (0.29.35)
Requirement already satisfied: numpy>=1.20 in /mnt/c/Users/baghom/Desktop/Tests/env/lib/python3.10/site-packages (from discretize==0.1.dev5527+g58043b9) (1.25.2)
Requirement already satisfied: scipy>=1.8 in /mnt/c/Users/baghom/Desktop/Tests/env/lib/python3.10/site-packages (from discretize==0.1.dev5527+g58043b9) (1.11.2)
Requirement already satisfied: setuptools_scm in /mnt/c/Users/baghom/Desktop/Tests/env/lib/python3.10/site-packages (from discretize==0.1.dev5527+g58043b9) (7.1.0)
Requirement already satisfied: packaging>=20.0 in /mnt/c/Users/baghom/Desktop/Tests/env/lib/python3.10/site-packages (from setuptools_scm->discretize==0.1.dev5527+g58043b9) (23.1)
Requirement already satisfied: typing-extensions in /mnt/c/Users/baghom/Desktop/Tests/env/lib/python3.10/site-packages (from setuptools_scm->discretize==0.1.dev5527+g58043b9) (4.7.1)
Requirement already satisfied: setuptools in /mnt/c/Users/baghom/Desktop/Tests/env/lib/python3.10/site-packages (from setuptools_scm->discretize==0.1.dev5527+g58043b9) (59.6.0)
Requirement already satisfied: tomli>=1.0.0 in /mnt/c/Users/baghom/Desktop/Tests/env/lib/python3.10/site-packages (from setuptools_scm->discretize==0.1.dev5527+g58043b9) (2.0.1)
Building wheels for collected packages: discretize
  Building wheel for discretize (setup.py) ... done
  Created wheel for discretize: filename=discretize-0.1.dev5527+g58043b9-cp310-cp310-linux_x86_64.whl size=4691875 sha256=60e3e11dfbcc8d6bc25777bf9eda2704321ede39e456811fdcb553218c87acd3
  Stored in directory: /tmp/pip-ephem-wheel-cache-0yplpgrx/wheels/fe/72/26/d10ab46336913418a55201c5aadc78a51d73715b4e0c9e47ca
Successfully built discretize
Installing collected packages: discretize
  Attempting uninstall: discretize
    Found existing installation: discretize 0.1.dev5527+g58043b9
    Uninstalling discretize-0.1.dev5527+g58043b9:
      Successfully uninstalled discretize-0.1.dev5527+g58043b9
Successfully installed discretize-0.1.dev5527+g58043b9

Nice! Let's test it now!

$ python -c "import discretize"
cannot import name 'interputils_cython' from 'discretize._extensions' (/mnt/c/Users/baghom/Desktop/Tests/discretize/discretize/_extensions/__init__.py)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/mnt/c/Users/baghom/Desktop/Tests/discretize/discretize/__init__.py", line 42, in <module>
    from discretize.unstructured_mesh import SimplexMesh
  File "/mnt/c/Users/baghom/Desktop/Tests/discretize/discretize/unstructured_mesh.py", line 7, in <module>
    from discretize._extensions.simplex_helpers import (
ModuleNotFoundError: No module named 'discretize._extensions.simplex_helpers'

Trouble! it seemed like it was installed properly, but it did not build the extensions apparently!

@jcapriot
Copy link
Member

jcapriot commented Sep 8, 2023

And if you change directories out of the source folders are you able to?
It's clearly trying to import the local version in your folder structure and not the one from site-packages.

@omid-b
Copy link
Author

omid-b commented Sep 8, 2023

Yes as you mentioned, it tries to read from the source folder rather than my env.

Here is the hotfix (but I still insist installation of discretize should not involve this many troubles!)

cd into source code dir and then copying the build files here...

$ cd /mnt/c/Users/baghom/Desktop/Tests/discretize/discretize/_extensions/
$ cp ../../../env/lib/python3.10/site-packages/discretize/_extensions/*.so ./
$ python -c "import discretize"
$ python -c "import discretize._extensions"
$ python -c "import discretize.tests"

No errors now...

@jcapriot
Copy link
Member

jcapriot commented Sep 8, 2023

But if you're doing that, why not just do an editable install? pip install -e .? That would be a better practice than copying things back from site-packages if what you want to do is to do a local install?

@omid-b
Copy link
Author

omid-b commented Sep 8, 2023

Yes I could... but how about others who are not python experts (not that I am an expert; not at all!), and just want to install and use SimPEG/Discretize? I can make it fixed the if owners/main-developers accept my contribution...

@jcapriot
Copy link
Member

jcapriot commented Sep 8, 2023

I'm just trying to make sure we understand the root cause of the issue that you are encountering, which is as I said,

Cython, numpy, and setuptools_scm are required for building the package, but only numpy is a run-time requirement. The current setup.py configuration does not successfully install the needed files when this occurs.

@omid-b
Copy link
Author

omid-b commented Sep 8, 2023

I understand your point, but still believe that it could be easily fixed to make the process more hassle-free...

An easy fix perhaps would be to modify requirements.txt as follows:

cython==0.29.35
numpy
setuptools_scm
-e .

But this hotfix is very temporary and things will go wrong again soon. Moving toward a src-layout and pyproject.toml is way to go...

omid-b added a commit to omid-b/discretize that referenced this issue Sep 10, 2023
In addition to making changes for src-layout, also fixed find_package() configurations,
so both editable and non-editable installation now work as intended.
Previousely, only editable installation was possible (simpeg#336).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants