elastic / eland

Python Client and Toolkit for DataFrames, Big Data, Machine Learning and ETL in Elasticsearch
https://eland.readthedocs.io
Apache License 2.0
636 stars 98 forks source link

Migrate to entry_points #551 #559

Closed sakurai-youhei closed 1 year ago

sakurai-youhei commented 1 year ago

Closes #551.

With this PR, eland_import_hub_model gets easier to find on Windows.

On windows: eland_import_hub_model is an executable file.

C:\Users\YouheiSakurai\git\myeland>where eland_import_hub_model
C:\Users\YouheiSakurai\AppData\Roaming\Python\Python311\Scripts\eland_import_hub_model.exe

On Linux: eland_import_hub_model is a simple auto-generated script file.

root@b16946fa4fe1:/# which eland_import_hub_model
/usr/local/bin/eland_import_hub_model

root@b16946fa4fe1:/# file `which eland_import_hub_model`
/usr/local/bin/eland_import_hub_model: Python script, ASCII text executable

root@b16946fa4fe1:/# head `which eland_import_hub_model`
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from eland.cli.eland_import_hub_model import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

Note: Because I come to think adding python -m eland would be too ambicious, I dropped it from the scope.

sakurai-youhei commented 1 year ago

As response to https://github.com/elastic/eland/pull/557#pullrequestreview-1525783718:

The following flake8 lint errors proves that noxfile covers eland/cli/eland_import_hub_model.py properly. https://github.com/elastic/eland/actions/runs/5540963903/jobs/10113737631?pr=559

davidkyle commented 1 year ago

I've tested this change on macOS and the script is installed into the exact same location as before, i.e. /Library/Frameworks/Python.framework/Versions/3.X/bin/eland_import_hub_model

davidkyle commented 1 year ago

@sakurai-youhei The build system is being migrated from Jenkins to Buildkite and there are problems which is why your PR is not passing CI. The PR did pass the CI checks previously, I've tested the change and it is good. The CI failure is nothing to do with your change so I will merge the PR and users can benefit from your change.

Thanks more making the eland_import_hub_model script easier to user.