Skip to content

Commit 4e71950

Browse files
author
Michele Fabbri
committed
setup for pypi template
1 parent 2277700 commit 4e71950

File tree

2 files changed

+52
-7
lines changed

2 files changed

+52
-7
lines changed

__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "0.0.1"

setup.py

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,56 @@
1-
from setuptools import setup, find_packages
1+
import sys
2+
from pathlib import Path
3+
4+
from setuptools import find_packages, setup
5+
6+
CURRENT_DIRECTORY = Path(__file__).parent.absolute()
7+
CURRENT_PYTHON = sys.version_info[:2]
8+
REQUIRED_PYTHON = (3, 8)
9+
VER_ERR_MSG = """
10+
==========================
11+
Unsupported Python version
12+
==========================
13+
This version of ibllib requires Python {}.{}, but you're trying to install it on Python {}.{}.
14+
"""
15+
if CURRENT_PYTHON < REQUIRED_PYTHON:
16+
sys.stderr.write(VER_ERR_MSG.format(*REQUIRED_PYTHON + CURRENT_PYTHON))
17+
sys.exit(1)
18+
19+
with open("README.md", "r") as f:
20+
long_description = f.read()
21+
22+
with open("requirements.txt") as f:
23+
require = [x.strip() for x in f.readlines() if not x.startswith("git+")]
24+
25+
26+
def read(rel_path):
27+
here = Path(__file__).parent.absolute()
28+
with open(here.joinpath(rel_path), "r") as fp:
29+
return fp.read()
30+
31+
32+
def get_version(rel_path):
33+
for line in read(rel_path).splitlines():
34+
if line.startswith("__version__"):
35+
delim = '"' if '"' in line else "'"
36+
return line.split(delim)[1]
37+
else:
38+
raise RuntimeError("Unable to find version string.")
239

3-
with open('requirements.txt') as f:
4-
require = [x.strip() for x in f.readlines() if not x.startswith('git+')]
540

641
setup(
7-
name='iblapps',
8-
version='0.1',
9-
packages=find_packages(),
42+
name="iblapps",
43+
version=get_version("__init__.py"),
44+
python_requires=">={}.{}".format(*REQUIRED_PYTHON),
45+
description="IBL Applications",
46+
license="MIT",
47+
long_description=long_description,
48+
long_description_content_type="text/markdown",
49+
author="IBL Staff",
50+
url="https://www.internationalbrainlab.com/",
51+
packages=find_packages(exclude=["scratch"]), # same as name
1052
include_package_data=True,
11-
install_requires=require
53+
# external packages as dependencies
54+
install_requires=require,
55+
scripts=[],
1256
)

0 commit comments

Comments
 (0)