diff --git a/.github/workflows/pypi_publish.yml b/.github/workflows/pypi_publish.yml index dcc9aa9e..458dc902 100644 --- a/.github/workflows/pypi_publish.yml +++ b/.github/workflows/pypi_publish.yml @@ -78,11 +78,6 @@ jobs: # set -vxeuo pipefail # conda install -y -c conda-forge mpi4py openmpi - - name: Copy over README.md - run: | - set -vxeuo pipefail - cp README.md env/python - - name: Install cibuildwheel on Linux if: runner.os == 'Linux' run: | @@ -113,17 +108,6 @@ jobs: mkdir -p ../../dist cp dist/*.whl ../../dist/ - # - name: Build sdist on Windows (for Python 3.11) - # if: runner.os == 'Windows' && matrix.python-version == '3.11' - # run: | - # set -vxeuo pipefail - # cd env/python - # python -VV - # python setup.py sdist - # ls -la dist/* - # mkdir -p ../../dist - # cp dist/*.tar.gz ../../dist/ - - name: Publish wheels to GitHub artifacts uses: actions/upload-artifact@v3 with: @@ -138,6 +122,9 @@ jobs: # Smoke import test: python -c "import srwpy; import srwpy.srwlpy" + # Check CLI tools: + srw-viewer --help + python -m pip install -r env/python/requirements-dev.txt python -m pip list diff --git a/env/python/setup.py b/env/python/setup.py index 0048fbd2..ec409805 100644 --- a/env/python/setup.py +++ b/env/python/setup.py @@ -77,8 +77,8 @@ def build_extension(self, ext): base_dir = os.path.dirname(os.path.realpath(__file__)) original_src_dir = os.path.join(base_dir, '../..') -#Read README.md for long_description -long_description = open(os.path.join(base_dir, 'README.md')).read() +# Read README.md for long_description +long_description = open(os.path.join(original_src_dir, 'README.md')).read() with open(os.path.join(base_dir, 'requirements.txt')) as requirements_file: # Parse requirements.txt, ignoring any commented-out lines. @@ -86,7 +86,7 @@ def build_extension(self, ext): if not line.startswith('#')] setup(name='srwpy', - version='4.0.0b0', + version='4.0.0b1', description='This is SRW for Python', author='O. Chubar et al.', author_email='chubar@bnl.gov', @@ -99,4 +99,7 @@ def build_extension(self, ext): zip_safe=False, ext_modules=[CMakeExtension('srwlpy', original_src_dir, 'srwpy')], cmdclass=dict(build_ext=CMakeBuild), + entry_points={ + 'console_scripts': ['srw-viewer=srwpy.SRWLIB_ExampleViewDataFile:main'], + }, ) diff --git a/env/python/srwpy/SRWLIB_ExampleViewDataFile.py b/env/python/srwpy/SRWLIB_ExampleViewDataFile.py index ea9379a1..15e6645b 100644 --- a/env/python/srwpy/SRWLIB_ExampleViewDataFile.py +++ b/env/python/srwpy/SRWLIB_ExampleViewDataFile.py @@ -15,7 +15,7 @@ import optparse import os -if __name__=='__main__': +def main(): p = optparse.OptionParser() p.add_option('-f', '--infile', dest='infile', metavar='FILE', default='', help='input file name') p.add_option('-e', '--e', dest='e', metavar='NUMBER', type='float', default=0, help='photon energy') @@ -58,3 +58,7 @@ opt.scale, opt.width_pixels) uti_plot_show() + + +if __name__ == "__main__": + main() diff --git a/env/python/srwpy/uti_plot.py b/env/python/srwpy/uti_plot.py index 9806ef86..6d79ec30 100644 --- a/env/python/srwpy/uti_plot.py +++ b/env/python/srwpy/uti_plot.py @@ -57,7 +57,10 @@ def uti_plot_init(backend=DEFAULT_BACKEND, fname_format=None): global _backend if backend is not None: try: - import uti_plot_matplotlib + try: + from . import uti_plot_matplotlib + except: + import uti_plot_matplotlib _backend = uti_plot_matplotlib.Backend(backend, fname_format) return except: