An Interest In:
Web News this Week
- April 27, 2024
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
Packaging and Releasing (Lab 10)
For this lab, we were tasked with packaging and releasing our SSG project we've been working on all semester. Since I wrote my SSG in Python, I chose PyPI for this.
Setting up
Reading PyPI's docs, I realized that I have to do a bit of restructuring, add a new file, and install setuptools, which does the packaging.
Installing setuptools was simple:pip install setuptools
I moved the ssg
folder containing the main code into a src
folder and added a new setup.cfg
file, which is used by setuptools.
setup.cfg
[metadata]name = ssg-a-rokayversion = 1.0.4author = Ahmad Rokayauthor_email = *************description = Uses python to generate static html files from a single txt or folder of txt fileslong_description = file: README.mdlong_description_content_type = text/markdownurl = https://github.com/a-rokay/static-site-generatorproject_urls = Bug Tracker = https://github.com/a-rokay/static-site-generator/issuesclassifiers = Programming Language :: Python :: 3 License :: OSI Approved :: MIT License Operating System :: OS Independent[options]package_dir = = srcpackages = find:python_requires = >=3.6[options.packages.find]where = src
I also had to add some lines to pyproject.toml
, which tells pip
and build
what is required to build my project.
[build-system]requires = [ "setuptools>=42", "markdown", "pygments"]build-backend = "setuptools.build_meta"
Because I moved the main code into a new folder, I had to update the imports for my tests to reflect the new structure:
Packaging and releasing
Now that everything was setup, I was able to package and release.
py -m build
py -m twine upload dist/*
After creating an account on PyPI and entering my information, the project was successfully released!
To install my project, all that has to be run is:pip install ssg-a-rokay
Testing
I reached out through Slack to another student and gave them the PyPI link to have them attempt to install my project. They had zero issues and were easily able to implement my code.
Outcomes
I've always thought you had to have your project approved by some big entity to be able to install it through pip. It was very interesting to see how easy it actually is. It felt really good installing my work from PyPI and seeing another student effortlessly do too!
Original Link: https://dev.to/ar/packaging-and-releasing-lab-10-3gcl
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To