Support installation from Git using Pip #83
Labels
No Label
bugfix
cleanup
discussion
documentation
doing
done
feature
improvement
packaging
Stale
testing
TODO
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: ungleich-public/cdist#83
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently, if you try to install cdist from Git using Pip, the installation will fail because
setup.py
usescdist.version
module, which doesn't exist at the time of installation.closed
https://code.ungleich.ch/ungleich-public/cdist/merge_requests/808
Okay. So, as I've previously reported,
2d0af7b7cc
works for me. Therefore, I'd say ship it and let's leave the issue with version reported by cdist for another time.@lubo I agree with @steven. Putting setuptools_scm into cdist is heavy.
It seems, currently, that https://code.ungleich.ch/ungleich-public/cdist/tree/build/support-pip-from-git is best effort for this issue.
So, what's it gonna be?
I always hated the way cdist version is handled. That's actually the sole reason why I run from a fork which I rebase on top of master with this single commit:
I do not care about the cdist version when running from a git checkout. Actually I don't care about the cdist version at all, ever.
IMHO the question is who/when cares about the cdist version?
I would just hardcode the version in the git repo to 'git' or 'dev' or whatever and only set the actual version during packaging.
If the user is running from a git checkout
git describe
tells you the details if needed.Pulling in setuptools_scm seems a bit heavy weight IMHO. Guess it would be simpler to shell out.
@nico @steven Do we want this coupling?
You'd have to put the same code to
cdist/__init__.py
too, in addition tosetup.py
. I think "Package versioning best practices" describes this approach quite well. So, instead of this:Something like this:
So, when installed in editable mode,
cdist/version.py
shouldn't be generated and the app itself should obtain the version string ifcdist/version.py
is not found.@lubo As I understand, editable mode does some sort of link to source/cloned repo. So if you change something that will reflect package execution.
If you change something, then you expect the version to change, i.e. to be regenerated by
git describe
?I think this could not be done automatically with
pip
, you have to regenerate it by yourself by executing./bin/build-helper version
.Or I don't understand it (or the problem) properly?
Maybe you should put
version.py
tobuild/lib/cdist
, so it's used when building distributable packages, but not locally. Then, if importingversion
module fails, assume we run in editable mode and run a script that obtains the version string. Much like they do in getversion - Package versioning best practices, which I've mentioned in #783 (comment).@lubo Do you have suggestions for "Although you'll have to reinstall the package if you change something in the editable mode." ?
Although you'll have to reinstall the package if you change something in the editable mode.
2d0af7b7cc
works when installed from local and remote repository and from generated sdist too.@lubo Can you please test it? Thanks!
@lubo This https://code.ungleich.ch/ungleich-public/cdist/blob/build/support-pip-from-git/setup.py should cover git and non git cases.
@lubo Well, I have to play with it. It must support different cases.
pip from git, git clone + setup, download tar.gz from pypi or gitlab release bundle when it is not a git repo, ...
With
fc28f58c77
, this finally works:But consider cdist is installed in editable mode from locally-cloned repository (this is how I actually use cdist). If I change something in the repository (e.g., check out different tag), and reinstall the package,
version.py
won't change withfc28f58c77
. Steps to reproduce:@lubo @nico What do you think about this simple patch?
fc28f58c77
Well, if you wanna do it yourself, do something like this (but with
setuptools
, I don't have a more up-to-date article right now) and generate the file insetup.py
. Generally, this is what should be done when in need of generating files that should be packaged with your application. However, I'd recommend using setuptools_scm or something similar and do something like this. No more Make, no more custom shell scripts, just a very simple, more declarative code which should work with all installation scenarios.P.S.: I get literally no email notifications from this GitLab instance. 😕
@lubo This is because cdist uses generated version file. After cloning and before runningo
python setup.py install
one should create version file withmake version
.https://www.cdi.st/cdist-install.html#from-git
Do you perhaps know how to hook
make version
command into pip after cloning a repo?