🐕
[uv]自分のgithubのRepositoryからpipできるようにする
目的:以下のように自分のprivate repoからpackageをinstallする
以下ができるようにする
# for pip with https
pip install git+https://github.com/dummy-user/my_package.git
# for pip with ssh
pip install git+ssh://git@github.com/dummy-user/my_package.git
# for uv
uv add git+https://github.com/dummy-user/my_package.git
packageの作り方
以下のようなファイル構造を作る
my_package/
│
├── my_package/ # パッケージの実装ディレクトリ
│ ├── __init__.py # パッケージ初期化ファイル
│ ├── module1.py # 任意のモジュール1
│ └── module2.py # 任意のモジュール2
├── MANIFEST.in # .py以外をinstallするときは必要
└── setup.py # パッケージの設定ファイル
init.pyの中身
from .module1 import Class_name, function_name
# 明示的に公開するAPIを文字列のリストで指定
__all__ = ["Class_name", "function_name"]
setup.pyの中身
from setuptools import setup, find_packages
setup(
name="my_package",
version="0.1.0",
packages=find_packages(include=['my_package*']), # includeを使うと明示的にたpackageの探索範囲を決めれて便利
install_requires=[],
include_package_data=True # MANIFEST.in の中に書くと*.py以外も追加できる。 なくても良い
)
MANIFEST.in
include backtesting/autoscale_cb.js # などworking dirから指定
buildしてgithubにpush
uv build
distとxxx.egg-infoというディレクトリができる。これらはpushする必要はない。
Discussion