Skip to content

Commit ff35fe4

Browse files
authored
Merge pull request #106 from ddavila0/master
making stashcp a package not a module (SOFTWARE-3799)
2 parents df49515 + 992f9ad commit ff35fe4

4 files changed

Lines changed: 27 additions & 20 deletions

File tree

bin/stashcp2/tests/test_inside_docker.sh

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ rpm -Uvh https://repo.opensciencegrid.org/osg/3.3/osg-3.3-el${OS_VERSION}-releas
1717

1818
yum -y install osg-oasis
1919

20+
yum -y install python-pip
21+
2022
echo "user_allow_other" >> /etc/fuse.conf
2123

2224
echo "CVMFS_HTTP_PROXY=DIRECT" >> /etc/cvmfs/default.local
@@ -37,27 +39,30 @@ module load xrootd
3739
# For now, disable pylint failures
3840
#pylint /StashCache/bin/stashcp || /bin/true
3941

42+
# Install stashcp
43+
pip install StashCache/
44+
4045
# Copy in the .job.ad file:
4146
cp /StashCache/bin/stashcp2/tests/job.ad ./.job.ad
4247

4348
# Test against a file that is known to not exist
4449
set +e
45-
/StashCache/stashcp.py --cache=$XRD_CACHE /blah/does/not/exist ./
50+
stashcp --cache=$XRD_CACHE /blah/does/not/exist ./
4651
if [ $? -eq 0 ]; then
4752
echo "Failed to exit with non-zero exit status when it should have"
4853
exit 1
4954
fi
5055
set -e
5156

5257
# Try copying with no forward slash
53-
/StashCache/stashcp.py --cache=$XRD_CACHE user/dweitzel/public/blast/queries/query1 ./
58+
stashcp --cache=$XRD_CACHE user/dweitzel/public/blast/queries/query1 ./
5459

5560
result=`md5sum query1 | awk '{print $1;}'`
5661

5762
rm query1
5863

5964
# Try copying with different destintion filename
60-
/StashCache/stashcp.py --cache=$XRD_CACHE -d /user/dweitzel/public/blast/queries/query1 query.test
65+
stashcp --cache=$XRD_CACHE -d /user/dweitzel/public/blast/queries/query1 query.test
6166

6267
result=`md5sum query.test | awk '{print $1;}'`
6368

@@ -68,7 +73,7 @@ fi
6873
rm -f query.test
6974

7075
# Perform tests
71-
/StashCache/stashcp.py --cache=$XRD_CACHE -d /user/dweitzel/public/blast/queries/query1 ./
76+
stashcp --cache=$XRD_CACHE -d /user/dweitzel/public/blast/queries/query1 ./
7277

7378
result=`md5sum query1 | awk '{print $1;}'`
7479

@@ -78,7 +83,7 @@ fi
7883
rm -f query.test
7984

8085
# Perform methods test
81-
/StashCache/stashcp.py --cache=$XRD_CACHE --method=cvmfs,xrootd -d /user/dweitzel/public/blast/queries/query1 ./
86+
stashcp --cache=$XRD_CACHE --method=cvmfs,xrootd -d /user/dweitzel/public/blast/queries/query1 ./
8287

8388
result=`md5sum query1 | awk '{print $1;}'`
8489

@@ -88,7 +93,7 @@ fi
8893
rm -f query.test
8994

9095
# Perform methods test
91-
/StashCache/stashcp.py --cache=$XRD_CACHE --method=xrootd -d /user/dweitzel/public/blast/queries/query1 ./
96+
stashcp --cache=$XRD_CACHE --method=xrootd -d /user/dweitzel/public/blast/queries/query1 ./
9297

9398
result=`md5sum query1 | awk '{print $1;}'`
9499

@@ -98,7 +103,7 @@ fi
98103
rm -f query.test
99104

100105
# Perform methods test
101-
/StashCache/stashcp.py --cache=$XRD_CACHE --method=http,xrootd -d /user/dweitzel/public/blast/queries/query1 ./
106+
stashcp --cache=$XRD_CACHE --method=http,xrootd -d /user/dweitzel/public/blast/queries/query1 ./
102107

103108
result=`md5sum query1 | awk '{print $1;}'`
104109

@@ -108,7 +113,7 @@ fi
108113
rm -f query.test
109114

110115
# Scheme test
111-
/StashCache/stashcp.py --cache=$XRD_CACHE --method=http,xrootd -d stash:///user/dweitzel/public/blast/queries/query1 file:///tmp
116+
stashcp --cache=$XRD_CACHE --method=http,xrootd -d stash:///user/dweitzel/public/blast/queries/query1 file:///tmp
112117

113118
result=`md5sum /tmp/query1 | awk '{print $1;}'`
114119

@@ -117,7 +122,7 @@ if [ "$result" != "12bdb9a96cd5e8ca469b727a81593201" ]; then
117122
fi
118123
rm -f query.test
119124

120-
/StashCache/stashcp.py --cache=$XRD_CACHE -d -r /user/dweitzel/public/blast/queries ./
125+
stashcp --cache=$XRD_CACHE -d -r /user/dweitzel/public/blast/queries ./
121126
ls -lah
122127

123128
rm -rf queries

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)