Generate packages from Stackoverflow answers


Keywords
packaging, stackoverflow, packaging-python, pypi, python, vendoring
License
MIT
Install
pip install so-pip==0.1.28

Documentation

so_pip

Everyone copies code from StackOverflow, but no one is formalizing it.

so_pip will vendorize the source code of question or answer into a folder and generate the files to make into a python package.

so_pip is less like a package installer and more like a project template maker, cookie cutter, vendorizing libraries and stackoverflow search cli's.

so_pip is dead, the AI version might actually be useful

Ever think, "I wish I could pip install the answer to this stackoverflow question?" You almost could with some markdown parsing and vendorizing techniques.

But too many answers were not given in the form of a function or a class, so they lack the minimal conditions for code re-use. There is no non-AI way to turn a script into a re-usable function, so this approach was always fatally flawed.

See the soon-to-be-posted "ai_pip" project that will do the same thing but use ChatGPT to transform the answer into re-usable code. This will solve previously unsolvable problems, like:

  • What code is this? Is that python or bash?
  • Is this series of markdown blocks one code file per block?
  • Is this series of markdown code blocks actually one code file with comments?
  • What is a good name for the package?
  • Is the code in the question part of the code in the answer?
  • If this code was written to be re-usable, what would it look like?
  • How do we upgrade the code to modern python?
  • Is the code malicious or buggy?
  • Where are the tests?

Badges

Libraries.io dependency status for latest release Downloads CodeFactor

Installation

Requires Python 3.11+

pip install so_pip
# or
poetry install so_pip

so_pip vendorize my_name --question=31049648 --output=output

Using via dockerhub

# for mac, unix, cmd.exe, powershell
docker pull matthewdeanmartin/so_pip
docker run --rm -i -v "$PWD/data:/data" matthewdeanmartin/so_pip --help

If you use git bash/mingw64/cygwin, see run.sh because docker needs help doing a volume mount.

Usage

Consider getting a key and adding a .so_pip.ini file The app will make best efforts if you don't.

# Turn posts into nicely formated packages
> so_pip vendorize my_name --question=31049648 | --answer=31049648
> so_pip search --answer=31049648 --tags=python

# Pip-like commands
> so_pip uninstall | upgrade {package_name}
> so_pip list | freeze

Docs