Skip to content

Commit

Permalink
Update setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
rexzhang committed Jan 13, 2022
1 parent 7060c8b commit 677ed0c
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,63 @@
# Template:
# https://github.com/rexzhang/pypi-package-project-template/blob/master/setup.py

from typing import List

# Always prefer setuptools over distutils
from setuptools import setup, find_packages

# To use a consistent encoding
from codecs import open
from os import path
from pathlib import Path

import aiomemcached as module

here = path.abspath(path.dirname(__file__))
root_path = Path(__file__).parent
requirements_path = root_path.joinpath("requirements")

# Get the long description from the README file
with open(path.join(here, "README.rst"), encoding="utf-8") as f:
with open(root_path.joinpath("README.md").as_posix(), encoding="utf-8") as f:
long_description = f.read()


# Get install_requires from requirements.txt
def _read_install_requires_from_requirements_txt(base_path, filename):
_install_requires = []
with open(path.join(base_path, filename), encoding="utf-8") as req_f:
def _read_requires_from_requirements_txt(
base_path: Path, filename: str, ignore_base: bool = False
) -> List[str]:
_requires = []
with open(base_path.joinpath(filename).as_posix(), encoding="utf-8") as req_f:
lines = req_f.readlines()
for line in lines:
if line == "\n" or line == "" or line[0] == "#":
continue

words = line.rstrip("\n").split(" ")
if words[0] == "-r":
_install_requires.extend(
_read_install_requires_from_requirements_txt(
base_path=base_path, filename=words[1]
if ignore_base and words[1] == "base.txt":
continue

else:
_requires.extend(
_read_requires_from_requirements_txt(
base_path=base_path, filename=words[1]
)
)
)

else:
_install_requires.append(words[0])
_requires.append(words[0])

return _install_requires
return _requires


install_requires = _read_install_requires_from_requirements_txt(
base_path=here, filename="requirements/base.txt"
install_requires = _read_requires_from_requirements_txt(
base_path=requirements_path, filename="base.txt"
)
extras_require_dev = list(
set(
_read_requires_from_requirements_txt(
base_path=requirements_path, filename="dev.txt"
)
)
)


Expand Down Expand Up @@ -190,7 +206,4 @@ def _read_install_requires_from_requirements_txt(base_path, filename):
# 'python_module_project=python_module_project:main',
# ],
# },
# tests_require=tests_require,
# test_suite="nose.collector",
include_package_data=True,
)

0 comments on commit 677ed0c

Please sign in to comment.