When developing as a team, there are cases where you want other people to use your own tools, or you want to incorporate your own modules into your project. In such a case, "packaging" is convenient.
I'll write later how to secretly host a package in a private repository.
(Addition) I'm sorry this may be
The following explanation will be written assuming the following structure. Please spit out the requirements relation with pip freeze. The project name is "uhouhoapp"
def main():
print('HelloWorld')
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
def _load_requires_from_file(filepath):
return [pkg_name.rstrip('\r\n') for pkg_name in open(filepath).readlines()]
def _install_requires():
requires = _load_requires_from_file('requirements.txt')
return requires
def _test_requires():
test_requires = _load_requires_from_file('test-requirements.txt')
return test_requires
def _packages():
return find_packages(
exclude=[
'*.tests',
'*.tests.*',
'tests.*',
'tests',
'*.yaml'
],
)
if __name__ == '__main__':
description = ''
setup(
name='uhouhoapp',
version='1.0.0',
description=description,
author='UhoUho Inc.',
author_email='[email protected]',
classifiers=[
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Development Status :: 3 - Alpha',
'License :: Confidencial',
'Intended Audience :: Developers',
'Natural Language :: English',
'Operating System :: POSIX'
],
packages=_packages(),
install_requires=_install_requires(),
tests_require=_test_requires(),
test_suite='nose.collector',
include_package_data=True,
zip_safe=False,
entry_points="""
[console_scripts]
uhouhoapp = uhouhoapp.main:main
""",
)
If you hit the following command, my module will be registered.
$ pip install -e .
Obtaining file:///Users/hiroyuki/test22
Installing collected packages: uhouhoapp
Running setup.py develop for uhouhoapp
Successfully installed uhouhoapp-1.0.0
If you want to execute it, do the following. If you're a good commander, you can get rid of the console_scripts part of setup.py.
$ uhouhoapp
HelloWorld
Recommended Posts