Skip to content

Commit

Permalink
Merge pull request #44 from mrakitin/fix-imports-and-cli-viewer
Browse files Browse the repository at this point in the history
Fix imports and add CLI file viewer
  • Loading branch information
ochubar authored May 26, 2023
2 parents 05e0a9b + 25fb0e1 commit 9338785
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
19 changes: 3 additions & 16 deletions .github/workflows/pypi_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
9 changes: 6 additions & 3 deletions env/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ 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.
requirements = [line for line in requirements_file.read().splitlines()
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',
Expand All @@ -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'],
},
)
6 changes: 5 additions & 1 deletion env/python/srwpy/SRWLIB_ExampleViewDataFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -58,3 +58,7 @@
opt.scale, opt.width_pixels)

uti_plot_show()


if __name__ == "__main__":
main()
5 changes: 4 additions & 1 deletion env/python/srwpy/uti_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 9338785

Please sign in to comment.