27 changed files with 548 additions and 228 deletions
@ -1,24 +1,15 @@
|
||||
Installation on Arch Linux systems |
||||
================================== |
||||
|
||||
These example instructions are for a system-wide installation of Pyrocko under |
||||
Arch Linux with default Python 3. |
||||
Use the general Linux installation instructions: :doc:`index` |
||||
|
||||
.. code-block:: bash |
||||
:caption: **Arch Linux** (e.g. 2021.06.01) |
||||
Prerequisites |
||||
------------- |
||||
|
||||
sudo pacman -Syu git make gcc patch python python-setuptools \ |
||||
python-numpy python-scipy python-matplotlib \ |
||||
python-pyqt5 qt5-webengine qt5-svg qt5-webkit \ |
||||
python-cairo python-progressbar \ |
||||
python-requests python-yaml python-jinja \ |
||||
python-nose python-coverage |
||||
The following packages are installed on Arch when running |
||||
``python install.py deps system`` in Pyrocko's project directory: |
||||
|
||||
cd ~/src/ # or wherever you keep your source packages |
||||
git clone https://git.pyrocko.org/pyrocko/pyrocko.git pyrocko |
||||
cd pyrocko |
||||
sudo python setup.py install |
||||
|
||||
For instructions on how to install Pyrocko on other systems or if the |
||||
installation with the above procedure fails, see :doc:`../index` or |
||||
:doc:`/install/details`. |
||||
.. literalinclude :: /../../prerequisites/prerequisites_arch_python3.sh |
||||
:caption: Arch system packages satisfying Pyrocko's requirements. |
||||
Executed by ``python install.py deps system`` |
||||
:lines: 3- |
||||
|
@ -1,24 +1,15 @@
|
||||
Installation on Centos and other rpm-based systems |
||||
-------------------------------------------------- |
||||
================================================== |
||||
|
||||
These example instructions are for a system-wide installation of Pyrocko under |
||||
Centos 8 with Python 3. Slight variations may work on other rpm-based systems. |
||||
Use the general Linux installation instructions: :doc:`index` |
||||
|
||||
.. code-block:: bash |
||||
:caption: e.g. **Centos 8**, Python 3 |
||||
Prerequisites |
||||
------------- |
||||
|
||||
sudo yum install epel-release dnf-plugins-core |
||||
sudo yum config-manager --set-enabled powertools |
||||
The following packages are installed on Centos systems when running |
||||
``python install.py deps system`` in Pyrocko's project directory: |
||||
|
||||
sudo yum install make gcc git python3 python3-yaml python3-matplotlib |
||||
sudo yum install python3-numpy python3-scipy python3-requests |
||||
sudo yum install python3-jinja2 python3-qt5 python3-matplotlib-qt5 |
||||
|
||||
cd ~/src/ # or wherever you keep your source packages |
||||
git clone https://git.pyrocko.org/pyrocko/pyrocko.git pyrocko |
||||
cd pyrocko |
||||
sudo python3 setup.py install |
||||
|
||||
For instructions on how to install Pyrocko on other systems or if the |
||||
installation with the above procedure fails, see :doc:`../index` or |
||||
:doc:`/install/details`. |
||||
.. literalinclude :: /../../prerequisites/prerequisites_centos_python3.sh |
||||
:caption: Centos system packages satisfying Pyrocko's requirements. |
||||
Executed by ``python install.py deps system`` |
||||
:lines: 3- |
||||
|
@ -1,25 +1,15 @@
|
||||
Installation on Ubuntu, Debian, Mint, ... |
||||
========================================= |
||||
|
||||
These example instructions should work for a system-wide installation of |
||||
Pyrocko under deb-based Linuxes with Python 3. |
||||
Use the general Linux installation instructions: :doc:`index` |
||||
|
||||
.. code-block:: bash |
||||
:caption: e.g. **Ubuntu** (14.04, 16.04, 18.04, 20.04), **Debian** (8, 9, 10), **Mint** (17, 18, 19, 20) |
||||
Prerequisites |
||||
------------- |
||||
|
||||
sudo apt-get install -y make git python3-dev python3-setuptools |
||||
sudo apt-get install -y python3-yaml python3-progressbar python3-jinja2 |
||||
sudo apt-get install -y python3-requests |
||||
sudo apt-get install -y python3-numpy python3-numpy-dev python3-scipy python3-matplotlib |
||||
sudo apt-get install -y python3-pyqt5 python3-pyqt5.qtopengl python3-pyqt5.qtsvg |
||||
# the following may emit an error message which can be ignored |
||||
sudo apt-get install -y python3-pyqt5.qtwebengine || sudo apt-get install -y python3-pyqt5.qtwebkit |
||||
The following packages are installed on Debian based systems when running |
||||
``python install.py deps system`` in Pyrocko's project directory: |
||||
|
||||
cd ~/src/ # or wherever you keep your source packages |
||||
git clone https://git.pyrocko.org/pyrocko/pyrocko.git pyrocko |
||||
cd pyrocko |
||||
sudo python3 setup.py install |
||||
|
||||
For instructions on how to install Pyrocko on other systems or if the |
||||
installation with the above procedure fails, see :doc:`../index` or |
||||
:doc:`/install/details`. |
||||
.. literalinclude :: /../../prerequisites/prerequisites_debian_python3.sh |
||||
:caption: Debian system packages satisfying Pyrocko's requirements. |
||||
Executed by ``python install.py deps system`` |
||||
:lines: 3- |
||||
|
@ -1,23 +1,15 @@
|
||||
Installation on OpenSuse systems |
||||
================================ |
||||
|
||||
These example instructions should work for a system-wide installation of |
||||
Pyrocko under OpenSuse Linuxes with Python 3. |
||||
Use the general Linux installation instructions: :doc:`index` |
||||
|
||||
.. code-block:: bash |
||||
:caption: **OpenSuse** (e.g. 42.1) |
||||
Prerequisites |
||||
------------- |
||||
|
||||
sudo zypper -n install make git gcc python3-devel python3-setuptools \ |
||||
python3-numpy python3-numpy-devel python3-scipy python3-matplotlib \ |
||||
python3-qt5 \ |
||||
python3-PyYAML python3-progressbar python3-Jinja2 \ |
||||
python3-requests |
||||
The following packages are installed on OpenSuse systems when running |
||||
``python install.py deps system`` in Pyrocko's project directory: |
||||
|
||||
cd ~/src/ # or wherever you keep your source packages |
||||
git clone https://git.pyrocko.org/pyrocko/pyrocko.git pyrocko |
||||
cd pyrocko |
||||
sudo python3 setup.py install |
||||
|
||||
For instructions on how to install Pyrocko on other systems or if the |
||||
installation with the above procedure fails, see :doc:`../index` or |
||||
:doc:`/install/details`. |
||||
.. literalinclude :: /../../prerequisites/prerequisites_opensuse_python3.sh |
||||
:caption: Opensuse system packages satisfying Pyrocko's requirements. |
||||
Executed by ``python install.py deps system`` |
||||
:lines: 3- |
||||
|
@ -0,0 +1,320 @@
|
||||
|
||||
import sys |
||||
import os |
||||
import re |
||||
import platform |
||||
import argparse |
||||
import shlex |
||||
import subprocess |
||||
import textwrap |
||||
|
||||
|
||||
def wrap(s): |
||||
lines = [] |
||||
parts = re.split(r'\n{2,}', s) |
||||
for part in parts: |
||||
if part.startswith('usage:'): |
||||
lines.extend(part.splitlines()) |
||||
else: |
||||
for line in part.splitlines(): |
||||
if not line: |
||||
lines.append(line) |
||||
if not line.startswith(' '): |
||||
lines.extend( |
||||
textwrap.wrap(line, 79,)) |
||||
else: |
||||
lines.extend( |
||||
textwrap.wrap(line, 79, subsequent_indent=' '*24)) |
||||
|
||||
lines.append('') |
||||
|
||||
return '\n'.join(lines) |
||||
|
||||
|
||||
def yes(parser): |
||||
parser.add_argument( |
||||
'-y', '--yes', |
||||
help='do not ask any questions (batch mode)', |
||||
action='store_true', |
||||
default=False) |
||||
|
||||
|
||||
def quiet(parser): |
||||
parser.add_argument( |
||||
'-q', '--quiet', |
||||
help='do not print executed commands', |
||||
action='store_true', |
||||
default=False) |
||||
|
||||
|
||||
commands = { |
||||
'description': wrap( |
||||
'This is Pyrocko\'s "from source" installation helper.\n\nIt provides ' |
||||
'shortcut commands to circumvent pip\'s default automatic dependency ' |
||||
'resolution which may be problematic, e.g. when prerequisites should ' |
||||
'be supplied either by the system\'s native package manager, or by ' |
||||
'other non-pip package managers, like conda. ' |
||||
'\n\n' |
||||
'Examples:\n\n' |
||||
'For a system-wide installation of Pyrocko "from source", run:' |
||||
'\n\n' |
||||
' /usr/bin/python install.py deps system\n' |
||||
' /usr/bin/python install.py system\n' |
||||
'\n' |
||||
'For installation "from source" into the currently activated conda ' |
||||
'environment:\n\n' |
||||
' python install.py deps conda\n' |
||||
' python install.py user\n' |
||||
'\n' |
||||
'For installation "from source" into a fresh venv with prerequisites ' |
||||
'supplied by the systems native package manager:\n\n' |
||||
' /usr/bin/python -m venv --system-site-packages myenv\n' |
||||
' source myenv/bin/activate\n' |
||||
' python install.py deps system\n' |
||||
' python install.py user\n' |
||||
'\n' |
||||
'For installation "from source" into a fresh venv with prerequisites ' |
||||
'supplied by pip (result is in this case similar to a standard ' |
||||
'"pip install .").:\n\n' |
||||
' /usr/bin/python -m venv myenv\n' |
||||
' source myenv/bin/activate\n' |
||||
' python install.py deps pip\n' |
||||
' python install.py user\n' |
||||
'\n' |
||||
'For batch installations with no questions add --yes --quiet to the ' |
||||
'selected subcommands.' |
||||
), |
||||
'subcommands': { |
||||
'deps': { |
||||
'help': 'install prerequisites', |
||||
'description': wrap( |
||||
'Install Pyrocko\'s prerequisites for a subsequent build and ' |
||||
'install "from source", using the selected installation type. ' |
||||
'Please consult the --help message of the available ' |
||||
'subcommands for further information.'), |
||||
'subcommands': { |
||||
'pip': { |
||||
'help': 'install prerequisites using pip', |
||||
'description': wrap( |
||||
'Install Pyrocko\'s prerequisites using pip into user ' |
||||
'environment. This command invokes `pip install` with ' |
||||
'the appropriate list of prerequisites to prepare the ' |
||||
'user\'s environment for a subsequent build and ' |
||||
'install of Pyrocko "from source".'), |
||||
'arguments': [yes, quiet], |
||||
}, |
||||
'conda': { |
||||
'help': 'install prerequisites using conda', |
||||
'description': wrap( |
||||
'Install Pyrocko\'s prerequisites using conda into ' |
||||
'into the user\'s environment. This command invokes ' |
||||
'`conda install` with the appropriate list of ' |
||||
'prerequisites to prepare the currently selected ' |
||||
'conda environment for a subsequent build and install ' |
||||
'of Pyrocko "from source".'), |
||||
'arguments': [yes, quiet], |
||||
}, |
||||
'system': { |
||||
'help': 'install prerequisites using the system\'s ' |
||||
'package manager', |
||||
'description': wrap( |
||||
'Install prerequisites using the system\'s ' |
||||
'package manager. On supported platforms, this ' |
||||
'command invokes the system\'s package manager ' |
||||
'with the appropriate list of system packages to ' |
||||
'prepare for a subsequent build and install of ' |
||||
'Pyrocko "from source".'), |
||||
'arguments': [yes, quiet], |
||||
}, |
||||
}, |
||||
}, |
||||
'user': { |
||||
'help': 'install into user or conda environment', |
||||
'description': wrap( |
||||
'Build Pyrocko "from source" and install it into user or ' |
||||
'conda environment. Use this installation method if you do ' |
||||
'not have "sudo" access on your system, or if you want to ' |
||||
'install into a virtual, or a conda environment. The selected ' |
||||
'options will prevent pip from automatically installing ' |
||||
'dependencies. Use one of the `deps` subcommands to satisfy ' |
||||
'Pyrocko\'s requirements before running this installer.'), |
||||
'arguments': [yes, quiet], |
||||
}, |
||||
'system': { |
||||
'help': 'install system-wide', |
||||
'description': wrap( |
||||
'Build Pyrocko "from source" and install it system-wide for ' |
||||
'all users. Requires "sudo" access. The selected options will ' |
||||
'prevent pip from automatically installing dependencies. Use ' |
||||
'the "deps system" subcommand to satisfy ' 'Pyrocko\'s ' |
||||
'requirements with system packages before running this ' |
||||
'installer.'), |
||||
'arguments': [yes, quiet], |
||||
}, |
||||
} |
||||
} |
||||
|
||||
|
||||
def die(message): |
||||
sys.exit('Error: %s' % message) |
||||
|
||||
|
||||
def confirm(s, force, quiet): |
||||
if not force: |
||||
try: |
||||
return input( |
||||
'Execute:\n\n%s\n\nProceed? [y/n] ' % s).lower() == 'y' |
||||
except KeyboardInterrupt: |
||||
print() |
||||
return False |
||||
|
||||
elif not quiet: |
||||
print('Running:\n\n%s\n\n' % s) |
||||
return True |
||||
else: |
||||
return True |
||||
|
||||
|
||||
def do_command(cmd, force=False, quiet=False): |
||||
qcmd = indent(' '.join(shlex.quote(s) for s in cmd)) |
||||
|
||||
if confirm(qcmd, force, quiet): |
||||
try: |
||||
subprocess.run(cmd, check=True) |
||||
except subprocess.CalledProcessError: |
||||
die('Error: Called process exited with error.') |
||||
|
||||
except OSError as e: |
||||
die('Could not run the requested command: %s' % e) |
||||
else: |
||||
sys.exit('Aborted.') |
||||
|
||||
|
||||
def indent(s): |
||||
return '\n'.join(' ' + line for line in s.splitlines()) |
||||
|
||||
|
||||
def do_shell_script(fn, force=False, quiet=False): |
||||
qscript = indent(open(fn, 'r').read()) |
||||
|
||||
if confirm(qscript, force, quiet): |
||||
os.execl('/bin/sh', 'sh', fn) |
||||
else: |
||||
sys.exit('Aborted.') |
||||
|
||||
|
||||
def cmd_deps_conda(parser, args): |
||||
|
||||
if platform.system().lower() == 'windows': |
||||
requirements = 'requirements-conda-windows.txt' |
||||
else: |
||||
requirements = 'requirements-conda.txt' |
||||
|
||||
do_command( |
||||
['conda', 'install', '--file', requirements], |
||||
force=args.yes, quiet=args.quiet) |
||||
|
||||
|
||||
def cmd_deps_pip(parser, args): |
||||
do_command( |
||||
['pip', 'install', '-r', 'requirements-all.txt'], |
||||
force=args.yes, quiet=args.quiet) |
||||
|
||||
|
||||
def cmd_deps_system(parser, args): |
||||
distribution = '' |
||||
try: |
||||
distribution = platform.linux_distribution()[0].lower().rstrip() |
||||
except Exception: |
||||
pass |
||||
|
||||
if not distribution: |
||||
try: |
||||
uname = platform.uname() |
||||
if uname[2].find('arch') != -1: |
||||
distribution = 'arch' |
||||
elif uname[3].lower().find('ubuntu') != -1: |
||||
distribution = 'ubuntu' |
||||
except Exception: |
||||
pass |
||||
|
||||
if not distribution: |
||||
sys.exit( |
||||
'Cannot determine platform for automatic prerequisite ' |
||||
'installation.') |
||||
|
||||
if distribution == 'ubuntu': |
||||
distribution = 'debian' |
||||
|
||||
if distribution.startswith('centos'): |
||||
distribution = 'centos' |
||||
|
||||
fn = 'prerequisites/prerequisites_%s_python%i.sh' % ( |
||||
distribution, sys.version_info.major) |
||||
|
||||
do_shell_script(fn, force=args.yes, quiet=args.quiet) |
||||
|
||||
|
||||
def cmd_user(parser, args): |
||||
do_command([ |
||||
'pip', 'install', '--no-deps', '--no-build-isolation', |
||||
'--force-reinstall', '.'], |
||||
force=args.yes, quiet=args.quiet) |
||||
|
||||
|
||||
def cmd_system(parser, args): |
||||
do_command([ |
||||
'sudo', 'pip', 'install', '--no-deps', '--no-build-isolation', |
||||
'--force-reinstall', '.'], |
||||
force=args.yes, quiet=args.quiet) |
||||
|
||||
|
||||
def print_help(parser, args): |
||||
parser.print_help() |
||||
|
||||
|
||||
def kwargs(d, keys): |
||||
return dict((k, d[k]) for k in keys if k in d) |
||||
|
||||
|
||||
class HelpFormatter(argparse.RawDescriptionHelpFormatter): |
||||
def __init__(self, *args, **kwargs): |
||||
kwargs['width'] = 79 |
||||
argparse.RawDescriptionHelpFormatter.__init__( |
||||
self, *args, **kwargs) |
||||
|
||||
|
||||
def make_parser(d, name=None, parent=None, path=()): |
||||
|
||||
if parent is None: |
||||
parser = argparse.ArgumentParser( |
||||
formatter_class=HelpFormatter, |
||||
**kwargs(d, ['description'])) |
||||
parser.set_defaults(func=print_help, parser=parser) |
||||
|
||||
else: |
||||
parser = parent.add_parser( |
||||
name, |
||||
formatter_class=HelpFormatter, |
||||
**kwargs(d, ['help', 'description'])) |
||||
|
||||
if 'arguments' in d: |
||||
for func in d['arguments']: |
||||
func(parser) |
||||
|
||||
if 'subcommands' in d: |
||||
subparsers = parser.add_subparsers(title='subcommands') |
||||
for name, d in d['subcommands'].items(): |
||||
subparser = make_parser(d, name, subparsers, path + (name,)) |
||||
subparser.set_defaults( |
||||
func=globals().get( |
||||
'cmd_%s' % '_'.join(path + (name,)), |
||||
print_help), |
||||
parser=subparser) |
||||
|
||||
return parser |
||||
|
||||
|
||||
parser = make_parser(commands) |
||||
args = parser.parse_args() |
||||
args.func(args.parser, args) |
@ -1,66 +0,0 @@
|
||||
#!/usr/bin/env python |
||||
|
||||
from __future__ import absolute_import, division, print_function |
||||
|
||||
import platform |
||||
import sys |
||||
import os |
||||
|
||||
if '--help' in sys.argv[1:] or '-h' in sys.argv[1:]: |
||||
sys.exit('''usage: install_prerequisites.py [--yes] [--help] |
||||
|
||||
Try to install Pyrocko's prerequisites through your system's native package |
||||
manager. This script simply calls a shell script (see under `prerequisites/`) |
||||
appropriate for your system and Python version. |
||||
|
||||
Options: |
||||
|
||||
--yes Do not ask any questions (batch mode). |
||||
--help Show this help message and exit |
||||
|
||||
''') |
||||
|
||||
force_yes = '--yes' in sys.argv[1:] |
||||
|
||||
|
||||
distribution = '' |
||||
try: |
||||
distribution = platform.linux_distribution()[0].lower().rstrip() |
||||
except Exception: |
||||
pass |
||||
|
||||
if not distribution: |
||||
try: |
||||
uname = platform.uname() |
||||
if uname[2].find('arch') != -1: |
||||
distribution = 'arch' |
||||
elif uname[3].lower().find('ubuntu') != -1: |
||||
distribution = 'ubuntu' |
||||
except Exception: |
||||
pass |
||||
|
||||
if not distribution: |
||||
sys.exit( |
||||
'Cannot determine platform for automatic prerequisite installation.') |
||||
|
||||
if distribution == 'ubuntu': |
||||
distribution = 'debian' |
||||
|
||||
if distribution.startswith('centos'): |
||||
distribution = 'centos' |
||||
|
||||
fn = 'prerequisites/prerequisites_%s_python%i.sh' % ( |
||||
distribution, sys.version_info.major) |
||||
|
||||
if not force_yes: |
||||
try: |
||||
input_func = raw_input |
||||
except NameError: |
||||
input_func = input |
||||
|
||||
confirm = input_func('Execute: %s \n\ |
||||
proceed? [y/n]' % open(fn, 'r').read()) |
||||
if not confirm.lower() == 'y': |
||||
sys.exit(0) |
||||
|
||||
os.execl('/bin/sh', 'sh', fn) |
@ -1,10 +1,9 @@
|
||||
#!/bin/sh |
||||
#!/bin/bash |
||||
|
||||
sudo apt-get update -y |
||||
sudo apt-get install -y make git python3-dev python3-setuptools python3-pip python3-wheel |
||||
sudo apt-get install -y python3-numpy python3-numpy-dev python3-scipy python3-matplotlib |
||||
sudo apt-get install -y python3-pyqt5 python3-pyqt5.qtopengl python3-pyqt5.qtsvg |
||||
sudo apt-get install -y python3-pyqt5.qtwebengine || sudo apt-get install -y python3-pyqt5.qtwebkit |
||||
sudo apt-get install -y python3-yaml python3-progressbar python3-jinja2 |
||||
sudo apt-get install -y python3-requests |
||||
sudo apt-get install -y python3-coverage python3-nose |
||||
sudo apt-get install -y make git python3-dev python3-setuptools python3-pip \ |
||||
python3-wheel python3-numpy python3-numpy-dev python3-scipy \ |
||||
python3-matplotlib python3-pyqt5 python3-pyqt5.qtopengl \ |
||||
python3-pyqt5.qtsvg python3-pyqt5.qtwebkit python3-yaml \ |
||||
python3-progressbar python3-jinja2 python3-requests python3-coverage \ |
||||
python3-nose |
||||
|
@ -0,0 +1,13 @@
|
||||
m2-tar |
||||
m2-gzip |
||||
m2-patch |
||||
setuptools |
||||
wheel |
||||
numpy>=1.8 |
||||
scipy |
||||
pyyaml |
||||
matplotlib |
||||
progressbar2 |
||||
requests |
||||
nose |
||||
jinja2 |
Loading…
Reference in new issue