Created
January 10, 2018 14:10
-
-
Save junmakii/c7c38054456699d69529b6ce81f39c43 to your computer and use it in GitHub Desktop.
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
| [aliases] | |
| test=pytest | |
| [tool:pytest] | |
| doctest_plus = enabled | |
| addopts = --ignore=env --doctest-modules | |
| #--ignore-toplevel=setup.py | |
| testpaths=mypkg | |
| norecursedirs=lib include .tox |
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
| """A setup file to install a package. | |
| See the following <http://setuptools.readthedocs.io/en/latest/setuptools.html#id54>. | |
| Metadata | |
| -------- | |
| - Key Aliases Type | |
| - name str | |
| - version attr:, str | |
| - url home-page str | |
| - download_url download-url str | |
| - project_urls dict | |
| - author str | |
| - author_email author-email str | |
| - maintainer str | |
| - maintainer_email maintainer-email str | |
| - classifiers classifier file:, list-comma | |
| - license file:, str | |
| - description summary file:, str | |
| - long_description long-description file:, str | |
| - long_description_content_type str | |
| - keywords list-comma | |
| - platforms platform list-comma | |
| - provides list-comma | |
| - requires list-comma | |
| - obsoletes list-comma | |
| Options | |
| ------- | |
| - Key Type | |
| - zip_safe bool | |
| - setup_requires list-semi | |
| - install_requires list-semi | |
| - extras_require section | |
| - python_requires str | |
| - entry_points file:, section | |
| - use_2to3 bool | |
| - use_2to3_fixers list-comma | |
| - use_2to3_exclude_fixers list-comma | |
| - convert_2to3_doctests list-comma | |
| - scripts list-comma | |
| - eager_resources list-comma | |
| - dependency_links list-comma | |
| - tests_require list-semi | |
| - include_package_data bool | |
| - packages find:, list-comma | |
| - package_dir dict | |
| - package_data section | |
| - exclude_package_data section | |
| - namespace_packages list-comma | |
| - py_modules list-comma | |
| """ | |
| import os | |
| from setuptools import setup, find_packages, Command | |
| from setuptools.command.install import install | |
| import doctest | |
| class SetupCommand(Command): | |
| user_options = [] | |
| def initialize_options(self): | |
| pass | |
| def finalize_options(self): | |
| pass | |
| def run(self, *args, **kwargs): | |
| doctest.testmod(module, verbose=True, raise_on_error=True) | |
| class SetupInstallCommand(install): | |
| def run(self): | |
| install.run(self) | |
| name = ( | |
| [i for i in os.listdir(os.path.dirname(__file__) or '.') | |
| if os.path.exists(os.path.join(i, '__init__.py'))] | |
| or [i.split('.', 1)[0] for i in os.listdir(os.path.dirname(__file__) or '.') | |
| if (i.endswith('.py') and i not in ['setup.py'])] | |
| )[0] | |
| module = __import__(name) | |
| setup( | |
| name=name, | |
| version=getattr(module, '__version__', '0.1'), | |
| description=getattr(module, '__doc__', '').splitlines()[0], | |
| long_description=getattr(module, '__doc__', ''), | |
| url=getattr(module, '__url__'), | |
| author=getattr(module, '__author__'), | |
| author_email=getattr(module, '__author_email__', ''), | |
| keywords=getattr(module, '__keywords__', ''), | |
| license=getattr(module, '__license__', 'GPLv3'), | |
| packages=find_packages('.'), | |
| package_data={ | |
| '': ['*'] | |
| }, | |
| py_modules=[name], | |
| scripts=getattr(module, '__scripts__', ( | |
| lambda script_dir: ([ | |
| os.path.join(script_dir, i) | |
| for i in os.listdir(script_dir) | |
| ] if os.path.exists(script_dir) else []) | |
| )(os.path.join(os.path.dirname(__file__), 'scripts'))), | |
| install_requires=getattr(module, '__install_requires__', []), | |
| classifiers=getattr(module, '__classifiers__', [ | |
| 'Intended Audience :: Developers', | |
| 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', | |
| 'Natural Language :: English', | |
| 'Programming Language :: Python', | |
| 'Programming Language :: Python :: 2.7', | |
| ]), | |
| # for the static files. | |
| # ~/anaconda2/PKG_NAME/data.json | |
| # data_files=getattr(module, '__data_files__', | |
| # [(name, ['data.json'])]), | |
| # exclude_package_data={'': ['README.txt']}, | |
| entry_points=getattr( | |
| module, '__entry_points__', | |
| {'console_scripts': []}), | |
| setup_requires=['pytest-runner'], | |
| # test_suite=getattr( | |
| # module, | |
| # '__test_suite__', | |
| # name, | |
| # ), | |
| # python_requires='>=2.5', | |
| # tests_require=list(open('test_requirements.txt').readlines()), | |
| tests_require=getattr(module, '__tests_require__', ['pytest', 'flake8']), | |
| include_package_data=True, | |
| zip_safe=False, | |
| setup_cfg=True, | |
| cmdclass={'test': SetupCommand, 'install': SetupInstallCommand}, | |
| ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment