Skip to content

Instantly share code, notes, and snippets.

@lost-theory
Created July 24, 2015 21:04
Show Gist options
  • Save lost-theory/c9d9b2e8275e803d75e3 to your computer and use it in GitHub Desktop.
Save lost-theory/c9d9b2e8275e803d75e3 to your computer and use it in GitHub Desktop.
minimal python package
$ find . -type f -name "*.py"
./setup.py
./mypkg/__init__.py
./mypkg/config.py
./mypkg/shapes/__init__.py
./mypkg/shapes/square.py
$ find . -type f -name "*.py" | xargs head -n999
==> ./setup.py <==
from setuptools import setup, find_packages
setup(
name="mypkg",
version="0.1",
packages=find_packages(),
)
==> ./mypkg/__init__.py <==
==> ./mypkg/config.py <==
SIZE = 4
==> ./mypkg/shapes/__init__.py <==
==> ./mypkg/shapes/square.py <==
from mypkg.config import SIZE
def square(size=SIZE):
edge = "*"*size
inside = "*" + " " * (size-2) + "*"
yield edge
for i in range(size-2):
yield inside
yield edge
if __name__ == "__main__":
print "\n".join(square())
$ virtualenv ~/foo-env
New python executable in /Users/stevek/foo-env/bin/python
Installing setuptools, pip...done.
$ ~/foo-env/bin/python setup.py develop
...
Finished processing dependencies for mypkg==0.1
$ ~/foo-env/bin/python mypkg/shapes/square.py
****
* *
* *
****
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment