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

How does this work when doing pip install .? #28

Open
ifiddes opened this issue Mar 9, 2021 · 2 comments
Open

How does this work when doing pip install .? #28

ifiddes opened this issue Mar 9, 2021 · 2 comments

Comments

@ifiddes
Copy link

ifiddes commented Mar 9, 2021

I am trying to modify miniver to not allow installations that do not properly resolve to a known version by raising an exception. I therefore modified all the places where unknown was returned with a new exception. This works fine for pip install -e ., but not for pip install .

This made me dig deeper, and I am not sure I understand how this is ever possible -- in the case where you are doing pip install ., the first thing pip does is copy the repo to a temporary folder, without the hidden folders, which means the .git folder is no longer present.

I am obviously missing something important here, but how can it be possible for miniver to successfully get the git version during such an install? Do I always have to install with pip install -e . if I am trying to do a local install from a repo?

@jbweston
Copy link
Owner

jbweston commented Mar 29, 2021

Hi Ian,

Sorry for the late reply.

I tried applying this patch to _version.py.
After doing so in a fresh repo with no tags, pip install . and also pip install -e . both error out (which is what we want).
When I add a tag both commands work fine again.

In the case where you are doing pip install ., the first thing pip does is copy the repo to a temporary folder

I took a closer look at the output of pip install . and it seems that it first builds a wheel:
2021-03-29-084324_936x213_scrot
The wheel will already have the version info embedded in it.

Let me know if that patch works for you; if so we could have this be an option when installing miniver.

@jbweston
Copy link
Owner

jbweston commented Mar 29, 2021

I just realized that applying that patch will mean that import mypackage will also fail, which is probably not what you want when developing 😄.

An alternative could be to just have the _build_py and/or _sdist functions error out when the version contains unknown. This would not make pip install -e . error out, unfortunately, but it might be possible to hook into setuptools' develop (which is what pip install -e . runs) to fix 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