Create Django Package 3 - Tirrilee/TechTalk GitHub Wiki

νŒ¨ν‚€μ§•

setup.pyμ—λŠ” 이름, 버전, μ„€λͺ…, ν•„μš”ν•œ νŒ¨ν‚€μ§€μ™€ 같은 νŒ¨ν‚€μ§€μ— 정보가 λ“€μ–΄κ°€κ²Œ λœλ‹€.

import os
from setuptools import setup

here = os.path.abspath(os.path.dirname(__file__))
README = open(os.path.join(here, 'README.md')).read()

setup(
    name='Tirrilee-Contact-Form',
    version='0.1',
    packages=['Tirrilee_Contact_Form/templates','Tirrilee_Contact_Form/templatetags', 'Tirrilee_Contact_Form'],
    description='Contact Form Package From Tirrilee',
    long_description=README,
    author='Aiden',
    author_email='[email protected]',
    url='https://github.com/Tirrilee/Django-Packages/Contact-Form/',
    license='MIT',
    include_package_data=True, # html 파일
    install_requires=[
        'Django>=2.0',
    ]
)
  • name : pip install ν•  λ•Œ μ‚¬μš©λ˜μ–΄μ§€λŠ” 이름
  • version : ν•΄λ‹Ή νŒ¨ν‚€μ§€μ˜ 버전
  • packages : νŒ¨ν‚€μ§€λ₯Ό μœ„ν•΄ μƒμ„±ν•œ μ•±μ˜ 이름
  • description : νŒ¨ν‚€μ§€μ— λŒ€ν•œ 간단 μ„€λͺ…
  • long_description : README νŒŒμΌλ‘œλΆ€ν„° μ½μ–΄μ˜¨ 상세 μ„€λͺ…
  • author : νŒ¨ν‚€μ§€ μ œμž‘μž
  • author_email : νŒ¨ν‚€μ§€ μ œμž‘μž 메일
  • url : κΉƒν—™ μ£Όμ†Œ
  • license : λΌμ΄μ„ΌμŠ€ (MIT)
  • install_requires : μ‚¬μš© κ°€λŠ₯ν•œ Django 버전

setup.py νŒŒμΌμ„ λ§Œλ“€κ³ λ‚˜λ©΄, 배포할 νŒŒμΌμ„ μ§€μ •ν•˜λŠ” MANIFEST.in νŒŒμΌμ„ μƒμ„±ν•œλ‹€.

include *.txt *.ini *.cfg *.md
include Tirrilee_Contact_Form/templates/tirrilee_contact_form/*.*
recursive-include myapp *.ico *.png *.css *.gif *.jpg *.txt *.js *.html *.xml

섀정이 μ™„λ£Œλ˜λ©΄, μ•„λž˜ νŒ¨ν‚€μ§€λ“€μ„ μ„€μΉ˜ν•œλ‹€.

$ pip install setuptools wheel

setup.py 파일이 μžˆλŠ” κ²½λ‘œμ—μ„œ μ•„λž˜μ™€ 같이 μž…λ ₯ν•΄ νŒ¨ν‚€μ§•μ„ μ§„ν–‰ν•œλ‹€.

$ python3 setup.py sdist # bdist_wheel

νŒ¨ν‚€μ§•μ΄ μ’…λ£Œλ˜λ©΄ dist 폴더에 μ•„λž˜μ™€ 같이 2개의 파일이 μƒμ„±λœ 것을 확인 ν•  수 μžˆλ‹€.

dist
β”œβ”€β”€  Tirrilee-Contact-Form-0.1-py3-none-any.whl
└──  Tirrilee-Contact-Form-0.1.tar.gz   

등둝

이제 νŒ¨ν‚€μ§€λ₯Ό PyPIμ‚¬μ΄νŠΈμ— 등둝을 ν•  것 이닀. PyPIλŠ” μƒμš©μ‚¬μ΄νŠΈμ™€ ν…ŒμŠ€νŠΈμ‚¬μ΄νŠΈλ‘œ λ‚˜λˆ μ§€λ©°, μš°μ„  ν…ŒμŠ€νŠΈ μ‚¬μ΄νŠΈμ— νŒ¨ν‚€μ§€λ₯Ό μ—…λ‘œλ“œν•˜κ³  ν…ŒμŠ€νŠΈ ν•΄λ³΄λ„λ‘ν•˜μž.

$ pip install twine

twine은 νŒ¨ν‚€μ§€ μ—…λ‘œλ“œλ₯Ό λ„μ™€μ£ΌλŠ” λΌμ΄λΈŒλŸ¬λ¦¬μ΄λ‹€.

$ twine upload --repository-url https://test.pypi.org/legacy/ dist/*

μ‹€μ œ 배포 : twine upload --repository-url https://upload.pypi.org/legacy/ dist/* http 400 였λ₯˜μ‹œ : twine upload --skip-existing --repository-url https://upload.pypi.org/legacy/ dist/*

μœ„μ™€ 같이 μ—…λ‘œλ“œλ₯Ό ν•˜κ³ , ν…ŒμŠ€νŠΈ μ‚¬μ΄νŠΈμ— λ“€μ–΄κ°€λ©΄ νŒ¨ν‚€μ§€κ°€ λ“±λ‘λœ 것을 확인 ν•  수 μžˆλ‹€. Django Package Result