From a3325025e06207a69214d5ef46a610cbf259d368 Mon Sep 17 00:00:00 2001 From: Roberto Javier Homs Puron Date: Tue, 31 Mar 2020 16:12:10 +0200 Subject: [PATCH 1/7] Adapt to use entry points instead of scripts --- PyPLC/PyPLC.py | 8 ++++++-- setup.py | 9 ++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/PyPLC/PyPLC.py b/PyPLC/PyPLC.py index 782e653..b994e06 100644 --- a/PyPLC/PyPLC.py +++ b/PyPLC/PyPLC.py @@ -1785,7 +1785,7 @@ def __init__(self, name): # PyPLC class main method # #================================================================== -if __name__ == '__main__': +def main(): try: py = ('PyUtil' in dir(PyTango) and PyTango.PyUtil or PyTango.Util)(sys.argv) from fandango.interface import FullTangoInheritance @@ -1811,7 +1811,11 @@ def __init__(self, name): except Exception,e: print '__main__ -------> An unforeseen exception occured....',e traceback.print_exc() - + + +if __name__ == '__main__': + main() + else: from fandango.interface import FullTangoInheritance PyPLC,PyPLCClass = FullTangoInheritance('PyPLC',PyPLC,PyPLCClass,DynamicDS,DynamicDSClass,Exclude=['Lock','Unlock','isLocked'],ForceDevImpl=True) diff --git a/setup.py b/setup.py index 17bed95..3e4e8f1 100644 --- a/setup.py +++ b/setup.py @@ -23,10 +23,9 @@ ------------------------------------------------------------------------------- """ -print(__doc__) +# print(__doc__) version = str(open('PyPLC/VERSION').read().strip()) -scripts = ['bin/PyPLC'] license = 'GPL-3.0' package_dir = {'PyPLC': 'PyPLC',} @@ -41,7 +40,11 @@ description = 'Tango device for Modbus equipment', packages = packages, package_dir= package_dir, - scripts = scripts, + entry_points={ + 'console_scripts': [ + 'PyPLC = PyPLC.PyPLC:main' + ] + }, include_package_data = True, package_data = package_data, install_requires=['fandango>=14.6.0','PyTango'], From 798714bc1e8922e11c1f5b8892c21bd0bf04e456 Mon Sep 17 00:00:00 2001 From: Roberto Javier Homs Puron Date: Tue, 31 Mar 2020 16:13:00 +0200 Subject: [PATCH 2/7] Update git ignore file --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 72364f9..2e05ce6 100644 --- a/.gitignore +++ b/.gitignore @@ -87,3 +87,6 @@ ENV/ # Rope project settings .ropeproject + +# JetBrain +.idea \ No newline at end of file From f0cdd589571924e07e643a329ba3520e0be02958 Mon Sep 17 00:00:00 2001 From: Roberto Javier Homs Puron Date: Tue, 31 Mar 2020 16:19:16 +0200 Subject: [PATCH 3/7] Add conda package configuration --- conda/conda_build_config.yaml | 6 +++++ conda/meta.yaml | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 conda/conda_build_config.yaml create mode 100644 conda/meta.yaml diff --git a/conda/conda_build_config.yaml b/conda/conda_build_config.yaml new file mode 100644 index 0000000..b5d49c7 --- /dev/null +++ b/conda/conda_build_config.yaml @@ -0,0 +1,6 @@ +python: + - 2.7 + +numpy: + - 1.11 + diff --git a/conda/meta.yaml b/conda/meta.yaml new file mode 100644 index 0000000..7240d3e --- /dev/null +++ b/conda/meta.yaml @@ -0,0 +1,42 @@ +{% set data = load_setup_py_data(setup_file="../setup.py", + from_recipe_dir=True) %} + +package: + name: {{ data.get('name') }} + version: {{ data.get('version') }} + +source: + path: .. + +build: + noarch: python + script: '{{PYTHON}} setup.py install --single-version-externally-managed + --record=record.txt' + + string: 'py{{CONDA_PY}}_{{GIT_DESCRIBE_HASH}}' + entry_points: + - PyPLC = PyPLC.PyPLC:main + +requirements: + host: + - python {{python}} + - setuptools + run: + - python {{python}} + - fandango + - pytango + + +test: + import: + - {{data.get('name')}} + +about: + home: {{ data.get('url')}} + license: {{ data.get('license')}} + summary: {{ data.get('description')}} + author: {{ data.get('author')}} + description: {{ data.get('long_description')}} + + + From 033e04a76bc8ff6217c2d236da9aadbd686c726b Mon Sep 17 00:00:00 2001 From: Roberto Javier Homs Puron Date: Wed, 1 Apr 2020 11:00:30 +0200 Subject: [PATCH 4/7] Add build number to the package name --- conda/meta.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/conda/meta.yaml b/conda/meta.yaml index 7240d3e..58c3b16 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -9,11 +9,13 @@ source: path: .. build: + number: {{environ.get('BUILD_NUMBER',0)}} noarch: python script: '{{PYTHON}} setup.py install --single-version-externally-managed --record=record.txt' - string: 'py{{CONDA_PY}}_{{GIT_DESCRIBE_HASH}}' + string: 'py{{CONDA_PY}}_{{ PKG_BUILDNUM }}_{{environ.get + ("GIT_DESCRIBE_HASH",0) }}' entry_points: - PyPLC = PyPLC.PyPLC:main From 0e29f21a33a078defc22ccf2dddfe89e9522cfec Mon Sep 17 00:00:00 2001 From: Roberto Javier Homs Puron Date: Wed, 1 Apr 2020 16:21:22 +0200 Subject: [PATCH 5/7] Fix error on module name --- conda/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda/meta.yaml b/conda/meta.yaml index 58c3b16..0028baa 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -31,7 +31,7 @@ requirements: test: import: - - {{data.get('name')}} + - PyPLC about: home: {{ data.get('url')}} From cbc3db6d7f6cc16a462967d79df53bb2f3f8ccea Mon Sep 17 00:00:00 2001 From: Roberto Javier Homs Puron Date: Fri, 3 Apr 2020 13:50:04 +0200 Subject: [PATCH 6/7] Fix mistake --- conda/meta.yaml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/conda/meta.yaml b/conda/meta.yaml index 0028baa..7b9411d 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -1,6 +1,8 @@ {% set data = load_setup_py_data(setup_file="../setup.py", from_recipe_dir=True) %} +{% set GIT_HASHTAG = os.popen("git describe --always").read().strip()%} + package: name: {{ data.get('name') }} version: {{ data.get('version') }} @@ -14,10 +16,8 @@ build: script: '{{PYTHON}} setup.py install --single-version-externally-managed --record=record.txt' - string: 'py{{CONDA_PY}}_{{ PKG_BUILDNUM }}_{{environ.get - ("GIT_DESCRIBE_HASH",0) }}' - entry_points: - - PyPLC = PyPLC.PyPLC:main + string: 'py{{CONDA_PY}}_{{ PKG_BUILDNUM }}_g{{GIT_HASHTAG}}' + entry_points: {{data.get('entry_points', {}).get('console_scripts', [])}} requirements: host: @@ -28,10 +28,14 @@ requirements: - fandango - pytango - test: - import: - - PyPLC + requires: + - fandango + - pytango + imports: + {% for pack in data['packages'] %} + - {{pack}} + {% endfor %} about: home: {{ data.get('url')}} From 85fed6eef68c438244aedf71c8bfc5996d222f34 Mon Sep 17 00:00:00 2001 From: Roberto Javier Homs Puron Date: Fri, 3 Apr 2020 17:22:29 +0200 Subject: [PATCH 7/7] Add more robust way to get the git hash --- conda/meta.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conda/meta.yaml b/conda/meta.yaml index 7b9411d..9d76c78 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -1,7 +1,8 @@ {% set data = load_setup_py_data(setup_file="../setup.py", from_recipe_dir=True) %} -{% set GIT_HASHTAG = os.popen("git describe --always").read().strip()%} +{% set GIT_HASHTAG = os.popen("git log --pretty=format:'%h' -n 1" ) + .read().strip()%} package: name: {{ data.get('name') }}