Giter VIP home page Giter VIP logo

piptest's Introduction

piptest

自作パッケージ(モジュール)を GitHub 経由で pip install するサンプルプログラム。

PyPi に公開したくない自作モジュールを作ることはよくあります。

この piptest をGitHub経由でインストールして、モジュール呼び出しするサンプルプログラムです。

動作確認済み:Python3.8

使い方

適当な作業フォルダ sandbox を作成します。

この sandbox フォルダ直下で、以下のどれかのコマンドを実行してインストールします。

  • pip install git+https://github.com/taketakeyyy/piptest.git -t mylib

    • sandbox 直下に mylib というフォルダが作成され、そこに piptest パッケージがインストールされます。
  • pip install git+https://github.com/taketakeyyy/piptest.git

    • システムに piptest パッケージがインストールされます。

piptestを使ってみる

sandbox 直下に、以下のrun.pyを作成します。

# -*- coding: utf-8 -*-

# mylib フォルダにインストールした場合、パスを通す
import sys
sys.path.append('mylib')

# piptest パッケージ内のモジュールを import する
from piptest import call
from piptest import Dog
from piptest import __author__
from piptest import __url__
from piptest import __version__

if __name__ == "__main__":
    call()  # Hello, here is pip test.

    dog = Dog("Taro")
    dog.bark()  # Bow! Bow name is Taro!

    print("===[piptest info]===")
    print(f"author:{__author__}")
    print(f"url:{__url__}")
    print(f"version:{__version__}")

これを実行してみます。

> python run.py
Hello, here is pip test.
Bow! Bow name is Taro!
===[piptest info]===
author:taketakeyyy
url:https://github.com/taketakeyyy/piptest
version:0.1.0

piptestcall(), dog.bark() のモジュールや、パッケージ情報が呼び出せました。

piptestのアップデート

piptest に変更を加えてアップデートしたとします。

一般に、パッケージのアップデートは以下のコマンドで行います。

> pip install --upgrade [パッケージ名]

なので、 piptest をアップデートしたい場合は以下のコマンドを使います。

# mylib にインストールした場合
> pip install --upgrade git+https://github.com/taketakeyyy/piptest.git -t mylib
# システムにインストールした場合
> pip install --upgrade git+https://github.com/taketakeyyy/piptest.git

参考

piptest's People

Contributors

taketakeyyy avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.