Skip to content

development-tutorials/python-first-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python First Library

Example library for use within other Python projects

Byte size of Python First Library Open Issues Open Pull Requests Latest commits python-first-library Demos



Requirements

Python based developer dependencies may be installed via one of the following methods...

  • Scoped within current user...
pip3 install --user setuptools twine wheel
  • Scoped with a Virtual Environment local to the directory of this project...
pip3 install --user pipenv

pipenv install setuptools twine wheel

Note, review Python Guide -- virtualenvs for more information on Python Virtual Environments.

  • Or scoped for the entire system...
sudo pip3 install setuptools twine wheel

Note, generally installing dependencies system-wide is not recommended.


Quick Start

Clone this project...

Linux/MacOS

mkdir -vp ~/git/hub/development-tutorials

cd ~/git/hub/development-tutorials

git clone git@github.com:development-tutorials/python-first-library.git

Windows

set _organization_directory="%HOMEDRIVE%%HOMEPATH%\git\hub\development-tutorials"

if not exists %_organization_directory (
  md %_organization_directory
)

CD /D %_organization_directory

git clone git@github.com:development-tutorials/python-first-library.git

Usage

Note the following are abbreviated instructions, check the Tutorial site for detailed guidance.

Example of packaging this project for publishing to Pip repository...

python3 setup.py sdist bdist_wheel

Example of uploading to the testing repository...

twine upload --repository testpypi dist/python-first-library-0.0.1*

Example of installing from testing repository...

python3 -m pip install\
  --index-url https://test.pypi.org/simple/\
  --no-deps python-first-library-<YourName>

Example of inheriting and modifying a class from python-first-library...

#!/usr/bin/env python


from python_first_library import First_Library


class Customized_First_Library(First_Library):
    """
    Customizes First_Library class with additional initialization parameters
    """

    def __init__(self, custom_arg = None, **kwargs):
        """
        Adds `custom_arg` to initialization of parent First_Library class
        """
        super(Customized_First_Library, self).__init__(**kwargs)
        self.custom_arg = custom_arg

    def main(self, **kwargs):
        """
        Prints `custom_arg` and returns results from parent `main()` method
        """
        original_main_results = super(Customized_First_Library, self).main(**kwargs)

        print(original_main_results)
        print("self.custom_arg -> {}".format(self.custom_arg))

        return original_main_results


if __main__ == '__name__':
    """
    Code that is run if this file is executed as a script instead of imported
    """
    customized = Customized_First_Library(custom_arg = 'SPAM')
    customized.main()

Notes

This repository may not be feature complete and/or fully functional, Pull Requests that add needed features and/or fix bugs are certainly welcomed.


Attribution


License

Example library for use within other Python projects
Copyright (C) 2020 S0AndS0

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

For further details review full length version of AGPL-3.0 License.

About

Documentation and example library for use within other Python projects

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Languages