Skip to content
This repository has been archived by the owner on Mar 2, 2022. It is now read-only.

Commit

Permalink
Use pkg_resources to find the config file path,
Browse files Browse the repository at this point in the history
instead of using __file__ as it would fail when packed in a zip.
Include the config file in the package adding it to MANIFEST.in
  • Loading branch information
juga0 committed Mar 22, 2018
1 parent f30063c commit 342d088
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include README LICENSE requirements.txt
include README.rst requirements.txt data/config.ini
4 changes: 2 additions & 2 deletions bwscanner/configutil.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os.path
from shutil import copyfile
from ConfigParser import SafeConfigParser
from pkg_resources import resource_string

from bwscanner.logger import log

Expand All @@ -22,7 +23,6 @@ def config_exists(cfg_path):

def copy_config(cfg_path, cfg_default_path=None):
if cfg_default_path is None:
cfg_default_path = os.path.join(os.path.dirname(os.path.dirname(
os.path.abspath(__file__))), 'data', 'config.ini')
cfg_default_path = resource_string(__name__, 'data/config.ini')
log.debug("cfg_default_path %s" % cfg_default_path)
copyfile(cfg_default_path, cfg_path)
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
url=__url__,
license=__license__,
packages=find_packages(),
# data_files = [('path', ['filename'])]
data_files=[],
include_package_data=True,
entry_points={
"console_scripts": [
'bwscan = bwscanner.scanner:cli',
Expand Down

0 comments on commit 342d088

Please sign in to comment.