티스토리 뷰

러프하게 했던 내용 기록용으로 작성

 

# 바로 쓸 수 있는 패키징 방법

> >=python2.7,<python 3.12 환경에서만 동작

> python3.12 이상의 버전에서는 소스 수정 필요

 

~~! 작성 예정

 

# python debian 패키지 만들기 (삽질기)

 

- https://github.com/astraw/stdeb에 있는 내용으로 만들 수 있음

- 사용법

  1. stdeb 패키지 설치

  2. 필요한 python의 setup.py 위치 이동

  3. stdeb 명령어 사용하여 빌드 및 패키징

 

## 이슈

 

- deb_helper가 pycompile을 dpkg postinst 스크립트 자동 생성

  - python2, 3 문법이 같이 있고 python2로 설치하면 문법에러 발생

- 아래 긴 버전에서 서술할 0.11.0에선 위 문제 해소하였으나..

  - python3.8 이상에서만 정상적으로 동작 (dirs_exist_ok=True 때문)

  - 내가 작업하는 환경은 python3.6으로 syntax error 발생

 

### 이슈 긴 버전

 

<details>

 

- deb_helper에서 생성하는 debian 폴더안의 postinst를 커스터마이징 하고 싶다.

  - python2, 3을 동시 지원하는 패키지의 경우, 분기를 통해 python3쪽 문법을 미사용함

  - 그런데, deb_helper에서 pycompile을 postinst를 자동으로 만들어서 컴파일 수행

  - 이게 전체 파일을 컴파일 하다 보니 python2에서 없는 python3 문법에서 syntax error 발생

  - 이에 dpkg fail 상태로 설치 끝남.

  - 근데 python library 설치는 잘되긴 해서 정상적으로 라이브러리 사용할 수는 있음

- 이를 해소하는 수동 방법 존재

  - 일단 stdeb로 빌드하고 만들어진 폴더 내에서 debian 내에 파일 넣고 재빌드

- 근데, debian 폴더가 setup.py와 같은 경로에 있으면 자동으로 복사해주는 0.11.0을 만든 분 등장

  - 기존 stdeb repo가 더이상 활동이 없어 새로 fork 떠져 있음

  - https://github.com/danielbisar/stdeb

 

GitHub - danielbisar/stdeb: produce Debian packages from Python packages

produce Debian packages from Python packages. Contribute to danielbisar/stdeb development by creating an account on GitHub.

github.com

- 근데.. python2.7과 python3.6에서 동작을 안함!

- 미지원하는 문법을 사용하기 때문

- 근데 충분히 범용성 있게 코드를 수정 가능해서 나도 해당 repo를 fork 떠서 PR을 했었으나, 활동이 없는 듯하여 별도로 관리 시작

  - https://github.com/DdangJin/stdeb

 

GitHub - DdangJin/stdeb: produce Debian packages from Python packages

produce Debian packages from Python packages. Contribute to DdangJin/stdeb development by creating an account on GitHub.

github.com

</details>

 

## 해소 과정

> ubuntu 18.04 기본 python3 버전은 3.6

 

- 0.11.0에 debian custom dir을 복사하기 위해 추가된 shutil.copytree은 기존 디렉토리가 있으면 에러가 발생한다.

- 하여 python3.8부터 추가되어 사용할 수 있는 인자 값인 dirs_exist_ok를 shutil.copytree에서 쓰는데 python3.6 써서 못쓴다.

- 그래서 3.12에서 사라지지만 3.6에서 쓸 수 있는 distutils.dir_util.copy_tree를 써서 해소하였다.

  - https://stackoverflow.com/questions/12683834/how-to-copy-directory-recursively-in-python-and-overwrite-all

 

How to copy directory recursively in python and overwrite all?

I'm trying to copy /home/myUser/dir1/ and all its contents (and their contents, etc.) to /home/myuser/dir2/ in python. Furthermore, I want the copy to overwrite everything in dir2/. It looks like

stackoverflow.com

## 또 다른 이슈들..

 

### python3.12 이상에서도 사용가능하게 수정

 

- python3.12에서는 distutils가 완전히 제거되어 설치가 안되는 문제 발생

- setuptools로 대체함

- 근데 인제는 setup.py를 직접 실행해서 설치하는걸 권장하지 않는다고 한다.

```

/usr/local/lib/python3.12/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` directly.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
        ********************************************************************************

!!
  self.initialize_options()
/usr/local/lib/python3.12/site-packages/setuptools/_distutils/cmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!

        ********************************************************************************
        Please avoid running ``setup.py`` and ``easy_install``.
        Instead, use pypa/build, pypa/installer or other
        standards-based tools.

        See https://github.com/pypa/setuptools/issues/917 for details.
        ********************************************************************************

!!

```

 

- 하여.. 해당 방안도 찾아보자..

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함