Skip to content

Commit 70e916c

Browse files
authored
Merge pull request #3 from y-aok/issue-2_setup-issue
#2 fix ModuleNotFoundError on setup.py
2 parents db51ddd + c184776 commit 70e916c

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

setup.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,42 @@
22
"""
33
pip setup file
44
"""
5-
from pyclickup.globals import __version__, LIBRARY
65
from setuptools import setup, find_packages
76

7+
LIBRARY = 'pyclickup'
8+
89

910
with open("README.rst") as readme:
1011
long_description = readme.read()
1112

1213

14+
with open("requirements.txt") as requirements:
15+
install_requires = requirements.read().split("\n")
16+
install_requires = [x.strip() for x in install_requires if x.strip()]
17+
18+
19+
def find_version(*file_paths):
20+
import os
21+
import re
22+
"""
23+
This pattern was modeled on a method from the Python Packaging User Guide:
24+
https://packaging.python.org/en/latest/single_source_version.html
25+
We read instead of importing so we don't get import errors if our code
26+
imports from dependencies listed in install_requires.
27+
"""
28+
base_module_file = os.path.join(*file_paths)
29+
with open(base_module_file) as f:
30+
base_module_data = f.read()
31+
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
32+
base_module_data, re.M)
33+
if version_match:
34+
return version_match.group(1)
35+
raise RuntimeError("Unable to find version string.")
36+
37+
1338
setup(
1439
name=LIBRARY,
15-
version=__version__,
40+
version=find_version('pyclickup', 'globals.py'),
1641
description="A python wrapper for the ClickUp API",
1742
long_description=long_description,
1843
author="Jacobi Petrucciani",
@@ -22,6 +47,7 @@
2247
download_url="https://github.com/jpetrucciani/{}.git".format(LIBRARY),
2348
license="LICENSE",
2449
packages=find_packages(),
50+
install_requires=install_requires,
2551
classifiers=[
2652
"Programming Language :: Python :: 3",
2753
"Programming Language :: Python :: 3.5",

0 commit comments

Comments
 (0)