-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·118 lines (104 loc) · 4.73 KB
/
setup.py
File metadata and controls
executable file
·118 lines (104 loc) · 4.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/env python3
#
# Copyright (C) 2013-2016 DNAnexus, Inc.
#
# This file is part of dx-toolkit (DNAnexus platform client libraries).
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy
# of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import glob
import os
import platform
import re
from setuptools import setup, find_packages
import sys
# Pypi is the repository for python packages.
# It requires that version numbers look like this: X.Y.Z,
# where X, Y, and Z are numbers. It is more complicated than that, but that's
# the main idea.
#
# Clean up the version number. It starts like this:
# '0.265.0-77-g059d243f'
# and we need 0.265.0
def make_valid_pypi_version(raw):
m = re.match(r'(\d+)\.(\d+)\.(\d+)', raw)
return m.group(0)
# Don't import, but use exec.
# Importing would trigger interpretation of the dxpy entry point, which can fail if deps are not installed.
#
# The result of this trickery is a variable called "version", initialized
# to the current version of dxpy.
with open(os.path.join(os.path.dirname(__file__), 'dxpy', 'toolkit_version.py')) as fh:
exec(compile(fh.read(), 'toolkit_version.py', 'exec'))
version = make_valid_pypi_version(version)
# The readme file is used as the long-description of the package.
# It will show up in the pypi site.
with open(os.path.join(os.path.dirname(__file__), "Readme.md"), "r") as fh:
readme_content = fh.read()
# Grab all the scripts from dxpy/scripts and install them without their .py extension.
# Replace underscores with dashes.
# See Readme.md for details.
scripts = []
for module in os.listdir(os.path.join(os.path.dirname(__file__), 'dxpy', 'scripts')):
if module == '__init__.py' or module[-3:] != '.py':
continue
module = module[:-3]
script = module.replace('_', '-')
scripts.append("{s} = dxpy.scripts.{m}:main".format(s=script, m=module))
dependencies = [line.rstrip() for line in open(os.path.join(os.path.dirname(__file__), "requirements.txt"))]
test_dependencies = [line.rstrip() for line in open(os.path.join(os.path.dirname(__file__), "requirements_test.txt"))]
if 'DNANEXUS_INSTALL_PYTHON_TEST_DEPS' in os.environ:
dependencies.extend(test_dependencies)
template_files = []
for directory, subdirectories, files in os.walk("dxpy/templating/templates"):
directory = directory[len("dxpy/templating/"):]
template_files.extend([os.path.join(directory, _file) for _file in files])
nextflow_files = os.listdir(os.path.join(os.path.dirname(__file__), 'dxpy', 'nextflow'))
nextflow_records = list(filter(lambda file: file[-5:] == ".json", nextflow_files))
dx_extract_files = os.listdir(os.path.join(os.path.dirname(__file__), 'dxpy', 'dx_extract_utils'))
dx_extract_records = list(filter(lambda file: file[-5:] == ".json", dx_extract_files))
setup(
name='dxpy',
version=version,
description='DNAnexus Platform API bindings for Python',
long_description=readme_content,
long_description_content_type="text/markdown",
author='Aleksandra Zalcman, Andrey Kislyuk, Anurag Biyani, Geet Duggal, Katherine Lai, Kurt Jensen, Marek Hrvol, Ohad Rodeh, Phil Sung',
author_email='support@dnanexus.com',
url='https://github.com/dnanexus/dx-toolkit',
zip_safe=False,
license='Apache Software License',
packages = find_packages(exclude=['test']),
package_data={'dxpy.templating': template_files, 'dxpy.nextflow': nextflow_records, 'dxpy.dx_extract_utils': dx_extract_records},
scripts = glob.glob(os.path.join(os.path.dirname(__file__), 'scripts', 'dx*')),
entry_points = {
"console_scripts": scripts,
},
python_requires = '>=3.8',
install_requires = dependencies,
extras_require={
'pandas': ["pandas==2.0.3; python_version == '3.8'", "pandas==2.2.3; python_version >= '3.9'", "numpy<2.0.0"],
'xattr': ["xattr==0.10.1; sys_platform == 'linux2' or sys_platform == 'linux'"]
},
tests_require = test_dependencies,
test_suite = "test",
classifiers=[
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: MacOS :: MacOS X',
'Operating System :: POSIX',
'Programming Language :: Python',
'Programming Language :: Unix Shell',
'Topic :: Software Development :: Libraries :: Python Modules'
]
)