Skip to content

Commit

Permalink
installation: improve compatibility with legacy systems
Browse files Browse the repository at this point in the history
- downgrade requirements on pyqt, scipy, pyqtgraph, setuptools,
  setuptools_scm and gdal
- add a fallback to setup.py so that it is possible to install when
  setuptools lacks support for pep621
- update installation docs
  • Loading branch information
emolch committed May 10, 2023
1 parent 8fcf4bf commit 5a1fbba
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 20 deletions.
34 changes: 21 additions & 13 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,43 @@ Installation

Kite is written for `Python 3 <https://python.org>`_, the installation has been tested on Debian based distributions (e.g. Ubuntu and Mint), MacOSX, and `Anaconda <https://anaconda.org/pyrocko/kite>`_.

Debian / Ubuntu
---------------
System-wide installation on Debian / Ubuntu
-------------------------------------------

As a mandatory prerequisite you have to install Pyrocko, visit `Pyrocko installation instructions <https://pyrocko.org/docs/current/install/index.html>`_ for details.

.. code-block :: sh
:caption: Installation from source and ``apt-get``
sudo apt-get install python3-dev python3-pyqt5 python3-pyqt5 python3-pyqt5.qtopengl python3-scipy python3-numpy python3-pyqtgraph
# satisfy Kite's requirements with system packages
sudo apt-get install python3-dev python3-pyqt5 python3-pyqt5 python3-pyqt5.qtopengl python3-scipy python3-numpy python3-pyqtgraph python3-geojson python3-setuptools python3-setuptools-scm
git clone https://github.com/Turbo87/utm
cd utm
sudo python3 setup.py install
# install the utm package with pip (no system package available)
sudo pip3 install utm
# get Kite's source code with git
git clone https://github.com/pyrocko/kite
cd kite
sudo python3 setup.py install
# compile and install with pip, but disable automatic dependency resolution (--no-deps)
sudo pip3 install . --no-build-isolation --no-deps
PIP
---
An installation through ``pip`` requires the same prerequisites as above:
Installation with ``pip`` into virtual environment ``venv``
-----------------------------------------------------------

.. code-block :: sh
:caption: Installation through pip
:caption: Installation into venv
sudo pip3 install utm
sudo pip3 install git+https://github.com/pyrocko/kite
# create and activate venv
python3 -m venv venv
source venv/bin/activate
# get Kite's source code with git
git clone https://github.com/pyrocko/kite
cd kite
# install prerequisites with pip, compile and install Kite
pip install .
MacOS (Sierra, MacPorts)
Expand Down
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[build-system]
requires = [
"wheel",
"setuptools >= 61.0.0",
"setuptools >= 52.0.0",
"oldest-supported-numpy",
"setuptools_scm[toml]>=6.2",
"setuptools_scm[toml]>=5.0",
]
build-backend = "setuptools.build_meta"

Expand Down Expand Up @@ -34,9 +34,9 @@ classifiers = [
]
dependencies = [
"numpy>=1.17.3",
"scipy>=1.8.0",
"PyQt5>=5.15.7",
"pyqtgraph==0.12.4",
"scipy>=1.6.0",
"PyQt5>=5.15.0",
"pyqtgraph==0.11.0",
"pyrocko>=2022.06.10",
"utm>=0.7.0",
"geojson>=2.5.0",
Expand All @@ -48,7 +48,7 @@ GitHub = "https://github.com/pyrocko/kite"
Issues = "https://github.com/pyrocko/kite/issues"

[project.optional-dependencies]
gdal = ["gdal>=3.5.0"]
gdal = ["gdal>=3.2.0"]
development = ["flake8", "black", "pre-commit"]
tests = ["pytest"]

Expand Down
61 changes: 60 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#!/usr/bin/env python3
import os
import platform
import sys
import tempfile
from distutils.sysconfig import get_python_inc
from os.path import join as pjoin

from pkg_resources import parse_version
from setuptools import Extension, setup
from setuptools import __version__ as setuptools_version

have_pep621_support = parse_version(setuptools_version) >= parse_version("61.0.0")

try:
import numpy
Expand Down Expand Up @@ -117,6 +122,59 @@ def _have_openmp():
omp_lib = []


if not have_pep621_support:
try:
import toml
except ImportError:
sys.exit(
"""Your setuptools version is too old to support PEP621-compliant
installs. You may either update setuptools or, if this is not
possible, install the "toml" package (python3-toml package on
deb-based systems) to enable a fallback mechanism."""
)

tomldata = toml.load(
open(os.path.join(os.path.dirname(__file__), "pyproject.toml"))
)
metadata = dict(
use_scm_version=True,
package_data={"kite": ["spool/res/*", "talpa/res/*"]},
ext_package="kite",
)
metadata["setup_requires"] = tomldata["build-system"]["requires"]
metadata["packages"] = tomldata["tool"]["setuptools"]["packages"]

for k in ["classifiers", "description", "name", "keywords"]:
metadata[k] = tomldata["project"][k]

metadata["license"] = tomldata["project"]["license"]["text"]

metadata["python_requires"] = tomldata["project"]["requires-python"]
first_author = list(tomldata["project"]["authors"])[0]
metadata["author"] = ", ".join(
author["name"] for author in tomldata["project"]["authors"]
)
metadata["author_email"] = first_author["email"]

metadata["extras_require"] = {}
for k_opt in tomldata["project"]["optional-dependencies"]:
metadata["extras_require"][k_opt] = tomldata["project"][
"optional-dependencies"
][k_opt]

metadata["install_requires"] = tomldata["project"]["dependencies"]
metadata["entry_points"] = {
"console_scripts": [
"%s = %s" % (k, v) for (k, v) in tomldata["project"]["scripts"].items()
],
"gui_scripts": [
"%s = %s" % (k, v) for (k, v) in tomldata["project"]["gui-scripts"].items()
],
}
else:
metadata = {}


setup(
ext_modules=[
Extension(
Expand All @@ -135,5 +193,6 @@ def _have_openmp():
extra_link_args=omp_lib,
language="c",
),
]
],
**metadata,
)

0 comments on commit 5a1fbba

Please sign in to comment.