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

Commit 342d088

Browse files
committed
Use pkg_resources to find the config file path,
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
1 parent f30063c commit 342d088

3 files changed

Lines changed: 4 additions & 5 deletions

File tree

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include README LICENSE requirements.txt
1+
include README.rst requirements.txt data/config.ini

bwscanner/configutil.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os.path
22
from shutil import copyfile
33
from ConfigParser import SafeConfigParser
4+
from pkg_resources import resource_string
45

56
from bwscanner.logger import log
67

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

2324
def copy_config(cfg_path, cfg_default_path=None):
2425
if cfg_default_path is None:
25-
cfg_default_path = os.path.join(os.path.dirname(os.path.dirname(
26-
os.path.abspath(__file__))), 'data', 'config.ini')
26+
cfg_default_path = resource_string(__name__, 'data/config.ini')
2727
log.debug("cfg_default_path %s" % cfg_default_path)
2828
copyfile(cfg_default_path, cfg_path)

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
url=__url__,
2323
license=__license__,
2424
packages=find_packages(),
25-
# data_files = [('path', ['filename'])]
26-
data_files=[],
25+
include_package_data=True,
2726
entry_points={
2827
"console_scripts": [
2928
'bwscan = bwscanner.scanner:cli',

0 commit comments

Comments
 (0)