Skip to content

Commit

Permalink
Fix all pathing issues by using pkg_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
nickjj committed Sep 11, 2014
1 parent 356406c commit 12bce5d
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v0.4.4

- Fix the missing readme template and VERSION file
- Trolled hard by how package files work but I think we're good now

## v0.4.3

- Probably fixed the colors file not being included properly
Expand Down
1 change: 1 addition & 0 deletions RELEASES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Version Release date
---------------------------
v0.4.4 09/11/2014
v0.4.3 09/11/2014
v0.4.2 09/11/2014
v0.4.1 09/11/2014
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.3
0.4.4
8 changes: 3 additions & 5 deletions ansigenome/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
GIT_AUTHOR = utils.capture_shell("git config user.name")[0][:-1]
GIT_EMAIL = utils.capture_shell("git config user.email")[0][:-1]

MODULE_DIR = os.path.join(os.path.dirname(__file__), os.path.pardir)
PACKAGE_RESOURCE = pkg_resources.resource_filename(__name__, "data")

VALID_ACTIONS = ("config", "scan", "gendoc", "genmeta",
"export", "init", "run")
Expand Down Expand Up @@ -96,7 +96,7 @@
ANSIBLE_FOLDERS = ("defaults", "handlers", "meta",
"tasks", "templates", "tests", "vars")

README_TEMPLATE_PATH = os.path.join(MODULE_DIR,
README_TEMPLATE_PATH = os.path.join(PACKAGE_RESOURCE,
"templates", "README.md.j2")

DEFAULT_META_FILE = """---
Expand Down Expand Up @@ -175,6 +175,4 @@

TEST_PATH = os.path.join(os.path.sep, "tmp", "ansigenome")

X11_COLORS = utils.file_to_list(pkg_resources.resource_filename(__name__,
\
os.path.join("data", "colors")))
X11_COLORS = utils.file_to_list(os.path.join(PACKAGE_RESOURCE, "colors"))
File renamed without changes.
3 changes: 2 additions & 1 deletion bin/ansigenome
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def build_option_parser(action):
epilog = ui.epilogue(os.path.basename(sys.argv[0]))

args = " ".join(sys.argv)
version = utils.get_version(os.path.join(c.MODULE_DIR, "VERSION"))
version = utils.get_version(os.path.join(c.PACKAGE_RESOURCE,
os.pardir, os.pardir, "VERSION"))

OptionParser.format_epilog = lambda self, formatter: self.epilog
parser = OptionParser(usage=usage, epilog=epilog,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
packages=["ansigenome"],
package_data={"ansigenome": ["data/*"]},
scripts=["bin/ansigenome"],
data_files=[])
data_files=["VERSION"])

0 comments on commit 12bce5d

Please sign in to comment.