Skip to content

Commit

Permalink
Merge pull request #44 from uparma/feature/setup_cfg
Browse files Browse the repository at this point in the history
Feature/setup cfg
  • Loading branch information
tristan-ranff authored Dec 15, 2022
2 parents 29f0d17 + 8d78e21 commit 4aa5d53
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
__pycache__
*.pyc
docs/build
*.json
build
pyenv
.idea
.DS_Store
.tox
uparma/version.txt
46 changes: 46 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[dev-dependencies]
black = { version = "^18.3-alpha.0", python = "^3.8" }

[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "uparma/version.txt"

[tool.black]
line-length = 88
target-version = ["py38"]
include = '\.pyi?$'
extend-exclude = '''
/(
# The following are specific to Black, you probably don't want those.
| blib2to3
| profiling
)/
'''

[tool.tox]
legacy_tox_ini = """
[tox]
envlist = py38,py39
isolated_build = True
[testenv]
passenv =
*
commands =
pytest {posargs}
[testenv:coverage]
commands =
coverage erase
coverage run --source=ursgal {envbindir}/pytest {posargs}
coverage report -m
"""

[tool.pytest.ini_options]
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
]
36 changes: 36 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[metadata]
name = uparma
description = tba
long_description = tba
author = tba
author_email = [email protected]
url = https://github.com/uparma
license = tba
classifier =
Development Status :: 4 - Beta
Environment :: Console
Intended Audience :: Education
Intended Audience :: Science/Research
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Operating System :: MacOS :: MacOS X
Operating System :: Microsoft :: Windows
Operating System :: POSIX
Operating System :: POSIX :: SunOS/Solaris
Operating System :: Unix
Programming Language :: Python :: 3.5
Topic :: Scientific/Engineering :: Bio-Informatics
Topic :: Scientific/Engineering :: Chemistry
Topic :: Scientific/Engineering :: Medical Science Apps

[options]
packages = find_namespace:
install_requires =
pytest==6.2.2
requests==2.25.1

[options.package_data]
uparma = *.txt, *.json

[egg_info]
egg_base = .
88 changes: 37 additions & 51 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,38 @@
#!/usr/bin/env python3
from setuptools import setup
import os


# We store our version number in a simple text file:
version_path = os.path.join(os.path.dirname(__file__), "uparma", "version.txt")

with open(version_path, "r") as version_file:
uparma_py_version = version_file.read().strip()

with open("requirements.txt") as req_file:
reqs = req_file.readlines()


setup(
name="uparma",
version=uparma_py_version,
packages=["uparma"],
package_dir={"uparma": "uparma"},
description="uparma",
package_data={
"uparma": [
"version.txt",
"lib_version.txt",
]
},
install_requires=reqs,
long_description="Universal Parameter Mapper for Proteomics tools",
author="... and Christian Fufezan",
author_email="[email protected]",
url="http://github.com/uparma/uparma-py",
license="Lesser GNU General Public License (LGPL)",
platforms="any that supports python 3.4",
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: POSIX :: SunOS/Solaris",
"Operating System :: Unix",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Topic :: Scientific/Engineering :: Chemistry",
"Topic :: Scientific/Engineering :: Medical Science Apps.",
"Topic :: Software Development :: Libraries :: Python Modules",
],
import setuptools


def branch_dependent_version():
import setuptools_scm

def void(version):
return ""

def version_scheme(version):
if version.branch not in ["main", "master"]:
_v = setuptools_scm.get_version(local_scheme=void)
else:
_v = str(version.tag)
return _v

def local_scheme(version):
if version.branch not in ["main", "master"]:
_v = setuptools_scm.get_version(version_scheme=void)
else:
_v = ""
return _v

scm_version = {
"root": ".",
"relative_to": __file__,
"version_scheme": version_scheme,
"local_scheme": local_scheme
# >> "no-local-version" not quit good enough
# >> on dev "node-and-timestamp", # version_scheme,
}
return scm_version


setuptools.setup(
use_scm_version=branch_dependent_version,
setup_requires=["setuptools_scm"],
)
17 changes: 0 additions & 17 deletions tox.ini

This file was deleted.

12 changes: 8 additions & 4 deletions uparma/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import os
from importlib.metadata import PackageNotFoundError, version

# Load version
version_path = os.path.join(os.path.dirname(__file__), "version.txt")
with open(version_path, "r") as version_file:
__version__ = version_file.read().strip()
try:
__version__ = version(__name__)
except PackageNotFoundError:
__version__ = None

# Version
__version_str__ = str(__version__)

lib_version_path = os.path.join(os.path.dirname(__file__), "lib_version.txt")
with open(lib_version_path, "r") as lib_version_file:
Expand Down
Empty file added uparma/parameters.json
Empty file.
Empty file added uparma/styles.json
Empty file.
16 changes: 11 additions & 5 deletions uparma/uparma.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
(
"general",
"parameters",
): f"https://raw.githubusercontent.com/uparma/uparma-lib/v{uparma.__lib_version__}/jsons/parameters.json",
): f"https://raw.githubusercontent.com/uparma/uparma-lib/master/jsons/parameters.json",
# f"https://raw.githubusercontent.com/uparma/uparma-lib/v{uparma.__lib_version__}/jsons/parameters.json",
(
"general",
"styles",
): f"https://raw.githubusercontent.com/uparma/uparma-lib/v{uparma.__lib_version__}/jsons/styles.json",
): f"https://raw.githubusercontent.com/uparma/uparma-lib/master/jsons/styles.json",
# f"https://raw.githubusercontent.com/uparma/uparma-lib/v{uparma.__lib_version__}/jsons/styles.json",
}

base_path = Path(__file__)
Expand Down Expand Up @@ -84,6 +86,13 @@ def __init__(
refresh_jsons = True
# we will have to pull

if refresh_jsons is False:
with open(full_path) as j:
try:
self.jsons[url_id] = json.load(j)
except json.decoder.JSONDecodeError:
refresh_jsons = True

if refresh_jsons is True:
with requests.get(url) as req:
with open(full_path, "w") as j:
Expand All @@ -94,9 +103,6 @@ def __init__(
)
print(json.dumps(req.json(), indent=2, sort_keys=True), file=j)
self.jsons[url_id] = req.json()
else:
with open(full_path) as j:
self.jsons[url_id] = json.load(j)

# Let's overwrite with custom
if parameter_data is not None:
Expand Down
1 change: 0 additions & 1 deletion uparma/version.txt

This file was deleted.

0 comments on commit 4aa5d53

Please sign in to comment.