1. zip 생성


아래와 같이 setup.py 작성후 해당 내용을 묶어 zip으로 구성후 배포



향후 설치시에는 zip를 풀고, 


python setup.py install


=======================  ex1) setup.py ==================================

아래 각 필드는 해당 환경에 맞게 조정이 필요함


#!/usr/bin/env python

# -*- coding: UTF-8 -*-

import os

from setuptools import setup


setup(

    name = 'test1',

    version='1.0',

    license='GNU General Public License v3',

    author='Test',

    author_email='test1@test.co.kr',

    description='Test Program',

    packages=['test1'],

    platforms='any',

    install_requires=[

        'flask', 'requests'

    ],

    classifiers=[

        'Development Status :: 1.0',

        'Environment :: Web Environment',

        'Intended Audience :: Developers',

        'License :: OSI Approved :: GNU General Public License v3',

        'Operating System :: OS Independent',

        'Programming Language :: Python',

        'Topic :: Internet :: WWW/HTTP :: Dynamic Content',

        'Topic :: Software Development :: Libraries :: Python Modules'

    ],

)



========================== ex2 ) setup.py=======================

setup(

    name = 'test1',

    version='1.0',

    license='GNU General Public License v3',

    author='Test',

    author_email='test1@test.co.kr',

    description='Test Program',

    packages=['test_app', 'test_app.test1'],

    include_package_data=True,

    zip_safe = False,                                                 -- zip 압축을 안함

    platforms='any',

    install_requires=[

        'flask', 'requests'

    ],

    classifiers=[

        'Development Status :: 1.0',

        'Environment :: Web Environment',

        'Intended Audience :: Developers',

        'License :: OSI Approved :: GNU General Public License v3',

        'Operating System :: OS Independent',

        'Programming Language :: Python',

        'Topic :: Internet :: WWW/HTTP :: Dynamic Content',

        'Topic :: Software Development :: Libraries :: Python Modules'

    ],

)



include_package_data ==> MANIFEST.in 파일 참조

recursive-include test_app/templates *


2. native packaging


1) 소스


def main():

    print("hello.....")



2) 디렉토리 생성

hello

   |

   |--  hello 

        |

        |--  __init__.py

        |-- main.py



3) virualenv 환경 생성

python3.7 -m venv   /tmp/work/test

source /tmp/work/test/bin/activate


# setup tool 설치

pip install setuptools twine    


# package setup files


from setuptools  import setup, find_packages


setup(

name="hello",

version="1.0.0",

author="test",

author="test@??.com",

url="localhost",

      description="hello...",

      packages=find_packages(),

      classifiers=[

            "Programming Language :: Python :: 3",

            "License :: OSI Approved :: MIT License",

            "Operating System :: OS Independent",

      ],

)



hello

   |

   |--  hello 

   |     |

   |     |--  __init__.py

   |     |-- main.py

   |--  README

   |--  setup.py



4) packaging

python3.7 setup.py sdist


5) install

pip install hello-world-1.0.0.tar.gz



'Language > python' 카테고리의 다른 글

python 버전 바꾸기  (0) 2018.01.03
python elk  (0) 2017.06.06
python fabric 설치  (0) 2017.06.06
python virtualenv 생성  (0) 2017.06.01
[web] flask 기본  (0) 2017.04.25

+ Recent posts