Warning: If your project has optional C extensions, it is recommended not to publish a universal wheel, because pip will prefer the wheel over a source installation.
-
-
Save akkefa/cb5050f9b7e76585d7c8680697176e9b to your computer and use it in GitHub Desktop.
Python Setup Tips and Tricks http://j.mp/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
.PHONY: test install pep8 release clean | |
test: pep8 | |
py.test --cov -l --tb=short --maxfail=1 program/ | |
install: | |
python setup.py develop | |
pep8: | |
@flake8 program --ignore=F403 --exclude=junk | |
release: test | |
@python setup.py sdist bdist_wheel upload | |
clean: | |
@find ./ -name '*.pyc' -exec rm -f {} \; | |
@find ./ -name 'Thumbs.db' -exec rm -f {} \; | |
@find ./ -name '*~' -exec rm -f {} \; |
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
[bdist_wheel] | |
universal = 1 |
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 | |
try: | |
import pypandoc | |
long_description = pypandoc.convert('README.md', 'rst') | |
except (IOError, ImportError): | |
long_description = "Python rulez" | |
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 Program', | |
version="0.0.1", | |
url='https://github.com/myname/myprogram', | |
license='MIT', | |
author="Super Man", | |
author_email="[email protected]", | |
description='Awesome project', | |
long_description=long_description, | |
packages=find_packages(), | |
include_package_data=True, | |
zip_safe=False, | |
platforms='any', | |
install_requires=requires, | |
dependency_links=links, | |
entry_points={ | |
"console_scripts": [ | |
"program = program.module:main" | |
] | |
}, | |
classifiers=[ | |
'Development Status :: 4 - Beta', | |
'Intended Audience :: Developers', | |
'Operating System :: POSIX', | |
'Operating System :: POSIX :: Linux', | |
'License :: OSI Approved :: MIT License', | |
'Programming Language :: Python :: 2', | |
'Programming Language :: Python :: 2.7', | |
'Programming Language :: Python :: 3', | |
'Programming Language :: Python :: 3.3', | |
'Programming Language :: Python :: 3.4', | |
] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment