0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【初心者向け】OSS開発のはじめかた

Last updated at Posted at 2025-03-01

これからOSS開発を始める方向けにコマンドやエラーハンドリングの記録を掲載しています。

この記事でわかること
  • good first issue で見つけたOSSにコントリビュートする方法
  • fork → clone → commitまでの流れ

目次

  1. リポジトリのクローンとセットアップ
  2. 仮想環境の作成とセットアップ
  3. 変更のコミットとプッシュ
  4. エラーハンドリング
  5. 作業メモ

① リポジトリのクローンとセットアップ

1. Fork後、ローカルにClone
$ git clone https://github.com/***/Bowler.git
$ cd Bowler
$ pwd

# 出力例: /***/***/Bowler

2. upstream にオリジナルのリポジトリを登録(任意)
$ git branch 

# 出力例: * main

$ git remote add upstream https://github.com/facebookincubator/Bowler.git
$ git remote -v

# 出力例:
# origin  https://github.com/***/Bowler.git (fetch)
# origin  https://github.com/***/Bowler.git (push)
# upstream https://github.com/facebookincubator/Bowler.git (fetch)
# upstream https://github.com/facebookincubator/Bowler.git (push)

3. 最新の状態を取得
$ git checkout main
$ git pull upstream main
$ git push origin main  # フォークしたリモートリポジトリにも反映

4. 仮想環境を作成せずに始める場合(推奨)
$ make dev


② 仮想環境の作成とセットアップ(Pythonの場合)

1. 仮想環境の作成&有効化

$ python3 -m venv .venv
$ source .venv/bin/activate  # 仮想環境の有効化
# deactivate  # 仮想環境の無効化

2. 必要なセットアップ

$ make setup 
$ python setup.py develop


③ 変更のコミットとプッシュ

1. 動作確認

$ pip list | grep bowler
# 出力例: bowler 0.1.dev186+g92c9eeb.d20250228 /***/***/Bowler

$ make test  # テストの実行
$ python -m coverage report  # テストカバレッジの確認
$ make format  # コードの自動整形

2. 変更をコミット

$ git add .
$ git commit -m "Apply code formatting using isort and black"

④ エラーハンドリング
1. codecov==2.1.9 のバージョンエラー

# エラーメッセージ:
# ERROR: Could not find a version that satisfies the requirement codecov==2.1.9 (from versions: 2.1.13)
# ERROR: No matching distribution found for codecov==2.1.9

$ python -m pip install --upgrade pip
$ python -m pip install codecov --no-cache-dir
$ nano requirements-dev.txt  # 必要に応じてバージョン変更

2. setuptools のバージョンエラー

# エラーメッセージ:
# ERROR: setuptools==58.0.4 is used in combination with setuptools-scm>=8.x
# setuptools-scm requires setuptools>=61

$ python -m pip install --upgrade setuptools

3. click の ImportError
# エラーメッセージ:
# ImportError: cannot import name '_unicodefun' from 'click'

pip install --upgrade black
pip install --upgrade click

⑤ 作業メモ

1. upstream について
git pull upstream main のように使うときに必要。
git remote -v でリモートリポジトリの名前を確認すると、remote add で設定したURLリポジトリが upstream として表示される。
ちなみに、自分のリポジトリは origin

2. 仮想環境について
プロジェクトごとに独立した環境を作るときに必要。
環境を分けずに複数のPythonプロジェクトを同じ環境で開発すると、パッケージのバージョン衝突が発生しやすい。
予期せぬエラーや互換性の問題を避けるために、必ず仮想環境を作成することを推奨。

まとめ
この記事では、OSSにコントリビュートするための 基本的なコマンド操作 や エラーハンドリング についてまとめました。
実際に good first issue から始めて、 fork → clone → commit までの流れをスムーズに進められるようになることが目標です。

次のステップとして、Pull Request(PR) の作成方法やレビューの受け方 についてもまとめる予定です!






0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?