acoustics-hardware icon indicating copy to clipboard operation
acoustics-hardware copied to clipboard

Error when installing the package locally from downloaded code

Open HaHeho opened this issue 1 year ago • 7 comments

Steps to reproduce:

  • Download code as ZIP (not git clone) unpack and navigate into directory
  • conda env create --file environment.yml

The setup process after downloading can be shortened to trigger the error:

conda create -n ahd pip
conda activate ahd
pip install .

Error:

Obtaining file:///Users/helmholz/Downloads/acoustics-hardware-master
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [11 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/Users/helmholz/Downloads/acoustics-hardware-master/setup.py", line 9, in <module>
          with version_manager() as version:
        File "/Users/helmholz/miniconda3/envs/ahd_test/lib/python3.11/contextlib.py", line 137, in __enter__
          return next(self.gen)
                 ^^^^^^^^^^^^^^
        File "/Users/helmholz/Downloads/acoustics-hardware-master/acoustics_hardware/_version.py", line 67, in version_manager
          raise RuntimeError('Cannot get version from git, nothing to hardcode')
      RuntimeError: Cannot get version from git, nothing to hardcode
      [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.

This occurs independent of the python version (I believe I testes 3.9, 3.10 and 3.11). So the issue has probably existed unnoticed for a while (I usually always clone).

HaHeho avatar May 12 '23 14:05 HaHeho

Why not install from pypi if you don't want to clone the repo?

CarlAndersson avatar May 15 '23 07:05 CarlAndersson

Why not install from pypi if you don't want to clone the repo?

The purpose was to use the example notebooks 1) from my SMA example branch (which is not in a PyPI release) or 2) from the main branch (but the notebooks are not included in the PyPI release).

There are, of course, alternatives to make it work. But downloading + installing via conda environment.yml is also a viable path that should be viable.

HaHeho avatar May 15 '23 09:05 HaHeho

Another option is to install directly from a git branch with pip, and then just download the example you want to run and not the entire repo. In my opinion, installing from a downloaded (not cloned) repo is not a good idea since it removes information about what version you installed.

CarlAndersson avatar May 16 '23 07:05 CarlAndersson

In my opinion, the version is irrelevant if someone installs a local copy that has potentially been modified. A person doing this will never try to do a pip install --upgrade of the package.

There should be some fallback in order not to prevent a fundamental use case like pip install .. The fallback version could be "0.0" or "0.0.dev" or "0.0.local" here? https://github.com/AppliedAcousticsChalmers/acoustics-hardware/blob/d18bb6e6848a885d131b885dc0fbdf55654da7e5/acoustics_hardware/_version.py#L66-L67

HaHeho avatar May 16 '23 18:05 HaHeho

The ability to detect if the version is modified or not is exactly why I get the version info from the git repo. The only limitation here is that you cannot install from a zipped repo.

CarlAndersson avatar May 18 '23 10:05 CarlAndersson

There should be some fallback in order not to prevent a fundamental use case like pip install .. The fallback version could be "0.0" or "0.0.dev" or "0.0.local" here?

A fallback without raising an exception to prevent the entire process is not viable?

HaHeho avatar May 20 '23 16:05 HaHeho

Of course it's possible. I guess I just don't see the point why you would actually need this.

CarlAndersson avatar May 31 '23 13:05 CarlAndersson