Skip to content

Commit 174bc17

Browse files
committed
Adding pypi packaging
1 parent 492fae9 commit 174bc17

2 files changed

Lines changed: 194 additions & 1 deletion

File tree

setup.py

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
"""A setuptools based setup module.
2+
See:
3+
https://packaging.python.org/en/latest/distributing.html
4+
https://github.com/pypa/sampleproject
5+
"""
6+
7+
# Always prefer setuptools over distutils
8+
from setuptools import setup, find_packages
9+
from os import path
10+
# io.open is needed for projects that support Python 2.7
11+
# It ensures open() defaults to text mode with universal newlines,
12+
# and accepts an argument to specify the text encoding
13+
# Python 3 only projects can skip this import
14+
from io import open
15+
16+
here = path.abspath(path.dirname(__file__))
17+
18+
# Get the long description from the README file
19+
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
20+
long_description = f.read()
21+
22+
# Arguments marked as "Required" below must be included for upload to PyPI.
23+
# Fields marked as "Optional" may be commented out.
24+
25+
setup(
26+
# This is the name of your project. The first time you publish this
27+
# package, this name will be registered for you. It will determine how
28+
# users can install this project, e.g.:
29+
#
30+
# $ pip install sampleproject
31+
#
32+
# And where it will live on PyPI: https://pypi.org/project/sampleproject/
33+
#
34+
# There are some restrictions on what makes a valid project name
35+
# specification here:
36+
# https://packaging.python.org/specifications/core-metadata/#name
37+
name='stashcp', # Required
38+
39+
# Versions should comply with PEP 440:
40+
# https://www.python.org/dev/peps/pep-0440/
41+
#
42+
# For a discussion on single-sourcing the version across setup.py and the
43+
# project code, see
44+
# https://packaging.python.org/en/latest/single_source_version.html
45+
version='5.1.2', # Required
46+
47+
# This is a one-line description or tagline of what your project does. This
48+
# corresponds to the "Summary" metadata field:
49+
# https://packaging.python.org/specifications/core-metadata/#summary
50+
description='StashCache Copy', # Optional
51+
52+
# This is an optional longer description of your project that represents
53+
# the body of text which users will see when they visit PyPI.
54+
#
55+
# Often, this is the same as your README, so you can just read it in from
56+
# that file directly (as we have already done above)
57+
#
58+
# This field corresponds to the "Description" metadata field:
59+
# https://packaging.python.org/specifications/core-metadata/#description-optional
60+
long_description=long_description, # Optional
61+
62+
# Denotes that our long_description is in Markdown; valid values are
63+
# text/plain, text/x-rst, and text/markdown
64+
#
65+
# Optional if long_description is written in reStructuredText (rst) but
66+
# required for plain-text or Markdown; if unspecified, "applications should
67+
# attempt to render [the long_description] as text/x-rst; charset=UTF-8 and
68+
# fall back to text/plain if it is not valid rst" (see link below)
69+
#
70+
# This field corresponds to the "Description-Content-Type" metadata field:
71+
# https://packaging.python.org/specifications/core-metadata/#description-content-type-optional
72+
long_description_content_type='text/markdown', # Optional (see note above)
73+
74+
# This should be a valid link to your project's main homepage.
75+
#
76+
# This field corresponds to the "Home-Page" metadata field:
77+
# https://packaging.python.org/specifications/core-metadata/#home-page-optional
78+
url='https://github.com/opensciencegrid/StashCache', # Optional
79+
80+
# This should be your name or the name of the organization which owns the
81+
# project.
82+
author='Open Science Grid', # Optional
83+
84+
# This should be a valid email address corresponding to the author listed
85+
# above.
86+
author_email='stashcache@opensciencegrid.org', # Optional
87+
88+
# Classifiers help users find your project by categorizing it.
89+
#
90+
# For a list of valid classifiers, see https://pypi.org/classifiers/
91+
classifiers=[ # Optional
92+
# How mature is this project? Common values are
93+
# 3 - Alpha
94+
# 4 - Beta
95+
# 5 - Production/Stable
96+
'Development Status :: 5 - Production/Stable',
97+
98+
# Indicate who your project is intended for
99+
'Intended Audience :: Science/Research',
100+
'Topic :: Internet',
101+
102+
# Pick your license as you wish
103+
'License :: OSI Approved :: Apache Software License',
104+
105+
# Specify the Python versions you support here. In particular, ensure
106+
# that you indicate whether you support Python 2, Python 3 or both.
107+
'Programming Language :: Python :: 2',
108+
'Programming Language :: Python :: 2.7',
109+
],
110+
111+
# This field adds keywords for your project which will appear on the
112+
# project page. What does your project relate to?
113+
#
114+
# Note that this is a string of words separated by whitespace, not a list.
115+
keywords='stashcache transfer', # Optional
116+
117+
# You can just specify package directories manually here if your project is
118+
# simple. Or you can use find_packages().
119+
#
120+
# Alternatively, if you just want to distribute a single Python file, use
121+
# the `py_modules` argument instead as follows, which will expect a file
122+
# called `my_module.py` to exist:
123+
#
124+
py_modules=["stashcp"],
125+
126+
#packages=find_packages(exclude=['contrib', 'docs', 'tests']), # Required
127+
128+
# This field lists other packages that your project depends on to run.
129+
# Any package you put here will be installed by pip when your project is
130+
# installed, so they must be valid existing projects.
131+
#
132+
# For an analysis of "install_requires" vs pip's requirements files see:
133+
# https://packaging.python.org/en/latest/requirements.html
134+
#install_requires=['peppercorn'], # Optional
135+
136+
# List additional groups of dependencies here (e.g. development
137+
# dependencies). Users will be able to install these using the "extras"
138+
# syntax, for example:
139+
#
140+
# $ pip install sampleproject[dev]
141+
#
142+
# Similar to `install_requires` above, these must be valid existing
143+
# projects.
144+
#extras_require={ # Optional
145+
# 'dev': ['check-manifest'],
146+
# 'test': ['coverage'],
147+
#},
148+
149+
# If there are data files included in your packages that need to be
150+
# installed, specify them here.
151+
#
152+
# If using Python 2.6 or earlier, then these have to be included in
153+
# MANIFEST.in as well.
154+
#package_data={ # Optional
155+
# '': ['bin/caches.json'],
156+
#},
157+
158+
# Although 'package_data' is the preferred approach, in some case you may
159+
# need to place data files outside of your packages. See:
160+
# http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files
161+
#
162+
# In this case, 'data_file' will be installed into '<sys.prefix>/my_data'
163+
data_files=[('', ['bin/caches.json'])], # Optional
164+
165+
# To provide executable scripts, use entry points in preference to the
166+
# "scripts" keyword. Entry points provide cross-platform support and allow
167+
# `pip` to create the appropriate form of executable for the target
168+
# platform.
169+
#
170+
# For example, the following would provide a command called `sample` which
171+
# executes the function `main` from this package when invoked:
172+
entry_points={ # Optional
173+
'console_scripts': [
174+
'stashcp=stashcp:main',
175+
],
176+
},
177+
178+
# List additional URLs that are relevant to your project as a dict.
179+
#
180+
# This field corresponds to the "Project-URL" metadata fields:
181+
# https://packaging.python.org/specifications/core-metadata/#project-url-multiple-use
182+
#
183+
# Examples listed include a pattern for specifying where the package tracks
184+
# issues, where the source is hosted, where to say thanks to the package
185+
# maintainers, and where to support the project financially. The key is
186+
# what's used to render the link text on PyPI.
187+
project_urls={ # Optional
188+
'Bug Reports': 'https://github.com/opensciencegrid/StashCache/issues',
189+
'Source': 'https://github.com/opensciencegrid/StashCache',
190+
},
191+
)

bin/stashcp renamed to stashcp.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import socket
1313
import random
1414
import shutil
15+
from pkg_resources import resource_string
1516

1617
import logging
1718
from urlparse import urlparse
@@ -499,7 +500,8 @@ def get_best_stashcache():
499500
cache_files = [ caches_json_location ]
500501
else:
501502
prefix = os.environ.get("OSG_LOCATION", "")
502-
cache_files = [os.path.join(os.path.dirname(os.path.realpath(__file__)), "caches.json"),
503+
cache_files = [resource_string(__name__, 'caches.json'),
504+
os.path.join(os.path.dirname(os.path.realpath(__file__)), "caches.json"),
503505
os.path.join(prefix, "/etc/stashcache/caches.json"),
504506
os.path.join(prefix, "/usr/share/stashcache/caches.json")]
505507

0 commit comments

Comments
 (0)