Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

Commit ad3e9c1

Browse files
author
John Andersen
committed
Initial Commit
Signed-off-by: John Andersen <john.s.andersen@intel.com>
0 parents  commit ad3e9c1

15 files changed

+334
-0
lines changed

.ci/pages.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
python3 -m pip install --prefix=${HOME}/.local/ -e .[dev]
4+
export PATH="${HOME}/.local/bin:${PATH}"
5+
sphinx-build -b html docs pages

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*__pycache__/
2+
*.swp
3+
*.pyc
4+
*.egg-info/
5+
pages/

README.md

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Example Project for Python\*
2+
3+
This is an example repo to show you how to create a Python package which can be
4+
published on PiPy. It also includes documentation generation and CI scripts you
5+
can copy.
6+
7+
## Install From Git Repo
8+
9+
```console
10+
$ python3 -m pip install --user git+https://github.com/intel/project-example-for-python
11+
```
12+
13+
## Install For Development
14+
15+
```console
16+
$ git clone https://github.com/intel/project-example-for-python
17+
$ python3 -m pip install --user -e .[dev]
18+
```
19+
20+
## Usage
21+
22+
```console
23+
$ export PATH="${HOME}/.local/bin:${PATH}"
24+
$ script
25+
SCRIPT!
26+
$ scriptscript
27+
SCRIPTSCRIPT!
28+
$ ufb
29+
It's a bird it's a plane!
30+
NO! It's a SCRIPT!!
31+
```
32+
33+
## Docs
34+
35+
```console
36+
$ sphinx-build -b html docs pages
37+
$ (cd pages && python3 -m http.server 4444)
38+
```
39+
40+
## Legal
41+
42+
> This software is subject to the U.S. Export Administration Regulations and
43+
> other U.S. law, and may not be exported or re-exported to certain countries
44+
> (Cuba, Iran, Crimea Region of Ukraine, North Korea, Sudan, and Syria) or to
45+
> persons or entities prohibited from receiving U.S. exports (including
46+
> Denied Parties, Specially Designated Nationals, and entities on the Bureau
47+
> of Export Administration Entity List or involved with missile technology or
48+
> nuclear, chemical or biological weapons).
49+
50+
> \*Other names and brands may be claimed as the property of others.

docs/autogenerated.rst

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Autogenerated Docs
2+
==================
3+
4+
These docs are autogenerated. Only functions with docstrings will be here! All
5+
classes get added even if they don't have docstrings.
6+
7+
.. automodule:: example_project_for_python.importable
8+
:members:
9+
:undoc-members:
10+
11+
.. automodule:: example_project_for_python.aclass
12+
:members:
13+
:undoc-members:

docs/conf.py

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# http://www.sphinx-doc.org/en/master/config
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
import os
14+
import sys
15+
from unittest.mock import patch
16+
17+
# Copy pasting be gone!
18+
sys.path.insert(0, os.path.abspath(".."))
19+
20+
with patch("setuptools.setup"):
21+
from setup import ORG, IMPORT_NAME, DESCRIPTION, VERSION, AUTHOR_NAME
22+
23+
24+
# -- Project information -----------------------------------------------------
25+
26+
project = IMPORT_NAME
27+
copyright = "2019, Intel Corperation"
28+
author = AUTHOR_NAME
29+
30+
# The short X.Y version
31+
version = VERSION
32+
33+
# The full version, including alpha/beta/rc tags
34+
release = VERSION
35+
36+
37+
# -- General configuration ---------------------------------------------------
38+
39+
# Add any Sphinx extension module names here, as strings. They can be
40+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
41+
# ones.
42+
extensions = [
43+
"sphinx.ext.autodoc",
44+
"sphinx.ext.viewcode",
45+
"sphinx.ext.intersphinx",
46+
"sphinxcontrib.asyncio",
47+
]
48+
49+
intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
50+
51+
# Add any paths that contain templates here, relative to this directory.
52+
templates_path = ["_templates"]
53+
54+
# List of patterns, relative to source directory, that match files and
55+
# directories to ignore when looking for source files.
56+
# This pattern also affects html_static_path and html_extra_path.
57+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
58+
59+
# -- Options for HTML output -------------------------------------------------
60+
61+
# The theme to use for HTML and HTML Help pages. See the documentation for
62+
# a list of builtin themes.
63+
#
64+
html_theme = "sphinx_rtd_theme"
65+
66+
# Add any paths that contain custom static files (such as style sheets) here,
67+
# relative to this directory. They are copied after the builtin static files,
68+
# so a file named "default.css" will overwrite the builtin "default.css".
69+
html_static_path = ["_static"]
70+
71+
# -- Extension configuration -------------------------------------------------

docs/index.rst

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Project Example For Python Documentation
2+
=========================
3+
4+
Here's all the things these docs know about
5+
6+
.. Here's a note, you won't see it rendered
7+
8+
.. The toctree is the main table of contents for this site, don't add the .rst
9+
suffix to your entries here
10+
11+
.. toctree::
12+
:maxdepth: 2
13+
:caption: Contents:
14+
15+
autogenerated
16+
rst
17+
18+
.. This is a reference, it can help you link sections across docs
19+
20+
.. _feedface:
21+
22+
Hi I'm a subheader
23+
------------------
24+
25+
This is some text

docs/rst.rst

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Restructured Text Examples
2+
==========================
3+
4+
- Yo
5+
6+
- Yo
7+
8+
- Yo
9+
10+
- This
11+
12+
- Is a list
13+
14+
.. With rst you MUST put empty lines between entries in lists
15+
16+
I'm a link to the :doc:`autogenerated` docs page.
17+
18+
I'm a link to the :ref:`feedface` section.
19+
20+
I'm a link to `an awesome open source project <https://intel.github.io/dffml>`_
21+
22+
This is a link to a method :meth:`project_example_for_python.aclass.MiscClass.load`
23+
24+
This is a link to a class :class:`project_example_for_python.importable.SomeClass`
25+
26+
.. code-block:: python
27+
28+
def im(some):
29+
python = "code"
30+
when_in.vim("I'm auto highlighted as Python code within the rst file")

project_example_for_python/__init__.py

Whitespace-only changes.

project_example_for_python/aclass.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class MiscClass:
2+
3+
@classmethod
4+
def load(cls1):
5+
"""
6+
I heard you like classmethods so I put a classmethod in your
7+
classmethod dawg
8+
"""
9+
class MyClass:
10+
@classmethod
11+
def classception(cls2):
12+
return type("NewClass", (cls1, cls2,), {"FEED": "FACE"})
13+
return MyClass

project_example_for_python/cli.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from .importable import outer_script
2+
3+
def SCRIPT():
4+
print('SCRIPT!')
5+
6+
def import_SCRIPT():
7+
outer_script()
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def SCRIPTSCRIPT():
2+
print('SCRIPT SCRIPT!')
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
def outer_script():
2+
"""
3+
Are we alone in the universe? Only NASA knows, and if they tell you they
4+
have to kill you. I don't make the rules the aliens do.
5+
6+
>>> scotty.beam(me, "up")
7+
"""
8+
print('It\'s a bird it\'s a plane!')
9+
print('NO! It\'s a SCRIPT!!')
10+
11+
12+
class SomeClass:
13+
14+
def hello(self):
15+
"""
16+
This class is useful
17+
"""
18+
return "I swear"

project_example_for_python/inner/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Example of relative imports
2+
from ..aclass import MiscClass

setup.py

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import os
2+
import sys
3+
import pathlib
4+
from setuptools import setup
5+
6+
ORG = "intel"
7+
NAME = "project-example-for-python"
8+
DESCRIPTION = "A short desciption of your project"
9+
VERSION = "1.33.7"
10+
AUTHOR_NAME = "You Name Here!"
11+
AUTHOR_EMAIL = "some.body@once.toldme"
12+
13+
SELF_PATH = os.path.dirname(os.path.abspath(__file__))
14+
15+
README = pathlib.Path(SELF_PATH, "README.md").read_text()
16+
17+
# Folders on disk for Python packages must be _ and not -
18+
IMPORT_NAME = NAME.replace("-", "_")
19+
20+
setup(
21+
name=NAME,
22+
version=VERSION,
23+
description=DESCRIPTION,
24+
long_description=README,
25+
# long_description_content_type is needed to make non-rst readmes display
26+
# correctly in PyPi, if you see a warning saying something like "I don't
27+
# know what this means" don't listen to it, it lies, it does know what this
28+
# means and if you have a .md README then you need to keep this line.
29+
long_description_content_type="text/markdown",
30+
author=AUTHOR_NAME,
31+
author_email=AUTHOR_EMAIL,
32+
url='https://github.com/{}/{}'.format(ORG, NAME),
33+
license='MIT',
34+
35+
keywords=[
36+
'this',
37+
'is',
38+
'where',
39+
'searchable',
40+
'keywords',
41+
'go',
42+
],
43+
44+
# Your package will fail to upload if you don't abide by these dude!:
45+
# https://pypi.org/classifiers/
46+
classifiers=[
47+
'Development Status :: 4 - Beta',
48+
'Intended Audience :: Developers',
49+
'License :: OSI Approved :: MIT License',
50+
'License :: OSI Approved :: Apache Software License',
51+
'Natural Language :: English',
52+
'Operating System :: OS Independent',
53+
# You must list all the version of Python that you want to allow to
54+
# download your package here. If you don't list it, users trying to pip
55+
# install it won't be able to get it from PyPi
56+
'Programming Language :: Python :: 3.6',
57+
'Programming Language :: Python :: 3.7',
58+
'Programming Language :: Python :: 3.8',
59+
'Programming Language :: Python :: Implementation :: CPython',
60+
'Programming Language :: Python :: Implementation :: PyPy',
61+
],
62+
63+
# Dependencies got here aka install_requires=['dffml']
64+
install_requires=[],
65+
# Dependencies only needed for running your tests go here
66+
tests_require=[],
67+
# If you include data files in your repo, you probably want the following
68+
# two lines
69+
include_package_data=True,
70+
zip_safe=False,
71+
# Install development dependencies with
72+
# pip install folder_containing_this_setup_py[dev]
73+
extras_require={
74+
"dev": [
75+
"coverage",
76+
"codecov",
77+
"sphinx",
78+
"sphinxcontrib-asyncio",
79+
"black",
80+
"sphinx_rtd_theme",
81+
],
82+
},
83+
# Python's plugin system, console_scripts says make command line utilities
84+
# out of these functions, note the `python.path : obj_in_file` syntax.
85+
# Don't forget the `:`!
86+
entry_points={
87+
'console_scripts': [
88+
'script = {}.cli:SCRIPT'.format(IMPORT_NAME),
89+
'scriptscript = {}.cli_again:SCRIPTSCRIPT'.format(IMPORT_NAME),
90+
'ufb = {}.cli:import_SCRIPT'.format(IMPORT_NAME),
91+
],
92+
},
93+
)

0 commit comments

Comments
 (0)