Skip to content
/ complex Public template

A simple example to illustrate coding good practice to create a python package.

License

Notifications You must be signed in to change notification settings

Advestis/complex

Repository files navigation

doc License: GPL v3

Status

pytests push-pypi push-doc

maintained issues pr

Compatibilities

ubuntu unix

python

Contact

linkedin website mail

Complex

Class implementing the notion of complex number.

This repository serves as a template for pip-installable public packages.

Installation

git clone https://github.com/Advestis/complex
cd complex
python setup.py install

Usage

from complex import Complex

znumber = Complex(3, 4)
znumber_fromstring = Complex(from_string="3+4i")
znumber_fromstring_cos = Complex(from_string="3cos(4) + 4isin(1)")
znumber_fromstring_exp = Complex(from_string="5e^3.1415926i")
znumber + znumber_fromstring
z_conj = znumber.conjugate

Use this package as a template

To make a pip-installable public Python package, follow the instructions below.

  1. Make a new blank public GitHub repository, naming it as you want.

  2. Clone complex locally, open a terminal and execute the following lines

cd <parent directory of the cloned complex repo>
mv complex <your_new_repo_name>
cd <your_new_repo_name>
rm -rf .git
git init .
rm .gitattributes
rm versioneer.py
rm complex/_version.py
git remote add origin https://github.com/your_new_repo_name
  1. Rename the project subfolder in <your_new_repo_name>

    • complex ---> your project name (no uppercase!)
  2. Modify project configuration files

    • setup.cfg :
      • Search and replace the occurences of "complex" with your new project name (no uppercase!)
      • Change the project description, author and author email
      • In [options] section, fill the contents of install_requires parameter from with what you normally put in your requirements.txt file (do not forget the indentation!) This is important, as otherwise your PyPI package will not include neither automatically install other required packages.
    • MANIFEST.in : Delete the line include complex/_version.py
    • tests/conftest.py : Delete if not needed
    • tests/test_complex.py : Rename and empty the file
    • complex/__init__.py : Empty the file
    • complex/complex.py : Rename and empty the file
    • .github/workflows/push-pypi.yml : Uncomment the end of the file (topypi step)
    • README.md :
      • Change the occurences of "complex" in the URLs at the top of the file
      • Change the rest of the file content to describe your project
  3. Install and use VERSIONEER

    • In you project directory, with a loaded virtualenv, execute :
    pip install versioneer
    versioneer install
    git tag v0.1
    • Add the line include you_package_name/_version.py to MANIFEST.in
    • Commit your modified files
    • Verify version information with python setup.py version. The version should be "v0.1"
  4. Push to master, including tags : at the bottom of PyCharm's push window, check the checkbox push tags. If using the command line, do git push -u origin master --follow-tags

  5. Protect your master branch in GitHub repository's settings, according to your needs.

  6. Make a new branch locally, push and make a PR to master to check that the CI/CD will trigger your pytests.

  7. Set GitHub pages of your repo, if you'd like.

  8. Manage your public package (repeat according to your needs)

    • Working on a local branch, fill the project subfolder with your code and modify __init__.py file in it as you wish.
    • Push and make a PR to master, then approve it (with assigned reviewers if required).
    • Merging this PR will update your public package on PyPI, putting a new subversion (0.1.1 ---> 0.1.2 etc.)

About

A simple example to illustrate coding good practice to create a python package.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages