Skip to content

Commit 0ac717f

Browse files
author
Diego Davila
committed
making stashcp a packge not a module and changing the order for looking the caches.json file (software-3799)
1 parent df49515 commit 0ac717f

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

setup.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
# For a discussion on single-sourcing the version across setup.py and the
4343
# project code, see
4444
# https://packaging.python.org/en/latest/single_source_version.html
45-
version='5.4.1', # Required
45+
version='5.5.0', # Required
4646

4747
# This is a one-line description or tagline of what your project does. This
4848
# corresponds to the "Summary" metadata field:
@@ -121,7 +121,8 @@
121121
# the `py_modules` argument instead as follows, which will expect a file
122122
# called `my_module.py` to exist:
123123
#
124-
py_modules=["stashcp"],
124+
#py_modules=["stashcp"],
125+
packages=["stashcp"],
125126

126127
#packages=find_packages(exclude=['contrib', 'docs', 'tests']), # Required
127128

@@ -151,6 +152,7 @@
151152
#
152153
# If using Python 2.6 or earlier, then these have to be included in
153154
# MANIFEST.in as well.
155+
package_data={'stashcp': ['caches.json'],},
154156
#package_data={ # Optional
155157
# '': ['bin/caches.json'],
156158
#},
@@ -160,7 +162,7 @@
160162
# http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files
161163
#
162164
# In this case, 'data_file' will be installed into '<sys.prefix>/my_data'
163-
data_files=[('', ['caches.json'])], # Optional
165+
data_files=[('share/stashcache/', ['stashcp/caches.json'])],
164166

165167
# To provide executable scripts, use entry points in preference to the
166168
# "scripts" keyword. Entry points provide cross-platform support and allow

stashcp.py renamed to stashcp/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
from urlparse import urlparse
1616

1717
try:
18-
from pkg_resources import resource_string
18+
from pkg_resources import resource_filename
1919
except ImportError as e:
20-
resource_string = None
20+
resource_filename = None
2121

2222

2323
import logging
2424
from urlparse import urlparse
2525

2626
# Version information for user-agent
27-
VERSION = "5.4.1"
27+
VERSION = "5.5.0"
2828

2929
main_redirector = "root://redirector.osgstorage.org"
3030
stash_origin = "root://stash.osgconnect.net"
@@ -554,12 +554,12 @@ def get_best_stashcache():
554554
cache_files = [ caches_json_location ]
555555
else:
556556
prefix = os.environ.get("OSG_LOCATION", "/")
557-
cache_files = [os.path.join(os.path.dirname(os.path.realpath(__file__)), "caches.json"),
558-
os.path.join(prefix, "etc/stashcache/caches.json"),
559-
os.path.join(prefix, "usr/share/stashcache/caches.json")]
560-
if resource_string:
557+
cache_files = [os.path.join(prefix, "etc/stashcache/caches.json"),
558+
os.path.join(prefix, "usr/share/stashcache/caches.json"),
559+
os.path.join(prefix, "usr/local/share/stashcache/caches.json")]
560+
if resource_filename:
561561
try:
562-
cache_files.insert(0, resource_string(__name__, 'caches.json'))
562+
cache_files.append(resource_filename(__name__, 'caches.json'))
563563
except IOError as ioe:
564564
logging.debug("Unable to retrieve caches.json using resource string, trying other locations")
565565

File renamed without changes.

0 commit comments

Comments
 (0)