Use setup.py entry_points for installation

This should make the installation via pip more robust.

On Windows the usage of entry_points will install a wrapper executable
for the script that chooses the proper python executable. This
essentially makes the script run correctly when called via `git
filter-repo` (direct execution via `git-filter-repo` was already fine
before).

This fixes an issue on Windows, where the git-installation will choose a
different python executable than the one indicated by the installation
via `pip{x,3} install`.

Signed-off-by: Benjamin Motz <benjamin.motz@mailbox.org>
pull/217/head
Benjamin Motz 3 years ago
parent 7ceb213f04
commit 4ff15cd422

@ -3951,7 +3951,7 @@ class RepoFilter(object):
print(_("Completely finished after {:.2f} seconds.")
.format(time.time()-start))
if __name__ == '__main__':
def main():
setup_gettext()
args = FilteringOptions.parse_args(sys.argv[1:])
if args.analyze:
@ -3959,3 +3959,6 @@ if __name__ == '__main__':
else:
filter = RepoFilter(args)
filter.run()
if __name__ == '__main__':
main()

@ -1,8 +1,21 @@
from setuptools import setup
import os
for f in ['git-filter-repo', 'git_filter_repo.py', 'README.md']:
def link_parent(src, target=None):
if target is None:
target = src
try:
os.symlink("../"+f, f)
os.symlink(os.path.join("..", src), target)
except FileExistsError:
pass
setup(use_scm_version=dict(root="..", relative_to=__file__))
for f in ['git-filter-repo', 'README.md']:
link_parent(f)
link_parent('git-filter-repo', 'git_filter_repo.py')
setup(use_scm_version=dict(root="..", relative_to=__file__),
entry_points={'console_scripts': ['git-filter-repo = git_filter_repo:main']})

Loading…
Cancel
Save