Skip to content

Commit 23b87d9

Browse files
authored
dep/doc: add tab completion via argcomplete (#1065)
+ add `argcomplete` to the dependency for tab completion capability. This package is light (only depends on pure Python), and available on pip and conda-forge (as noarch package). - requirements.txt: add argcomplete - setup.py: move argcomplete from optional to required + docs/installation.md: add "tab complete sub-commands" as another sub-section in Post-Installation Setup.
1 parent 6605a95 commit 23b87d9

File tree

3 files changed

+59
-12
lines changed

3 files changed

+59
-12
lines changed

docs/installation.md

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,25 @@ mamba install -c conda-forge mintpy
2121
<details>
2222
<p><summary>via docker</summary></p>
2323

24-
Docker allows one to run MintPy in a dedicated container, which is essentially an efficient virtual machine, and to be independent of platform OS. First, install <a href="https://docs.docker.com/install">docker</a> if you have not already done so. Then run the following to pull the latest stable released constainer image version from <a href="https://github.com/insarlab/MintPy/pkgs/container/mintpy">MintPy GitHub Container Registry</a> to your local machine:
24+
Docker allows one to run MintPy in a dedicated container, which is essentially an efficient virtual machine, and to be independent of the platform OS. First, install <a href="https://docs.docker.com/install">docker</a> if you have not already done so. Then run the following to pull the latest stable released container image version from <a href="https://github.com/insarlab/MintPy/pkgs/container/mintpy">MintPy GitHub Container Registry</a> to your local machine:
2525

2626
```bash
2727
docker pull ghcr.io/insarlab/mintpy:latest
2828
```
2929

30-
<p>Check <a href="./docker.md">docker.md</a> for more details on Docker container image usage, e.g. pulling development version and running in shell or Jupyter server.</p>
30+
<p>Check <a href="./docker.md">docker.md</a> for more details on Docker container image usage, e.g. pulling the development version and running in a shell or Jupyter server.</p>
3131
</details>
3232

3333
<details>
3434
<p><summary>via apt (Linux Debian)</summary></p>
3535

36-
MintPy is available in the main archive of the <a href="https://tracker.debian.org/pkg/mintpy">Debian</a> GNU/Linux OS. It can be installed by using your favourite package manager or running the following command:
36+
MintPy is available in the main archive of the <a href="https://tracker.debian.org/pkg/mintpy">Debian</a> GNU/Linux OS. It can be installed by using your favorite package manager or running the following command:
3737

3838
```bash
3939
apt install mintpy
4040
```
4141

42-
The same procedure, in priciple, can be used in <a href="https://ubuntu.com">Ubuntu</a> and all the other <a href="https://wiki.debian.org/Derivatives/Census">Debian derivatives</a>. Check the <a href="https://salsa.debian.org/debian-gis-team/mintpy/-/blob/master/debian/README.Debian">Debian GIS Project</a> page for more detailed usage.
42+
The same procedure, in principle, can be used in <a href="https://ubuntu.com">Ubuntu</a> and all the other <a href="https://wiki.debian.org/Derivatives/Census">Debian derivatives</a>. Check the <a href="https://salsa.debian.org/debian-gis-team/mintpy/-/blob/master/debian/README.Debian">Debian GIS Project</a> page for more detailed usage.
4343
</details>
4444
</p>
4545

@@ -69,7 +69,7 @@ git clone https://github.com/insarlab/MintPy.git
6969
Install <a href="https://docs.conda.io/en/latest/miniconda.html">miniconda</a> if you have not already done so. You may need to close and restart the shell for changes to take effect.
7070

7171
```bash
72-
# use wget or curl to download in command line or click from the web browser
72+
# use wget or curl to download in the command line or click from the web browser
7373
# for macOS, use Miniconda3-latest-MacOSX-x86_64.sh instead.
7474
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
7575
bash Miniconda3-latest-Linux-x86_64.sh -b -p ~/tools/miniconda3
@@ -105,7 +105,7 @@ conda activate mintpy
105105
<details open>
106106
<p><summary>via pip [recommended]</summary></p>
107107

108-
We recommend installing mintpy in the "editable" mode. This mode installs the package without copying files to your interpreter directory (e.g. the <code>site-packages</code> directory), thus, one could "edit" the source code and have changes take effect immediately without having to rebuild and reinstall.
108+
We recommend installing MintPy in the "editable" mode. This mode installs the package without copying files to your interpreter directory (e.g. the <code>site-packages</code> directory), thus, one could "edit" the source code and have changes take effect immediately without having to rebuild and reinstall.
109109

110110
```bash
111111
python -m pip install -e ~/tools/MintPy
@@ -163,13 +163,13 @@ export MANPATH=/opt/local/share/man:${MANPATH}
163163
# Finished adapting your PATH environment variable for use with MacPorts.
164164
```
165165

166-
Update the port tree with the following command. If your network prevent the use of rsync or svn via http of port tree, try <a href="https://trac.macports.org/wiki/howto/PortTreeTarball">Portfile Sync via a Snapshot Tarball</a>.
166+
Update the port tree with the following command. If your network prevents the use of rsync or svn via HTTP of the port tree, try <a href="https://trac.macports.org/wiki/howto/PortTreeTarball">Portfile Sync via a Snapshot Tarball</a>.
167167

168168
```
169169
sudo port selfupdate
170170
```
171171

172-
Install the dependencies by running:
172+
Install the dependencies by running the following:
173173

174174
```bash
175175
# install dependencies with macports
@@ -205,7 +205,7 @@ Same as the <a href="#21-install-on-linux">instruction for Linux</a>, except for
205205

206206
Set up an account for ERA5 to download weather re-analysis datasets for tropospheric delay correction as described in <a href="https://github.com/insarlab/pyaps#2-account-setup-for-era5">insarlab/PyAPS</a>.
207207

208-
<code>WEATHER_DIR</code>: Optionally, if you defined an environment variable named <code>WEATHER_DIR</code> to contain the path to a directory, MintPy will download the GAM files into the indicated directory. Also, MintPy will look for the GAM files in the directory before downloading a new one to prevent downloading multiple copies if you work with different dataset that cover the same date/time.
208+
<code>WEATHER_DIR</code>: Optionally, if you defined an environment variable named <code>WEATHER_DIR</code> to contain the path to a directory, MintPy will download the GAM files into the indicated directory. Also, MintPy will look for the GAM files in the directory before downloading a new one to prevent downloading multiple copies if you work with different datasets that cover the same date/time.
209209

210210
#### b. Dask for parallel processing ####
211211

@@ -214,7 +214,7 @@ We recommend setting the <code>temporary-directory</code> in your <a href="https
214214
```yaml
215215
temporary-directory: /tmp # Directory for local disk like /tmp, /scratch, or /local
216216

217-
# If you are sharing the same machine with others, use the following instead to avoid permission issues with others.
217+
# If you share the same machine with others, use the following instead to avoid permission issues.
218218
# temporary-directory: /tmp/{replace_this_with_your_user_name}
219219
```
220220

@@ -227,3 +227,50 @@ export VRT_SHARED_SOURCE=0 # do not share dataset while using GDAL V
227227
export HDF5_DISABLE_VERSION_CHECK=2 # supress the HDF5 version warning message (0 for abort; 1/2 for printout/suppress warning message)
228228
export HDF5_USE_FILE_LOCKING=FALSE # request that HDF5 file locks should NOT be used
229229
```
230+
231+
#### d. Tab complete sub-commands ####
232+
233+
We recommend activating the <a href="https://kislyuk.github.io/argcomplete/">tab completion</a> as below if you:
234+
1. Use bash or zsh shells
235+
2. On Linux or macOS
236+
3. Run MintPy in sub-commands style, e.g. <code>mintpy view</code> instead of <code>view.py</code>
237+
238+
```bash
239+
activate-global-python-argcomplete --user
240+
```
241+
242+
On macOS, there is a <a href="https://kislyuk.github.io/argcomplete/#global-completion">bash version compatibility</a> issue, which can be fixed as below. If you use the default zsh shell, no fix is needed.
243+
244+
<p>
245+
<details>
246+
<p><summary>Click to expand for more details</summary></p>
247+
248+
macOS ships with an older version of the bash shell, but <code>argcomplete</code> requires the newer version, which can be installed as below.
249+
250+
```bash
251+
# check the current bash version: argcomplete requires bash>=4.2
252+
echo $BASH_VERSION
253+
254+
# install via mamba
255+
mamba install bash
256+
257+
# add the path to /etc/shells file
258+
echo "${CONDA_PREFIX}/bin/bash" | sudo tee -a /etc/shells
259+
260+
# change your shell via chsh
261+
chsh -s "${CONDA_PREFIX}/bin/bash"
262+
263+
# check the current bash version
264+
echo $BASH_VERSION
265+
```
266+
267+
Then run <code>activate-global-python-argcomplete --user</code> again. You may need to add the following to your <code>~/.bash_profile</code> file.
268+
269+
```bash
270+
# bash completion
271+
if [ -f ~/.bash_completion ]; then
272+
. ~/.bash_completion
273+
fi
274+
```
275+
</details>
276+
</p>

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# docs/requirements4rtd.txt for readthedocs, which uses pip with limited memory usage
55
python>=3.6
66
pip
7+
argcomplete
78
cartopy
89
cvxopt
910
dask>=1.0

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
# dependencies
5353
python_requires=">=3.6",
5454
install_requires=[
55+
"argcomplete",
5556
"cartopy",
5657
"cvxopt",
5758
"dask>=1.0",
@@ -74,14 +75,12 @@
7475
"utm",
7576
],
7677
extras_require={
77-
"cli": ["argcomplete"],
7878
"extra": ["gdal"],
7979
"fractal": ["pyfftw"],
8080
"gbis": ["geoid"], # not available on pypi
8181
"isce": ["isce"], # not available on pypi
8282
"kite": ["kite"],
8383
"all": [
84-
"cli",
8584
"extra",
8685
"fractal",
8786
"gbis",

0 commit comments

Comments
 (0)