-
-
Save luzfcb/75d0e1e705d07a0f528c to your computer and use it in GitHub Desktop.
Perfect setup.py
This file contains hidden or 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 pip | |
try: | |
from setuptools import setup, find_packages | |
except ImportError: | |
from distutils.core import setup, find_packages | |
links = [] # for repo urls (dependency_links) | |
requires = [] # for package names | |
try: | |
requirements = pip.req.parse_requirements('requirements.txt') | |
except: | |
# new versions of pip requires a session | |
requirements = pip.req.parse_requirements( | |
'requirements.txt', session=pip.download.PipSession() | |
) | |
for item in requirements: | |
if getattr(item, 'url', None): # older pip has url | |
links.append(str(item.url)) | |
if getattr(item, 'link', None): # newer pip has link | |
links.append(str(item.link)) | |
if item.req: | |
requires.append(str(item.req)) # always the package name | |
setup( | |
name='My Porject', | |
version="0.0.0", # avoid reading version from __init__.py it belongs here | |
url='https://github.com/myname/myproject', # repo is prefered over project site | |
license='FREE', | |
author="Super Man", | |
author_email="[email protected]", | |
description='Awesome project', # small description, avoid extra read from outer file | |
long_description="Python rulez", # it needs to be an .rst file open().read() from somewhere | |
packages=find_packages(), | |
include_package_data=True, | |
zip_safe=False, | |
platforms='any', | |
install_requires=requires, | |
dependency_links=links | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment