New entry point in package.
A module (cli.py) is used to provide an entry point for the msspec package. It is here to be PEX-compatible (https://github.com/pantsbuild/pex) that may be used to provide a zero-install msspec distribution.
This commit is contained in:
parent
bec694b16e
commit
47e35b3b7f
|
@ -13,3 +13,5 @@ src/msspec/results.txt
|
|||
**/*build/
|
||||
**/*dist/
|
||||
**/*.egg-info/
|
||||
.ropeproject
|
||||
.project
|
||||
|
|
|
@ -3,3 +3,4 @@ recursive-include . SConstruct
|
|||
include setup_requirements.txt
|
||||
include requirements.txt
|
||||
include pip.freeze
|
||||
include VERSION
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import os
|
||||
import subprocess
|
||||
import datetime
|
||||
from pkg_resources import parse_version
|
||||
from setuptools_scm import get_version
|
||||
|
||||
###############################################################################
|
||||
def filtered_glob(env, pattern, omit=[],
|
||||
|
@ -30,13 +33,30 @@ def install_module(env, module):
|
|||
env.Alias('install', destdir)
|
||||
return None
|
||||
|
||||
def version_action(target, source, env):
|
||||
with open(str(target[0]), 'w') as fd:
|
||||
v = get_version(root='../', relative_to='./', version_scheme="post-release")
|
||||
v = parse_version(v)
|
||||
if v._version.post[-1] == 0:
|
||||
version = v.base_version
|
||||
else:
|
||||
version = v.public
|
||||
fd.write(version + '\n')
|
||||
now = datetime.datetime.now().isoformat()
|
||||
fd.write(f'compiled on {now}\n')
|
||||
p = subprocess.run([env['FORTRAN'], "--version"], stdout=subprocess.PIPE)
|
||||
fd.write(p.stdout.decode('utf8'))
|
||||
|
||||
|
||||
f2py_bld = Builder(generator=f2py_generator)
|
||||
version_bld = Builder(action=version_action)
|
||||
|
||||
# define the default build environment
|
||||
std = Environment(tools=['default', 'fortran'], F2PY_OPTS=[], LIBS=[])
|
||||
std.AddMethod(filtered_glob, "FilteredGlob")
|
||||
std.AddMethod(install_module, "InstallModule")
|
||||
std['BUILDERS']['F2py'] = f2py_bld
|
||||
std['BUILDERS']['Version'] = version_bld
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
@ -96,7 +116,8 @@ if GetOption('verbose'):
|
|||
|
||||
|
||||
Export('env')
|
||||
#SConscript('msspec/spec/fortran/SConstruct')
|
||||
#SConscript('msspec/phagen/fortran/SConstruct')
|
||||
SConscript('msspec/spec/fortran/SConstruct', variant_dir='build/build_spec')
|
||||
SConscript('msspec/phagen/fortran/SConstruct', variant_dir='build/build_phagen')
|
||||
|
||||
version_file = env.Version('VERSION', [])
|
||||
Depends(version_file, "install")
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright © 2016-2020 - Rennes Physics Institute
|
||||
#
|
||||
# This file is part of msspec.
|
||||
#
|
||||
# msspec is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# msspec is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with msspec. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Source file : src/msspec/cli.py
|
||||
# Last modified: jeu. 04 juin 2020 16:54:12
|
||||
# Committed by : "Sylvain Tricot <sylvain.tricot@univ-rennes1.fr>"
|
||||
|
||||
|
||||
import sys
|
||||
import textwrap
|
||||
import subprocess
|
||||
from msspec.iodata import Data
|
||||
from pip._internal.cli.main import main as pipmain
|
||||
|
||||
|
||||
def print_info():
|
||||
s = textwrap.dedent("""
|
||||
This application is a take-away Python environment
|
||||
to run msspec.
|
||||
|
||||
Below is a list of all packages bundled with this
|
||||
interpreter.
|
||||
""")
|
||||
print(s)
|
||||
pipmain(['list'])
|
||||
s = textwrap.dedent("""
|
||||
To run a script with this interpreter, please launch
|
||||
this application with your script as an argument.
|
||||
|
||||
I let you with the interactive environment. Type in
|
||||
<CTRL>+D to exit.
|
||||
|
||||
""")
|
||||
print(s)
|
||||
|
||||
def load_py(*args):
|
||||
subprocess.run(['python'] + list(args))
|
||||
|
||||
def load_hdf5(fname):
|
||||
data = Data.load(fname)
|
||||
data.view()
|
||||
|
||||
|
||||
def main():
|
||||
argv = sys.argv
|
||||
argc = len(argv)
|
||||
if argc > 1:
|
||||
if argv[1].endswith('.hdf5'):
|
||||
load_hdf5(argv[1])
|
||||
else:
|
||||
load_py(*argv[1:])
|
||||
else:
|
||||
print_info()
|
||||
subprocess.run(['ipython', '--profile=msspec'])
|
||||
exit()
|
|
@ -25,14 +25,14 @@ import os
|
|||
from pkg_resources import DistributionNotFound
|
||||
from pkg_resources import get_distribution
|
||||
from pkg_resources import parse_version
|
||||
from setuptools_scm import get_version
|
||||
|
||||
|
||||
# find the version number
|
||||
# 1- Try to read it from the git info
|
||||
# 2- If it fails, try to read it from the distribution file
|
||||
# 3- If it fails, try to read it from the VERSION file
|
||||
|
||||
try:
|
||||
from setuptools_scm import get_version
|
||||
v = get_version(root='../../', relative_to=__file__, version_scheme="post-release")
|
||||
v = parse_version(v)
|
||||
if v._version.post[-1] == 0:
|
||||
|
@ -42,6 +42,10 @@ try:
|
|||
except Exception as err:
|
||||
try:
|
||||
__version__ = get_distribution(__name__.strip('.version')).version
|
||||
except Exception as err:
|
||||
try:
|
||||
with open("../VERSION", "r") as fd:
|
||||
__version__ = fd.readline()
|
||||
except Exception as err:
|
||||
print("Unable to get the version number!")
|
||||
__version__ = "9.9.9"
|
||||
|
|
|
@ -54,3 +54,4 @@ traitlets==4.3.3
|
|||
urllib3==1.25.8
|
||||
wcwidth==0.1.9
|
||||
wheel==0.34.2
|
||||
wxPython@https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04/wxPython-4.0.7.post2-cp36-cp36m-linux_x86_64.whl
|
||||
|
|
12
src/setup.py
12
src/setup.py
|
@ -24,17 +24,7 @@
|
|||
import sys
|
||||
sys.path.insert(0, "msspec")
|
||||
from setuptools import setup, find_packages
|
||||
try:
|
||||
from version import __version__
|
||||
except Exception as err:
|
||||
__version__ = "8.8.8"
|
||||
|
||||
|
||||
with open('setup_requirements.txt', 'r') as fd:
|
||||
SETUP_REQUIREMENTS = fd.read().strip().split('\n')
|
||||
|
||||
with open('requirements.txt', 'r') as fd:
|
||||
REQUIREMENTS = fd.read().strip().split('\n')
|
||||
|
||||
with open('pip.freeze', 'r') as fd:
|
||||
REQUIREMENTS = fd.read().strip().split('\n')
|
||||
|
@ -83,4 +73,6 @@ if __name__ == "__main__":
|
|||
],
|
||||
keywords='spectroscopy atom electron photon multiple scattering',
|
||||
license='GPL',
|
||||
entry_points={
|
||||
'console_scripts': ['msspec=msspec.cli:main']}
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue