Created
May 14, 2021 18:03
-
-
Save hartsock/26385ffaec274b2afe79f1dee6f48afe to your computer and use it in GitHub Desktop.
A super generic Python3 setup.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import os | |
from setuptools import find_packages, setup | |
# Author @hartsock | |
# | |
# Why: copy into a directory with some python scripts you want to call a "library" | |
# How: pip3 install -e . | |
# | |
# I often run into piles of Python scripts that _could_ be used as a python library. These often aren't | |
# enough to warrant a WHOLE separate python library project, but it's nice to setup a Python3 venv to | |
# have these simple hacky "library" scripts available. | |
# | |
# This is a version of a very super generic python setup.py that I use in these weird little corner cases. | |
# optionally allow for a requirements file if folks feel like it. | |
def read(*names, **kwargs): | |
try: | |
return io.open( | |
os.path.join(os.path.dirname(__file__), *names), | |
encoding=kwargs.get('encoding', 'utf8') | |
).read() | |
except FileNotFoundError: | |
return "" | |
# don't package and ship python test code in this library | |
packages = [item for item in find_packages('.', exclude=['test']) if not str(item).startswith('test')] | |
setup( | |
# allow for package name to be determined by wherever we are | |
name=os.path.basename(os.path.dirname(__file__)), | |
packages=packages, | |
# we scoop the installer requirements into the packager's definition here | |
install_requires=read('requirements.txt').splitlines(), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment