Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP621 적용 #228

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

PEP621 적용 #228

wants to merge 17 commits into from

Conversation

phi-friday
Copy link
Contributor

@phi-friday phi-friday commented Aug 16, 2024

closes: #225

패키징 및 배포 도구로 선택된 uv 사용 방법

상세한 문서: 공식문서

설치

linux or mac

curl -LsSf https://astral.sh/uv/install.sh | sh

windows

powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

pipx를 사용한 설치

pipx install uv

개발 환경 구축

파이썬 버전 설정

uv python pin <사용하고자 하는 파이썬 버전>

ex: uv python pin 3.12, uv python pin 3.11.5

의존성 동기화

uv sync

동기화된 파이썬 환경 사용
  • 쉘 환경 진입시
    source .venv/bin/activate
  • 단일 스크립트 실행시
    uv run python <실행하고자 하는 스크립트>

빌드

Note

build 명령어를 공식 지원할 예정이나, 당장은 uvx를 사용해야합니다.

build 명령어에 대한 pr이 최근 추가됐습니다. astral-sh/uv#6895
build 명령어를 v0.4.5부터 사용할 수 있습니다.

wheel, sdist

uvx --from build pyproject-build --installer uv
uv build

only wheel

uvx --from build pyproject-build --installer uv --wheel
uv build --wheel

only sdist

uvx --from build pyproject-build --installer uv --sdist
uv build --sdist

배포

Note

publish 명령어를 공식 지원할 예정이나, 당장은 uvx를 사용해야합니다.

uvx twine upload dist/* -u __token__ -p <pypi 배포시 사용되는 토큰>

TODO:

  • 기존 사용중이던 패키징 관련 파일 준수(setup.py , setup.cfg , MANIFEST.in , requirements.txt 반영 완료)
  • 패키징 및 배포 도구 선정(rye로 결정됨 uv로 변경됨)
  • 지원 파이썬 버전 구체화

pypiwhl파일을 확인 했을 때 3.5+로 작성되어 있으므로, 우선 3.5+로 작성하였음

추가1. 3.8 이상 지원 고려중이며, 적정 버전에 대한 논의가 진행중이므로, 임시 3.9+로 변경하였음.

추가2. 약 2주간 기타 의견이 없으므로 3.9를 유지하고, draft 상태를 종료

  • 의존성 목록 구체화(필수 의존성으로 plotly, beautifulsoup4 추가)

pypiwhl파일을 확인 했을 때, 다음과 같은 의존성을 확인할 수 있었음

Requires-Dist: pandas (>=0.19.2)
Requires-Dist: requests (>=2.3.0)
Requires-Dist: requests-file
Requires-Dist: lxml
Requires-Dist: tqdm

하지만 라이브러리를 실제로 사용할 때, plotlybs4가 필요 한 것으로 보이므로,
관련 내용 수정할 필요가 있음

추가1. 수정하였음.

목표:

  1. PEP621 준수
  2. 기존 패키징 결과물과 동일하거나, 동일하게 사용 가능한 결과물 확인

@geesecross
Copy link

안녕하세요! pyproject.toml 도입이 된다니 기쁩니다.

잠깐 훑어보다가 bs4를 의존성으로 추가하신 걸 발견했는데, bs4는 dummy package라서 beautlfulsoup4를 사용하시는 게 더 정확하겠습니다.

This is a dummy package designed to prevent namesquatting on PyPI. You should install beautifulsoup4 instead.

@phi-friday
Copy link
Contributor Author

안녕하세요! pyproject.toml 도입이 된다니 기쁩니다.

잠깐 훑어보다가 bs4를 의존성으로 추가하신 걸 발견했는데, bs4는 dummy package라서 beautlfulsoup4를 사용하시는 게 더 정확하겠습니다.

This is a dummy package designed to prevent namesquatting on PyPI. You should install beautifulsoup4 instead.

확인 감사합니다. 수정했습니다.

@phi-friday
Copy link
Contributor Author

phi-friday commented Aug 16, 2024

@FinanceData
plotly의 경우 ModuleNotFoundError로 따로 처리하신 것으로 봤을 때,
chart 기능을 사용할 때만 에러가 발생하는 것을 의도하신게 맞을까요?
현재는 최상위 폴더의 __init__.py에서 char 모듈이 임포트돼서, plotly가 필수 의존성에 포함되어야 할 것 같습니다.
만약 chart 기능을 사용할 때만 에러가 발생하는 것을 의도하셨다면,
이 pr이 병합 된 이후 별도의 pr을 통해 따로 요청드리겠습니다.

@phi-friday phi-friday force-pushed the chore-pep621 branch 2 times, most recently from 6b029f3 to 926f726 Compare August 18, 2024 23:59
@phi-friday
Copy link
Contributor Author

phi-friday commented Aug 19, 2024

@FinanceData
#225 에서 공유해주신 setup.py, setup.cfg, MANIFEST.in, requirements.txt를 토대로 pyproject.toml을 수정했습니다.
다만 아직 확인이 필요한 부분이 있습니다.

  1. setup.pysetup.cfg에 정의된 classifierspypi에 배포되어 있는 패키지의 지원 파이썬 버전이 다릅니다. 지원하고자 하는 파이썬 버전이 정확하게 어떤 버전인가요? 현재 파이썬은 3.8 이전 버전은 EOL상태이니 참고부탁드립니다.
  • pypi에서 >=3.5로 표시되며, 실제 패키지의 dist-info/METADATA에도 >=3.5로 되어있습니다.
  • 3.8 또한 2024.10 이후 지원 종료 예정입니다.
  • 앞서 말씀드린 plotly와 관련된 chart 모듈의 지연 로딩 기능>=3.7부터 사용 가능합니다.
  1. MANIFEST.in에 지정된 LICENSE.txt파일이 존재하지 않습니다. 추가 예정이신가요?
  2. pypi에 배포된 패키지에는 FinanceDataReader-backup 경로가 포함됩니다. 이 경로는 어떤 이유로 추가된 것인지 확인 가능하실까요? 그리고 앞으로도 추가되어야 하는 경로가 맞나요?

위 3가지에 대해 확인 부탁드립니다.

추가1.
기존 메타데이터와 수정사항이 반영된 메타데이터는 다음과 같으니 참고부탁드립니다.

기존

Metadata-Version: 2.1
Name: finance-datareader
Version: 0.9.93
Summary: Financial data reader (price, stock list of markets)
Home-page: https://github.com/financedata/financedatareader
Author: FinanceData.KR
Author-email: plusjune@financedata.kr
License: MIT License
Keywords: data,finance
Requires-Python: >=3.5
Requires-Dist: pandas (>=0.19.2)
Requires-Dist: requests (>=2.3.0)
Requires-Dist: requests-file
Requires-Dist: lxml
Requires-Dist: tqdm

신규

Metadata-Version: 2.3
Name: finance-datareader
Version: 0.9.93
Summary: Financial data reader (price, stock list of markets)
Project-URL: Repository, https://github.com/financedata/financedatareader
Author-email: "FinanceData.KR" <plusjune@financedata.kr>
Maintainer-email: "FinanceData.KR" <plusjune@financedata.kr>
License: MIT License
Keywords: data,finance
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Cython
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.5
Requires-Dist: beautifulsoup4
Requires-Dist: lxml
Requires-Dist: pandas>=0.19.2
Requires-Dist: plotly
Requires-Dist: requests-file
Requires-Dist: requests>=2.3.0
Requires-Dist: tqdm
Provides-Extra: docs
Requires-Dist: sphinx; extra == 'docs'
Provides-Extra: notebook
Requires-Dist: ipykernel; extra == 'notebook'
Requires-Dist: nbformat>=4.2.0; extra == 'notebook'
Provides-Extra: test
Requires-Dist: pytest; extra == 'test'
Description-Content-Type: text/markdown
(README 내용 후략)

추가2.
현재 build 명령어 실행 시 다음과 같이 패키지가 생성되니 참고부탁드립니다.

dist

❯ ls -algo dist
total 200
drwxr-xr-x@  5     160  8 19 09:35 .
drwxr-xr-x@ 20     640  8 19 08:59 ..
-rw-r--r--@  1    8196  8 19 09:15 .DS_Store
-rw-r--r--   1   51738  8 19 09:35 finance_datareader-0.9.93-py3-none-any.whl
-rw-r--r--   1   34122  8 19 09:35 finance_datareader-0.9.93.tar.gz

finance_datareader-0.9.93.tar.gz

❯ tree
.
├── PKG-INFO
├── README.md
├── pyproject.toml
└── src
    └── FinanceDataReader
        ├── __init__.py
        ├── _utils.py
        ├── back_chart.py
        ├── chart
        │   ├── __init__.py
        │   ├── candle.py
        │   └── plot.py
        ├── data.py
        ├── ecos
        │   ├── __init__.py
        │   ├── data.py
        │   └── snap.py
        ├── fred
        │   ├── __init__.py
        │   └── data.py
        ├── investing
        │   ├── __init__.py
        │   ├── data.py
        │   └── listing.py
        ├── krx
        │   ├── __init__.py
        │   ├── data.py
        │   ├── listing.py
        │   └── snap.py
        ├── nasdaq
        │   ├── __init__.py
        │   └── listing.py
        ├── naver
        │   ├── __init__.py
        │   ├── data.py
        │   ├── listing.py
        │   └── snap.py
        ├── wikipedia
        │   ├── __init__.py
        │   └── listing.py
        └── yahoo
            ├── __init__.py
            └── data.py

12 directories, 32 files

finance_datareader-0.9.93-py3-none-any.whl

❯ tree
.
├── FinanceDataReader
│   ├── __init__.py
│   ├── _utils.py
│   ├── back_chart.py
│   ├── chart
│   │   ├── __init__.py
│   │   ├── candle.py
│   │   └── plot.py
│   ├── data.py
│   ├── ecos
│   │   ├── __init__.py
│   │   ├── data.py
│   │   └── snap.py
│   ├── fred
│   │   ├── __init__.py
│   │   └── data.py
│   ├── investing
│   │   ├── __init__.py
│   │   ├── data.py
│   │   └── listing.py
│   ├── krx
│   │   ├── __init__.py
│   │   ├── data.py
│   │   ├── listing.py
│   │   └── snap.py
│   ├── nasdaq
│   │   ├── __init__.py
│   │   └── listing.py
│   ├── naver
│   │   ├── __init__.py
│   │   ├── data.py
│   │   ├── listing.py
│   │   └── snap.py
│   ├── wikipedia
│   │   ├── __init__.py
│   │   └── listing.py
│   └── yahoo
│       ├── __init__.py
│       └── data.py
└── finance_datareader-0.9.93.dist-info
    ├── METADATA
    ├── RECORD
    └── WHEEL

12 directories, 32 files

추가3.
rye 사용법에 대한 간략한 설명과 링크를 pr 설명란에 추가하였으니 참고부탁드립니다.

@FinanceData
Copy link
Owner

아래와 같이 정리 드립니다.

  1. 지원가능한 가장 낮은 버전을 고수하고 있었습니다. 하지만, 지금은 파이썬 지원은 3.8 혹은 그 이상이 되어도 좋을 것 같습니다. 적정한 버전에 대해 의견을 주시면 최대한 수용하겠습니다.
  2. LICENSE.txt 추가 예정입니다. (추가하더라고 MIT를 그대로 혹은 MIT에 준하는 내용으로 예정하고 있습니다)
  3. FinanceDataReader-backup 는 이제 필요하지 않습니다.

@phi-friday
Copy link
Contributor Author

아래와 같이 정리 드립니다.

  1. 지원가능한 가장 낮은 버전을 고수하고 있었습니다. 하지만, 지금은 파이썬 지원은 3.8 혹은 그 이상이 되어도 좋을 것 같습니다. 적정한 버전에 대해 의견을 주시면 최대한 수용하겠습니다.

3.8이 곧 지원 종료되는 만큼, 3.9이상으로 제한하시면 좋을 것 같습니다.

  1. LICENSE.txt 추가 예정입니다. (추가하더라고 MIT를 그대로 혹은 MIT에 준하는 내용으로 예정하고 있습니다)

추가 후, pyproject.tomllicense항목에 file 속성을 추가하시면 됩니다.

  1. FinanceDataReader-backup 는 이제 필요하지 않습니다.

확인하였습니다.

말씀주신 내용 토대로 초안 수정하여 다시 푸쉬하겠습니다.
또한 #225 에서 말씀주신대로, rye에서 uv로 변경 후 진행하겠습니다.
이와 관련하여 패키징 및 배포 관련 변경이 있을 예정입니다.

@phi-friday
Copy link
Contributor Author

@FinanceData
#225 에서 말씀주신대로 uv를 사용하는 방향으로 수정하였습니다.
pr의 설명에도 사용법에 대해 업데이트하였으니 참고바랍니다.

또한 지원 파이썬 버전을 3.9로 변경했습니다.
임시로 변경한 것으로, 이후 다른 버전에 대해 말씀주신다면 수정하겠습니다.

마지막으로, 파이썬 버전이 상향됨에 따라,
pandas의 최소 버전을 1.1로 수정했습니다.
pandas>=1.1부터 3.9를 지원하기 때문에 수정한 사항으로, 만약 3.8로 변경된다면 1.0으로 수정하겠습니다.

@phi-friday phi-friday marked this pull request as ready for review September 7, 2024 05:27
@phi-friday
Copy link
Contributor Author

@FinanceData
추가적인 조정(지원 파이썬 버전 조정 등)이 없다면 이 pr에서 더 수정할 사항은 없어보입니다.
확인가능하실까요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PEP 621를 적용할 의향이 있으신가요
3 participants