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

Error when installing the package locally from downloaded code #8

Open
HaHeho opened this issue May 12, 2023 · 7 comments
Open

Error when installing the package locally from downloaded code #8

HaHeho opened this issue May 12, 2023 · 7 comments
Assignees

Comments

@HaHeho
Copy link
Member

HaHeho commented May 12, 2023

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 HaHeho assigned HaHeho and CarlAndersson and unassigned HaHeho May 12, 2023
@CarlAndersson
Copy link
Member

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

@HaHeho
Copy link
Member Author

HaHeho commented May 15, 2023

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.

@CarlAndersson
Copy link
Member

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.

@HaHeho
Copy link
Member Author

HaHeho commented May 16, 2023

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?

if version is None:
raise RuntimeError('Cannot get version from git, nothing to hardcode')

@CarlAndersson
Copy link
Member

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.

@HaHeho
Copy link
Member Author

HaHeho commented May 20, 2023

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?

@CarlAndersson
Copy link
Member

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

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