Skip to content

automated packaging in setup.py #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[settings]
known_third_party = arviz,matplotlib,numba,numpy,pandas,pandas_flavor,pymc,pytensor,pytest,scipy,sphinx_bootstrap_theme,tqdm
known_third_party = arviz,matplotlib,numba,numpy,pandas,pandas_flavor,pymc,pytensor,pytest,scipy,setuptools,sphinx_bootstrap_theme,tqdm
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
Expand Down
61 changes: 36 additions & 25 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,49 @@
# Copyright (C) 2019 Nicolas Legrand
import codecs
import os

from setuptools import setup

def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
PROJECT_ROOT = os.path.dirname(os.path.realpath(__file__))
REQUIREMENTS_FILE = os.path.join(PROJECT_ROOT, "requirements.txt")


DESCRIPTION = "metadpy: Metacognitive efficiency modelling in Python"
LONG_DESCRIPTION = (
"Fitting behavioural and cognitive models of metacognitive efficiency in Python."
)
def get_requirements():
with codecs.open(REQUIREMENTS_FILE) as buff:
return buff.read().splitlines()


# Get the package's version number of the __init__.py file
def read(rel_path):
"""Read the file located at the provided relative path."""
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, rel_path), "r") as fp:
return fp.read()


def get_version(rel_path):
"""Get the package's version number.
We fetch the version number from the `__version__` variable located in the
package root's `__init__.py` file. This way there is only a single source
of truth for the package's version number.

"""
for line in read(rel_path).splitlines():
if line.startswith("__version__"):
delim = '"' if '"' in line else "'"
return line.split(delim)[1]
else:
raise RuntimeError("Unable to find version string.")


DESCRIPTION = "metadpy: Metacognitive efficiency modelling in Python"
DISTNAME = "metadpy"
MAINTAINER = "Nicolas Legrand"
MAINTAINER_EMAIL = "nicolas.legrand@cas.au.dk"
VERSION = "0.1.1"

INSTALL_REQUIRES = [
"numpy>=1.18.1",
"scipy>=1.3",
"pandas>=0.24",
"matplotlib>=3.1.3",
"seaborn>=0.10.0",
"pandas_flavor>=0.1.2",
"numba>=0.55.1",
]

PACKAGES = ["metadpy", "metadpy.datasets"]

try:
from setuptools import setup

_has_setuptools = True
except ImportError:
from distutils.core import setup

if __name__ == "__main__":

Expand All @@ -44,10 +54,11 @@ def read(fname):
maintainer=MAINTAINER,
maintainer_email=MAINTAINER_EMAIL,
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
long_description=open("README.md", encoding="utf-8").read(),
long_description_content_type="text/markdown",
license="GPL-3.0",
version=VERSION,
install_requires=INSTALL_REQUIRES,
version=get_version("metadpy/__init__.py"),
install_requires=get_requirements(),
include_package_data=True,
packages=PACKAGES,
)