본문 바로가기
Python/Django

[Django] 10. Django 앱 패키징하기 (setuptools ModuleNotFoundError)

by haku-s 2024. 7. 23.
728x90

https://docs.djangoproject.com/ko/5.0/intro/reusable-apps/

 

심화 튜토리얼: 재사용 가능한 앱을 만드는 법 | Django 문서

The web framework for perfectionists with deadlines.

docs.djangoproject.com

재사용 가능한 앱을 만들기 위해 패키징 하는 방법을 익혀보는 것으로 Django의 튜토리얼은 마무리된다.

 

LICENSE 파일은 다음과 같이 사용하면 될 것 같다.

BSD 3-Clause License

Copyright (c) [YEAR], [ORGANIZATION NAME]
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation 
and/or other materials provided with the distribution.

3. Neither the name of the [ORGANIZATION NAME] nor the names of its contributors may be used to endorse 
or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

ChatGPT로 생성한 BSD-3-Clause의 Sample이다. 코드블럭으로 보기 좋지 않아, 줄 바꿈을 일부러 만들었다.

[YEAR]와 [ORGANIZATION NAME]을 맞게 수정해서 사용하면 될 것 같다.

 

setup.cfg 파일에서 작성할 django의 버전은 다음과 같이 확인할 수 있다.

django-admin --version

py -m django --version

 

 

링크의 설명대로 따라하면 이와 같은 폴더 및 파일 구조가 된다.

 

이제 마지막으로 django-polls 디렉토리에서 패키지하는 명령을 입력한다.

python setup.py sdist

 

이와 같이 django-polls-0.1.tar.gz 파일이 생성되면 올바르게 패키징이 완료 된 것이다.

 

만약 패키지 명령을 입력했는데, 다음과 같이 setuptools를 찾을 수 없는 ModuleNotFoundError가 발생하는가?

 

이는 setuptools가 설치되지 않아서 발생한 문제이다.

 

본문의 "앱 패키징" 내용  전 "필수 구성 요소 설치"란을 잘 읽어보면 setuptools를 pip 도구로 설치하라고 되어있다.

pip install setuptools

위와 같은 명령으로 setuptools를 설치해주면 패키지가 잘 된다.

 

마지막으로 새로 프로젝트를 생성하거나 polls 폴더를 다른 곳으로 이동시킨 뒤 만든 패키지를 설치하여 테스트를 해 보는 것으로 Django 튜토리얼은 마무리 된다.

 

https://docs.djangoproject.com/ko/5.0/

 

Django 문서 | Django 문서

The web framework for perfectionists with deadlines.

docs.djangoproject.com

django의 document 페이지를 보며 더 알고 싶은 부분을 찾아 가이드에 따라 학습을 이어나가면 될 것 같다.

django tutorial에 대한 포스트는 여기서 마무리 하도록 한다.


처음으로

https://haku-s.tistory.com/15

 

[Django] 1. 설치 Django Document 따라하기 (ModuleNotFoundError: No module namded 'django')

https://docs.djangoproject.com/ko/5.0/intro/ 시작하기 | Django 문서The web framework for perfectionists with deadlines.docs.djangoproject.com Django는 공식 홈페이지에 튜토리얼에 대한 Document가 잘 되어있다.잘 따라하면 문

haku-s.tistory.com

 

728x90