Skip to content

Commit

Permalink
automated packaging in setup.py (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
LegrandNico authored Mar 23, 2023
1 parent eadf426 commit eeea3df
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 26 deletions.
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 = "[email protected]"
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,
)

0 comments on commit eeea3df

Please sign in to comment.