Skip to content

Commit 9338785

Browse files
authored
Merge pull request #44 from mrakitin/fix-imports-and-cli-viewer
Fix imports and add CLI file viewer
2 parents 05e0a9b + 25fb0e1 commit 9338785

File tree

4 files changed

+18
-21
lines changed

4 files changed

+18
-21
lines changed

.github/workflows/pypi_publish.yml

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ jobs:
7878
# set -vxeuo pipefail
7979
# conda install -y -c conda-forge mpi4py openmpi
8080

81-
- name: Copy over README.md
82-
run: |
83-
set -vxeuo pipefail
84-
cp README.md env/python
85-
8681
- name: Install cibuildwheel on Linux
8782
if: runner.os == 'Linux'
8883
run: |
@@ -113,17 +108,6 @@ jobs:
113108
mkdir -p ../../dist
114109
cp dist/*.whl ../../dist/
115110
116-
# - name: Build sdist on Windows (for Python 3.11)
117-
# if: runner.os == 'Windows' && matrix.python-version == '3.11'
118-
# run: |
119-
# set -vxeuo pipefail
120-
# cd env/python
121-
# python -VV
122-
# python setup.py sdist
123-
# ls -la dist/*
124-
# mkdir -p ../../dist
125-
# cp dist/*.tar.gz ../../dist/
126-
127111
- name: Publish wheels to GitHub artifacts
128112
uses: actions/upload-artifact@v3
129113
with:
@@ -138,6 +122,9 @@ jobs:
138122
# Smoke import test:
139123
python -c "import srwpy; import srwpy.srwlpy"
140124
125+
# Check CLI tools:
126+
srw-viewer --help
127+
141128
python -m pip install -r env/python/requirements-dev.txt
142129
python -m pip list
143130

env/python/setup.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,16 @@ def build_extension(self, ext):
7777
base_dir = os.path.dirname(os.path.realpath(__file__))
7878
original_src_dir = os.path.join(base_dir, '../..')
7979

80-
#Read README.md for long_description
81-
long_description = open(os.path.join(base_dir, 'README.md')).read()
80+
# Read README.md for long_description
81+
long_description = open(os.path.join(original_src_dir, 'README.md')).read()
8282

8383
with open(os.path.join(base_dir, 'requirements.txt')) as requirements_file:
8484
# Parse requirements.txt, ignoring any commented-out lines.
8585
requirements = [line for line in requirements_file.read().splitlines()
8686
if not line.startswith('#')]
8787

8888
setup(name='srwpy',
89-
version='4.0.0b0',
89+
version='4.0.0b1',
9090
description='This is SRW for Python',
9191
author='O. Chubar et al.',
9292
author_email='[email protected]',
@@ -99,4 +99,7 @@ def build_extension(self, ext):
9999
zip_safe=False,
100100
ext_modules=[CMakeExtension('srwlpy', original_src_dir, 'srwpy')],
101101
cmdclass=dict(build_ext=CMakeBuild),
102+
entry_points={
103+
'console_scripts': ['srw-viewer=srwpy.SRWLIB_ExampleViewDataFile:main'],
104+
},
102105
)

env/python/srwpy/SRWLIB_ExampleViewDataFile.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import optparse
1616
import os
1717

18-
if __name__=='__main__':
18+
def main():
1919
p = optparse.OptionParser()
2020
p.add_option('-f', '--infile', dest='infile', metavar='FILE', default='', help='input file name')
2121
p.add_option('-e', '--e', dest='e', metavar='NUMBER', type='float', default=0, help='photon energy')
@@ -58,3 +58,7 @@
5858
opt.scale, opt.width_pixels)
5959

6060
uti_plot_show()
61+
62+
63+
if __name__ == "__main__":
64+
main()

env/python/srwpy/uti_plot.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ def uti_plot_init(backend=DEFAULT_BACKEND, fname_format=None):
5757
global _backend
5858
if backend is not None:
5959
try:
60-
import uti_plot_matplotlib
60+
try:
61+
from . import uti_plot_matplotlib
62+
except:
63+
import uti_plot_matplotlib
6164
_backend = uti_plot_matplotlib.Backend(backend, fname_format)
6265
return
6366
except:

0 commit comments

Comments
 (0)