Skip to content

Commit 4aa5d53

Browse files
Merge pull request #44 from uparma/feature/setup_cfg
Feature/setup cfg
2 parents 29f0d17 + 8d78e21 commit 4aa5d53

10 files changed

Lines changed: 139 additions & 79 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
__pycache__
22
*.pyc
33
docs/build
4-
*.json
54
build
65
pyenv
76
.idea
87
.DS_Store
98
.tox
9+
uparma/version.txt

pyproject.toml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[dev-dependencies]
2+
black = { version = "^18.3-alpha.0", python = "^3.8" }
3+
4+
[build-system]
5+
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"]
6+
build-backend = "setuptools.build_meta"
7+
8+
[tool.setuptools_scm]
9+
write_to = "uparma/version.txt"
10+
11+
[tool.black]
12+
line-length = 88
13+
target-version = ["py38"]
14+
include = '\.pyi?$'
15+
extend-exclude = '''
16+
/(
17+
# The following are specific to Black, you probably don't want those.
18+
| blib2to3
19+
| profiling
20+
)/
21+
'''
22+
23+
[tool.tox]
24+
legacy_tox_ini = """
25+
26+
[tox]
27+
envlist = py38,py39
28+
isolated_build = True
29+
30+
[testenv]
31+
passenv =
32+
*
33+
commands =
34+
pytest {posargs}
35+
36+
[testenv:coverage]
37+
commands =
38+
coverage erase
39+
coverage run --source=ursgal {envbindir}/pytest {posargs}
40+
coverage report -m
41+
"""
42+
43+
[tool.pytest.ini_options]
44+
markers = [
45+
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
46+
]

setup.cfg

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[metadata]
2+
name = uparma
3+
description = tba
4+
long_description = tba
5+
author = tba
6+
author_email = christian@fufezan.net
7+
url = https://github.com/uparma
8+
license = tba
9+
classifier =
10+
Development Status :: 4 - Beta
11+
Environment :: Console
12+
Intended Audience :: Education
13+
Intended Audience :: Science/Research
14+
Intended Audience :: Developers
15+
License :: OSI Approved :: MIT License
16+
Operating System :: MacOS :: MacOS X
17+
Operating System :: Microsoft :: Windows
18+
Operating System :: POSIX
19+
Operating System :: POSIX :: SunOS/Solaris
20+
Operating System :: Unix
21+
Programming Language :: Python :: 3.5
22+
Topic :: Scientific/Engineering :: Bio-Informatics
23+
Topic :: Scientific/Engineering :: Chemistry
24+
Topic :: Scientific/Engineering :: Medical Science Apps
25+
26+
[options]
27+
packages = find_namespace:
28+
install_requires =
29+
pytest==6.2.2
30+
requests==2.25.1
31+
32+
[options.package_data]
33+
uparma = *.txt, *.json
34+
35+
[egg_info]
36+
egg_base = .

setup.py

Lines changed: 37 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,38 @@
1-
#!/usr/bin/env python3
2-
from setuptools import setup
3-
import os
4-
5-
6-
# We store our version number in a simple text file:
7-
version_path = os.path.join(os.path.dirname(__file__), "uparma", "version.txt")
8-
9-
with open(version_path, "r") as version_file:
10-
uparma_py_version = version_file.read().strip()
11-
12-
with open("requirements.txt") as req_file:
13-
reqs = req_file.readlines()
14-
15-
16-
setup(
17-
name="uparma",
18-
version=uparma_py_version,
19-
packages=["uparma"],
20-
package_dir={"uparma": "uparma"},
21-
description="uparma",
22-
package_data={
23-
"uparma": [
24-
"version.txt",
25-
"lib_version.txt",
26-
]
27-
},
28-
install_requires=reqs,
29-
long_description="Universal Parameter Mapper for Proteomics tools",
30-
author="... and Christian Fufezan",
31-
author_email="christian@fufezan.net",
32-
url="http://github.com/uparma/uparma-py",
33-
license="Lesser GNU General Public License (LGPL)",
34-
platforms="any that supports python 3.4",
35-
classifiers=[
36-
"Development Status :: 4 - Beta",
37-
"Environment :: Console",
38-
"Intended Audience :: Science/Research",
39-
"Intended Audience :: Developers",
40-
"Operating System :: MacOS :: MacOS X",
41-
"Operating System :: Microsoft :: Windows",
42-
"Operating System :: POSIX",
43-
"Operating System :: POSIX :: SunOS/Solaris",
44-
"Operating System :: Unix",
45-
"Programming Language :: Python :: 3",
46-
"Programming Language :: Python :: 3.4",
47-
"Topic :: Scientific/Engineering :: Bio-Informatics",
48-
"Topic :: Scientific/Engineering :: Chemistry",
49-
"Topic :: Scientific/Engineering :: Medical Science Apps.",
50-
"Topic :: Software Development :: Libraries :: Python Modules",
51-
],
1+
import setuptools
2+
3+
4+
def branch_dependent_version():
5+
import setuptools_scm
6+
7+
def void(version):
8+
return ""
9+
10+
def version_scheme(version):
11+
if version.branch not in ["main", "master"]:
12+
_v = setuptools_scm.get_version(local_scheme=void)
13+
else:
14+
_v = str(version.tag)
15+
return _v
16+
17+
def local_scheme(version):
18+
if version.branch not in ["main", "master"]:
19+
_v = setuptools_scm.get_version(version_scheme=void)
20+
else:
21+
_v = ""
22+
return _v
23+
24+
scm_version = {
25+
"root": ".",
26+
"relative_to": __file__,
27+
"version_scheme": version_scheme,
28+
"local_scheme": local_scheme
29+
# >> "no-local-version" not quit good enough
30+
# >> on dev "node-and-timestamp", # version_scheme,
31+
}
32+
return scm_version
33+
34+
35+
setuptools.setup(
36+
use_scm_version=branch_dependent_version,
37+
setup_requires=["setuptools_scm"],
5238
)

tox.ini

Lines changed: 0 additions & 17 deletions
This file was deleted.

uparma/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import os
2+
from importlib.metadata import PackageNotFoundError, version
23

3-
# Load version
4-
version_path = os.path.join(os.path.dirname(__file__), "version.txt")
5-
with open(version_path, "r") as version_file:
6-
__version__ = version_file.read().strip()
4+
try:
5+
__version__ = version(__name__)
6+
except PackageNotFoundError:
7+
__version__ = None
8+
9+
# Version
10+
__version_str__ = str(__version__)
711

812
lib_version_path = os.path.join(os.path.dirname(__file__), "lib_version.txt")
913
with open(lib_version_path, "r") as lib_version_file:

uparma/parameters.json

Whitespace-only changes.

uparma/styles.json

Whitespace-only changes.

uparma/uparma.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
(
1515
"general",
1616
"parameters",
17-
): f"https://raw.githubusercontent.com/uparma/uparma-lib/v{uparma.__lib_version__}/jsons/parameters.json",
17+
): f"https://raw.githubusercontent.com/uparma/uparma-lib/master/jsons/parameters.json",
18+
# f"https://raw.githubusercontent.com/uparma/uparma-lib/v{uparma.__lib_version__}/jsons/parameters.json",
1819
(
1920
"general",
2021
"styles",
21-
): f"https://raw.githubusercontent.com/uparma/uparma-lib/v{uparma.__lib_version__}/jsons/styles.json",
22+
): f"https://raw.githubusercontent.com/uparma/uparma-lib/master/jsons/styles.json",
23+
# f"https://raw.githubusercontent.com/uparma/uparma-lib/v{uparma.__lib_version__}/jsons/styles.json",
2224
}
2325

2426
base_path = Path(__file__)
@@ -84,6 +86,13 @@ def __init__(
8486
refresh_jsons = True
8587
# we will have to pull
8688

89+
if refresh_jsons is False:
90+
with open(full_path) as j:
91+
try:
92+
self.jsons[url_id] = json.load(j)
93+
except json.decoder.JSONDecodeError:
94+
refresh_jsons = True
95+
8796
if refresh_jsons is True:
8897
with requests.get(url) as req:
8998
with open(full_path, "w") as j:
@@ -94,9 +103,6 @@ def __init__(
94103
)
95104
print(json.dumps(req.json(), indent=2, sort_keys=True), file=j)
96105
self.jsons[url_id] = req.json()
97-
else:
98-
with open(full_path) as j:
99-
self.jsons[url_id] = json.load(j)
100106

101107
# Let's overwrite with custom
102108
if parameter_data is not None:

uparma/version.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)