Skip to content

Commit 4ff15cd

Browse files
committed
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 <[email protected]>
1 parent 7ceb213 commit 4ff15cd

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

git-filter-repo

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3951,11 +3951,14 @@ class RepoFilter(object):
39513951
print(_("Completely finished after {:.2f} seconds.")
39523952
.format(time.time()-start))
39533953

3954-
if __name__ == '__main__':
3954+
def main():
39553955
setup_gettext()
39563956
args = FilteringOptions.parse_args(sys.argv[1:])
39573957
if args.analyze:
39583958
RepoAnalyze.run(args)
39593959
else:
39603960
filter = RepoFilter(args)
39613961
filter.run()
3962+
3963+
if __name__ == '__main__':
3964+
main()

release/setup.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
from setuptools import setup
22
import os
3-
for f in ['git-filter-repo', 'git_filter_repo.py', 'README.md']:
3+
4+
5+
def link_parent(src, target=None):
6+
if target is None:
7+
target = src
48
try:
5-
os.symlink("../"+f, f)
9+
os.symlink(os.path.join("..", src), target)
610
except FileExistsError:
711
pass
8-
setup(use_scm_version=dict(root="..", relative_to=__file__))
12+
13+
14+
for f in ['git-filter-repo', 'README.md']:
15+
link_parent(f)
16+
17+
link_parent('git-filter-repo', 'git_filter_repo.py')
18+
19+
20+
setup(use_scm_version=dict(root="..", relative_to=__file__),
21+
entry_points={'console_scripts': ['git-filter-repo = git_filter_repo:main']})

0 commit comments

Comments
 (0)