{ "info": { "author": "Daniel Bunzendahl", "author_email": "StudentDanBu@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# myFirstPiPy\nIgnore this package ! It is simple showing progress of learning developing reusable python modules\n\n# Steps to create your own PIP Module\n\nEach file extended by ```.py``` becomes a python module as follows:\n\n```\n#!/usr/bin/python\ndef myMethod():\n msg = \"Hello PiP\"\n print (\"MSG: {}\".format(msg))\n return msg\nmyVariable = 123\n\n```\n\nIf you want to use your file as a module\nyou simple have to import it:\n\n```\n#!/usr/bin/python\nimport myModule\nmyModule.myMethod()\n```\n\nAlso possible:\n\n```\n#!/usr/bin/python\nfrom myModule import myMethod, myVariable\nprint (\"myVariable: {}\".format(myVariable))\n\n```\n\n#Share your PiP\nTo share your module as a PIP Package everyone can install by ```pip install yourPackageName```requires a bit more structure.\nAfter registering on [PyPi.org](https://pypi.org) ([and the Test Space accont!](https://test.pypi.org/account/register/)) install an utility for publishing Python packages on PyPi:\n\n```\npip install twine\n```\n## Setup.py\nCreate a directory structure as follows and add plain files as shown:\n\n```\n/myFirstPiPy\n /myFirstPiPy\n __init__.py\n setup.py\n LICENSE\n README.md\n```\nWithin the ```__init__.py``` you can add python code to be executed while importing the module.\nThe `setup.py` requires a fixed structure you can copy and past here for customizing your needs:\n\n```\nimport setuptools\nwith open(\"README.md\", \"r\") as fh:\n long_description = fh.read()\nsetuptools.setup(\n name=\"myFirstPiPy\",\n version=\"0.0.1\",\n author=\"Daniel Bunzendahl\",\n author_email=\"StudentDanBu@gmail.com\",\n description=\"My first PiP\",\n long_description=long_description,\n long_description_content_type=\"text/markdown\",\n url=\"https://github.com/StudentESE/myFirstPiP\",\n packages=setuptools.find_packages(),\n classifiers=[\n \"Programming Language :: Python :: 3\",\n \"License :: OSI Approved :: MIT License\",\n \"Operating System :: OS Independent\",\n ],\n)\n```\n**Note:** You have to create a new Git Repository [here](https://github.com/new) and copy the URL\n\nTo generate the [wheel](https://pythonwheels.com) for native compilations and `tar.gz` for python module - just do:\n\n```\ncd myFirstPiPy\npython setup.py sdist bdist_wheel\n```\ngenerates:\n\n```\ndist/\n myFirstPiPy-0.0.1-py-none-any.whl\n myFirstPiPy-0.0.1.tar.gz\n```\n## Testdrive and Upload\nFirst we test how a submission would look like:\n\n```\ntwine upload --skip-existing --repository-url https://test.pypi.org/legacy/ dist/* \n```\nIf the result looks good for you it is time to run\n\n```\ntwine upload dist/*\n```\nWhich will publish your first PiP Package.\n\n**Note:** If you like to change files on Pypi, you need to change the version in `setup.py`. It is not possible to delete the project and reupload your local version (security reason!!)\n\n# Testing\nNow we like to go more professional and add [unittests](https://docs.python.org/3/library/unittest.html). So we add a directory where to add tests in multiple files. \n\n```\n/myFirstPiP\n /myFirstPiP\n __init__.py\n /tests\n test_var.py\n test_method.py\n setup.py\n LICENSE\n README.md\n```\n\nAll this files are executed by the command ```python -m unittest discover -s ./tests -p \"test_*\"```\n\n## Writing Tests\nTests are Classes which subclasses ```unittest.TestCase```. Each Method named `test*` within such a class will be run. The following example shows how `test_var.py` or `test_method.py` could look like merged within one file.\n\n```\nimport unittest\nimport myModule\nclass TestMyMethod(unittest.TestCase):\n def test_myMethod(self):\n self.assertEqual(myModule.myMethod(), \"Hello PiP\")\n def test_myVariable(self):\n self.assertIs(myModule.myVariable, 123)\nif __name__ == '__main__':\n unittest.main()\n```\n\n#Continuous Integration (CI)\nA very interesting solution is Travis which runs tests on Github. To enable Travis CI you need a ```.travis.yml``` after generating a ```requirements.txt```from your ```virtualenv```.\n##Virtual Environment\nFirst we need a virtual environment with only pip packages installed are realy neccessary. Based on this the generating of the ```requirements.txt``` is created.\n\n```\ncd .. # below ./myFirstPiP\nvirtualenv myFirstModuleDependencies\nsource myFirstModuleDependencies/bin/activate\ncd myFirstPiP\n```\nInstall required packages and generate the ```requirements.txt```\n\n```\npip freeze > requirements.txt\n```\n##Travis\nNow we can write the `.travis.yml` as follows:\n\n```\nlanguage: python\npython:\n - \"2.7\"\n - \"3.3\"\n - \"3.4\"\n - \"3.5\"\n - \"3.5-dev\" # 3.5 development branch\n - \"3.6\"\n - \"3.6-dev\" # 3.6 development branch\n - \"3.7-dev\" # 3.7 development branch\n# command to install dependencies\ninstall:\n - pip install -r requirements.txt\n# command to run tests\nscript:\n - python -m unittest discover -s ./tests -p \"test_*\"\n```\n\n# Git\n```\ncd ..\ngit pull\ngit add .\ngit commit -m \"Travis CI Testdrive\"\ngit push origin master\n```\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/StudentESE/myFirstPiP", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "myFirstPiPy", "package_url": "https://pypi.org/project/myFirstPiPy/", "platform": "", "project_url": "https://pypi.org/project/myFirstPiPy/", "project_urls": { "Homepage": "https://github.com/StudentESE/myFirstPiP" }, "release_url": "https://pypi.org/project/myFirstPiPy/0.0.3/", "requires_dist": null, "requires_python": "", "summary": "My first PiP", "version": "0.0.3" }, "last_serial": 4384249, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "11b640b636a4628b41d3f60b869e745c", "sha256": "1ea25bc29556b691a4c76972609c7660fbff860605176e6f02db45ee5d3329a9" }, "downloads": -1, "filename": "myFirstPiPy-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "11b640b636a4628b41d3f60b869e745c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 3457, "upload_time": "2018-10-16T22:09:38", "url": "https://files.pythonhosted.org/packages/55/ad/bbeaeb31e97d75652588b4689e514f4364f7c23d0d0b76232370a71a496a/myFirstPiPy-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a157cacb2145162db4c382342af17bb8", "sha256": "721340a142c8e558758e214d9997b157b557dcdc7c455781eb37895c5e2a0c68" }, "downloads": -1, "filename": "myFirstPiPy-0.0.1.tar.gz", "has_sig": false, "md5_digest": "a157cacb2145162db4c382342af17bb8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3294, "upload_time": "2018-10-16T22:09:41", "url": "https://files.pythonhosted.org/packages/2c/a5/a186b6ba53d69c4afce5c1a0d30193b8ad84c42ec4c0a2ba011ad80f3ee5/myFirstPiPy-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "8b7b20af4c76e9b81cf1c568cb260cff", "sha256": "c3de2048201ea61cb3e1bf08a4535993a68e3c42454d78ec68f5ac7861e3c09e" }, "downloads": -1, "filename": "myFirstPiPy-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "8b7b20af4c76e9b81cf1c568cb260cff", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 3500, "upload_time": "2018-10-16T22:09:40", "url": "https://files.pythonhosted.org/packages/3f/2b/4dd5245f40a4ae70f4b98d95216ede869cd81d3f4bdd57e0d1bee8c490b7/myFirstPiPy-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4eb7f3d7bfc89aff0e143ea51b1b1dff", "sha256": "8180c0283763d693d1845eb0de1248ef1059375bf3f718ca45772accfb730d09" }, "downloads": -1, "filename": "myFirstPiPy-0.0.2.tar.gz", "has_sig": false, "md5_digest": "4eb7f3d7bfc89aff0e143ea51b1b1dff", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3374, "upload_time": "2018-10-16T22:09:42", "url": "https://files.pythonhosted.org/packages/6e/8b/5b0d228afd389cb29c851696d0ecbfd40536f677ab739d1fc177924d651c/myFirstPiPy-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "f0d99fea6ce01655fc5514451943acb1", "sha256": "c46f952f6dc6219e993013ca114b03af02b0264d81b682cb75800f60f3156954" }, "downloads": -1, "filename": "myFirstPiPy-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "f0d99fea6ce01655fc5514451943acb1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 3653, "upload_time": "2018-10-16T22:49:16", "url": "https://files.pythonhosted.org/packages/55/89/b6a1e5b4db2f860048325faa0ea154e0934b1f0e9afea81b04db73e59830/myFirstPiPy-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5e5d0ea847fd5e865fb648d37923543d", "sha256": "9415232220cc2c3cab70c1e3e8318db233707a97d6d4b7ef1f5c31c70a8be7a1" }, "downloads": -1, "filename": "myFirstPiPy-0.0.3.tar.gz", "has_sig": false, "md5_digest": "5e5d0ea847fd5e865fb648d37923543d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3392, "upload_time": "2018-10-16T22:49:17", "url": "https://files.pythonhosted.org/packages/25/eb/d42000c5c58d460ddccc11b5e7e077f69484698b424985c3945e55b107da/myFirstPiPy-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f0d99fea6ce01655fc5514451943acb1", "sha256": "c46f952f6dc6219e993013ca114b03af02b0264d81b682cb75800f60f3156954" }, "downloads": -1, "filename": "myFirstPiPy-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "f0d99fea6ce01655fc5514451943acb1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 3653, "upload_time": "2018-10-16T22:49:16", "url": "https://files.pythonhosted.org/packages/55/89/b6a1e5b4db2f860048325faa0ea154e0934b1f0e9afea81b04db73e59830/myFirstPiPy-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5e5d0ea847fd5e865fb648d37923543d", "sha256": "9415232220cc2c3cab70c1e3e8318db233707a97d6d4b7ef1f5c31c70a8be7a1" }, "downloads": -1, "filename": "myFirstPiPy-0.0.3.tar.gz", "has_sig": false, "md5_digest": "5e5d0ea847fd5e865fb648d37923543d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3392, "upload_time": "2018-10-16T22:49:17", "url": "https://files.pythonhosted.org/packages/25/eb/d42000c5c58d460ddccc11b5e7e077f69484698b424985c3945e55b107da/myFirstPiPy-0.0.3.tar.gz" } ] }