Package: biglm
Python Package ExampleThis package was created by generally following thePackaging Python Projectswith the addition of somepipenv setupto manage virtual environments.How this package was createdInstall pipenv,build, andtwineif not already installed.create directory structure for the package like that below, whereexamplepackagefb1258is replaced with your package's name. This name must be uniquely yours when uploaded toPyPI. Better to avoid hyphens or underline characters (-or_) in the package name, as these can create problems when importing. The parent directory name (the repository name) -python-package-examplein this case - is not relevant to the package name.python-package-example/
  |____README.md
  |____LICENSE
  |____pyproject.toml
  |____tests
  |____src
    |____examplepackagefb1258
      |______init__.py
      |______main__.py
      |____wisdom.pyMake__init__.pyan empty file.Enter the text of acopyright license of your choosingintoLICENSE.Add settings inpyproject.tomlsuitable for asetuptools-based build and add metadata fields to this file - see the example in this repository.Put your own custom module code intosrc/examplepackagefb1258/wisdom.pyor whatever filename(s) you choose for the module(s) that live within your package.Optionally add a__main__.pyfile to the package directory, if you want to be able to run the package as a script from the command line, e.g.python -m examplepackagefb1258.Build the project by runningpython -m buildfrom the same directory where thepyproject.tomlfile is located.Verify that the built.tararchive has the files you expect your package to have (including any important non-code files) by running the command:tar --list -f dist/examplepackagefb1258-0.0.7.tar.gz, whereexamplepackagefb1258-0.0.7is replaced with your own package name and version.Create an account onTestPyPIwhere one can upload to a test repository instead of the production PyPI repo.Create anew API tokenon TestPyPI with the "Scope" set to “Entire account”. Save a copy of the token somewhere safe.Upload your packageto the TestPyPI repository using twine, e.g.twine upload -r testpypi dist/*twine will output the URL of your package on the PyPI website - load that URL in your web browser to see your packaged published - make sure theREADME.mdfile looks nice on the web site.Every time you change the code in your package, you will need to rebuild and reupload it to PyPI. You will need to build from a clean slate and update the version number to achieve this:delete the autogenerateddistdirectorydelete the autogeneratedsrc/*.egg-infodirectoryupdate the version number inpyproject.tomland anywhere else it is mentioned (do a find/replace)build the package again withpython -m buildupload the package again withtwine upload -r testpypi dist/*Repeat as many times as necessary until the package works as expected. Once complete, upload to the real PyPI instead of the TestPyPI repository.If updating version numbers is tedious, you may consider usingbumpver- a tool that can automate some parts of updating version numbers.How to install and use this packageTryinstalling and using your packagein a separate Python project:Create apipenv-managed virtual environment and install the latest version of your package installed:pipenv install -i https://test.pypi.org/simple/ examplepackagefb1258==0.0.7. (Note that if you've previously created apipenvvirtual environment in the same directory, you may have to delete the old one first. Find out where it is located with thepipenv --venvcommand.)Activate the virtual environment:pipenv shell.Create a Python program file that imports your package and uses it, e.g.from examplepackagefb1258 import wisdomand thenprint(wisdom.get())(replacewisdomandget()with any module name and function that exists in your package) .Run the program:python3 my_program_filename.py.Exit the virtual environment:exit.Try running the package directly:Create and activate up thepipenvvirtual environment as before.Run the package directly from the command line:python3 -m examplepackagefb1258. This should run the code in the__main__.pyfile.Exit the virtual environment.How to run unit testsSimple example unit tests are included within thetestsdirectory. To run these tests...Install pytest in a virtual environment.Run the tests from the main project directory:python3 -m pytest.Tests should never fail. Any failed tests indicate that the production code is behaving differently from the behavior the tests expect.Pro tipWhile working on the package code, and verifying it behaves as expected, it can be helpful to install the package in "editable" mode so that changes to the package are immediately updated in the virtual environment.To do this, runpipenv install -e .from the main project directory.Continuous integrationThis project has a continuous integration workflow that builds and runs unit tests automatically with everypushof the code to GitHub.