-
Notifications
You must be signed in to change notification settings - Fork 3
Fix path issues w/setup.py #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
### | ||
# Wikicurses configuration | ||
# This file will automatically be copied to the user configuration path on first run | ||
# User configuration stored in ~/.config/wikicurses/config (i.e. $HOME/.config/wikicurses/config) | ||
|
||
[general] | ||
default = Wikipedia_EN | ||
mouse = False | ||
hide_references = False | ||
|
||
[keymap] | ||
q = quit | ||
c = contents | ||
o = open | ||
h = back | ||
l = forward | ||
left = back | ||
right = forward | ||
|
||
[Wikipedia_EN] | ||
url = https://en.wikipedia.org/w/api.php | ||
|
||
[Wiktionary_EN] | ||
url = https://en.wiktionary.org/w/api.php | ||
|
||
# Additional Languages | ||
# [Wikipedia_DE] | ||
# url = https://de.wikipdia.org/w/api.php |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,42 @@ | ||
#!/usr/bin/env python3 | ||
#!/usr/bin/env python3 | ||
|
||
from setuptools import setup | ||
|
||
import os.path | ||
import sys | ||
import warnings | ||
|
||
# Changed paths to remove absolutes | ||
|
||
files_spec = [ | ||
('share/wikicurses', ['conf/wikicurses.conf.dist']), | ||
('share/zsh/site-functions', ['zsh/_wikicurses']), | ||
('share/man/man1', ['docs/wikicurses.1']), | ||
('share/man/man5', ['docs/wikicurses.conf.5']) | ||
] | ||
|
||
# Loop through and make the install relative to where we are now | ||
# Concept from github:ytdl-org/youtube-dl/setup.py | ||
root = os.path.dirname(os.path.abspath(__file__)) | ||
data_files = [] | ||
for dirname, files in files_spec: | ||
resfiles = [] | ||
for fn in files: | ||
if not os.path.exists(fn): | ||
warnings.warn('Skipping file %s since it is not present. Type make to build all automatically generated files.' % fn) | ||
else: | ||
resfiles.append(fn) | ||
data_files.append((dirname, resfiles)) | ||
|
||
setup(name='Wikicurses', | ||
version='1.4', | ||
version='1.4.1', | ||
description='A simple curses interface for accessing Wikipedia.', | ||
author='Ian D. Scott', | ||
author_email='[email protected]', | ||
license = "MIT", | ||
url='http://github.com/ids1024/wikicurses/', | ||
packages = ['wikicurses'], | ||
data_files=[ | ||
('/etc', ['wikicurses.conf']), | ||
('/usr/share/man/man1', ['wikicurses.1']), | ||
('/usr/share/man/man5', ['wikicurses.conf.5']), | ||
('/usr/share/zsh/site-functions', ['_wikicurses']) | ||
], | ||
data_files=data_files, | ||
entry_points={'console_scripts': ['wikicurses = wikicurses.main:main']}, | ||
install_requires = ['beautifulsoup4', 'lxml', 'urwid'], | ||
classifiers=[ | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
import sys | ||
import os | ||
import json | ||
import collections | ||
import configparser | ||
import shutil | ||
from wikicurses import formats | ||
from urllib.parse import urlparse | ||
|
||
default_configdir = os.environ['HOME'] + '/.config' | ||
# TODO: This may cause issues with python 2.7; however, as of 01OCT2019, it is nearing sunset | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Running Wikicurses in Python 2 already fails immediately (syntax errors from (I personally don't see any reason now to support Python 2 in an application; maybe in a library.) |
||
default_configdir = os.path.expanduser('~') + '/.config' | ||
configpath = os.environ.get( | ||
'XDG_CONFIG_HOME', default_configdir) + '/wikicurses' | ||
|
||
configfile = os.path.join(configpath, "config") | ||
|
||
os.makedirs(configpath, exist_ok=True) | ||
|
||
if not os.path.isfile(configfile): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neat solution! One thing I'm not so sure about: I think the current behavior using a global configuration file instead of copying like this might be better for disro packaging (rather than installing with But then, maybe it would just complicate and confuse things too much to provide a mechanism for either copying or not copying... I guess if we want this complexity, it might be best achieved by also checking for |
||
# Copy the default config file | ||
current_run_path = os.path.dirname(os.path.realpath(sys.argv[0])) | ||
default_config = os.path.normpath(os.path.join(current_run_path, "../share/wikicurses/wikicurses.conf.dist")) | ||
shutil.copyfile(default_config, configfile) | ||
|
||
conf = configparser.ConfigParser() | ||
conf.read(['/etc/wikicurses.conf', configpath + '/config']) | ||
conf.read(configpath + '/config') | ||
|
||
try: | ||
mouse = conf.getboolean('general', 'mouse') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. Unfortunately
man
doesn't seem to check~/.local/share/main
by default, at least on Arch Linux. But I presume there's no better solution for user-local installs...