mirror of https://github.com/cheat/cheat.git
Installation issues
Resolves the following: - #351 (use of `sudo` when installing) - #420 (failure to install on Windows) - #431 (failure to install on MacOS) Application now relies on `appdirs` module to identify the appropriate locations for storing configuration and data, both during installation and runtime.
This commit is contained in:
parent
5487314676
commit
fdddedb8bd
|
@ -50,9 +50,12 @@ Installing
|
||||||
It is recommended to install `cheat` with `pip`:
|
It is recommended to install `cheat` with `pip`:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
[sudo] pip install cheat
|
pip install cheat --user
|
||||||
```
|
```
|
||||||
|
|
||||||
|
(You must ensure that the `Location` identified by `pip show cheat` exists on
|
||||||
|
your `PATH`.)
|
||||||
|
|
||||||
[Other installation methods are available][installing].
|
[Other installation methods are available][installing].
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,13 @@ Vagrant.configure("2") do |config|
|
||||||
vb.memory = "512"
|
vb.memory = "512"
|
||||||
end
|
end
|
||||||
|
|
||||||
config.vm.provision "shell", inline: <<-SHELL
|
config.vm.provision "shell", privileged: false, inline: <<-SHELL
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y python-pip
|
sudo apt-get install -y python-pip
|
||||||
su vagrant && sudo -H pip install docopt pygments termcolor flake8
|
sudo -H pip install flake8
|
||||||
cd /vagrant && sudo python setup.py install
|
pip install --user docopt pygments termcolor
|
||||||
|
cd /vagrant/ && python setup.py install --user
|
||||||
|
echo 'export PATH=$PATH:/home/vagrant/.local/bin' >> /home/vagrant/.bashrc
|
||||||
SHELL
|
SHELL
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from cheat.utils import Utils
|
from cheat.utils import Utils
|
||||||
|
import appdirs
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -9,10 +10,12 @@ class Configuration:
|
||||||
# compute the location of the config files
|
# compute the location of the config files
|
||||||
config_file_path_global = self._select([
|
config_file_path_global = self._select([
|
||||||
os.environ.get('CHEAT_GLOBAL_CONF_PATH'),
|
os.environ.get('CHEAT_GLOBAL_CONF_PATH'),
|
||||||
|
appdirs.site_config_dir('cheat', 'cheat'),
|
||||||
'/etc/cheat',
|
'/etc/cheat',
|
||||||
])
|
])
|
||||||
config_file_path_local = self._select([
|
config_file_path_local = self._select([
|
||||||
os.environ.get('CHEAT_LOCAL_CONF_PATH'),
|
os.environ.get('CHEAT_LOCAL_CONF_PATH'),
|
||||||
|
appdirs.user_config_dir('cheat', 'cheat'),
|
||||||
os.path.expanduser('~/.config/cheat/cheat'),
|
os.path.expanduser('~/.config/cheat/cheat'),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@ -81,6 +84,8 @@ class Configuration:
|
||||||
os.environ.get('CHEAT_PATH'),
|
os.environ.get('CHEAT_PATH'),
|
||||||
os.environ.get('CHEATPATH'),
|
os.environ.get('CHEATPATH'),
|
||||||
config.get('CHEAT_PATH'),
|
config.get('CHEAT_PATH'),
|
||||||
|
appdirs.user_data_dir('cheat', 'cheat'),
|
||||||
|
appdirs.site_data_dir('cheat', 'cheat'),
|
||||||
'/usr/share/cheat',
|
'/usr/share/cheat',
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
24
setup.py
24
setup.py
|
@ -1,10 +1,23 @@
|
||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# determine the directory in which to install system-wide cheatsheets
|
# install appdirs if it cannot be imported
|
||||||
# KLUDGE: It would be better to read `/usr/share/cheat` from `config/cheat`
|
try:
|
||||||
# rather than hard-coding it here
|
import appdirs
|
||||||
cheat_path = os.environ.get('CHEAT_PATH') or '/usr/share/cheat'
|
except ImportError:
|
||||||
|
import pip
|
||||||
|
pip.main(['install', 'appdirs'])
|
||||||
|
import appdirs
|
||||||
|
|
||||||
|
# determine the path in which to install the cheatsheets included with the
|
||||||
|
# package
|
||||||
|
cheat_path = os.environ.get('CHEAT_PATH') or \
|
||||||
|
appdirs.user_data_dir('cheat', 'cheat')
|
||||||
|
|
||||||
|
# determine the path in which to install the config file
|
||||||
|
config_path = os.environ.get('CHEAT_GLOBAL_CONF_PATH') or \
|
||||||
|
os.environ.get('CHEAT_LOCAL_CONF_PATH') or \
|
||||||
|
appdirs.user_config_dir('cheat', 'cheat')
|
||||||
|
|
||||||
# aggregate the systme-wide cheatsheets
|
# aggregate the systme-wide cheatsheets
|
||||||
cheat_files = []
|
cheat_files = []
|
||||||
|
@ -29,12 +42,13 @@ setup(
|
||||||
],
|
],
|
||||||
scripts=['bin/cheat'],
|
scripts=['bin/cheat'],
|
||||||
install_requires=[
|
install_requires=[
|
||||||
|
'appdirs >= 1.4.3',
|
||||||
'docopt >= 0.6.1',
|
'docopt >= 0.6.1',
|
||||||
'pygments >= 1.6.0',
|
'pygments >= 1.6.0',
|
||||||
'termcolor >= 1.1.0',
|
'termcolor >= 1.1.0',
|
||||||
],
|
],
|
||||||
data_files=[
|
data_files=[
|
||||||
(cheat_path, cheat_files),
|
(cheat_path, cheat_files),
|
||||||
('/etc', ['config/cheat']),
|
(config_path, ['config/cheat']),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue