Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
district10 committed Dec 10, 2023
0 parents commit 968083f
Show file tree
Hide file tree
Showing 25 changed files with 648 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# this file is *not* meant to cover or endorse the use of GitHub Actions, but rather to
# help make automated releases for this project

name: Release

on:
push:
branches:
- main

jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install build dependencies
run: python -m pip install -U setuptools wheel build
- name: Build
run: python -m build .
- name: Publish
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}
skip_existing: true
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# this file is *not* meant to cover or endorse the use of GitHub Actions, but rather to
# help test this project

name: Test

on: [push, pull_request]

jobs:
test:
strategy:
matrix:
python: ['3.7', '3.8', '3.9', '3.10']
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python }}
- name: Install test dependencies
run: python -m pip install -U tox
- name: Test
run: python -m tox -e py
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# general things to ignore
build/
dist/
*.egg-info/
*.egg
*.py[cod]
__pycache__/
*.so
*~

# due to using tox and pytest
.tox
.cache
site
data/*
!data/Makefile
67 changes: 67 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# To use:
#
# pre-commit run -a
#
# Or:
#
# pre-commit install # (runs every time you commit in git)
#
# To update this file:
#
# pre-commit autoupdate
#
# See https://github.com/pre-commit/pre-commit

ci:
autoupdate_commit_msg: "chore: update pre-commit hooks"
autofix_commit_msg: "style: pre-commit fixes"

repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
exclude: ^conda\.recipe/meta\.yaml$
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: requirements-txt-fixer
- id: trailing-whitespace

# Black, the code formatter, natively supports pre-commit
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
exclude: ^(docs)

# Sort your imports in a standard form
- repo: https://github.com/PyCQA/isort
rev: 5.11.5
hooks:
- id: isort

# Upgrade older Python syntax
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.1
hooks:
- id: pyupgrade
args: ["--py36-plus"]

# Changes tabs to spaces
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.13
hooks:
- id: remove-tabs
exclude: ^(docs|Makefile)

- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear]
7 changes: 7 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
formats: all
mkdocs:
fail_on_warning: false
python:
install:
- requirements: docs/requirements.txt
19 changes: 19 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2016 The Python Packaging Authority (PyPA)

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# https://packaging.python.org/en/latest/guides/using-manifest-in/
exclude *.yaml
exclude docs
include Makefile
72 changes: 72 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
PROJECT_SOURCE_DIR ?= $(abspath ./)
PROJECT_NAME ?= $(shell basename $(PROJECT_SOURCE_DIR))

all:
@echo nothing special

lint:
pre-commit run -a
lint_install:
pre-commit install

clean:
rm -rf build dist *.egg-info __pycache__ *.pyc
force_clean:
docker run --rm -v `pwd`:`pwd` -w `pwd` -it alpine/make make clean
.PHONY: clean force_clean

tox_check:
python -m tox -e py

data_pull:
make pull -C data
data_clean:
make clean -C data

docs_build:
mkdocs build
docs_serve:
mkdocs serve -a 0.0.0.0:8088

install:
python3 -m pip install . --force --user
package:
python3 -m build
build: package
list:
unzip -l dist/cubao_pypi_example-*.whl
pypi_remote ?= testpypi
upload:
python3 -m pip install --upgrade twine
python3 -m twine upload --repository $(pypi_remote) dist/*
.PHONY: install package build upload

ci:
python -m tox -e py
.PHONY: ci

test: data_pull pytest clitest
pytest:
python3 -m pip install pytest
# pytest --capture=tee-sys tests
pytest tests -vv
clitest:
@echo not ready
.PHONY: test pytest clitest

DOCKER_TAG_WINDOWS ?= ghcr.io/cubao/build-env-windows-x64:v0.0.1
DOCKER_TAG_LINUX ?= ghcr.io/cubao/build-env-manylinux2014-x64:v0.0.1
DOCKER_TAG_MACOS ?= ghcr.io/cubao/build-env-macos-arm64:v0.0.1

test_in_win:
docker run --rm -w `pwd` -v `pwd`:`pwd` -v `pwd`/build/win:`pwd`/build -it $(DOCKER_TAG_WINDOWS) bash
test_in_mac:
docker run --rm -w `pwd` -v `pwd`:`pwd` -v `pwd`/build/mac:`pwd`/build -it $(DOCKER_TAG_MACOS) bash
test_in_linux:
docker run --rm -w `pwd` -v `pwd`:`pwd` -v `pwd`/build/linux:`pwd`/build -it $(DOCKER_TAG_LINUX) bash

# https://stackoverflow.com/a/25817631
echo-% : ; @echo -n $($*)
Echo-% : ; @echo $($*)
ECHO-% : ; @echo $* = $($*)
echo-Tab: ; @echo -n ' '
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# A sample Python project

![Python Logo](https://www.python.org/static/community_logos/python-logo.png "Sample inline image")

<!--intro-start-->

A sample project that exists as an aid to the [Python Packaging User
Guide][packaging guide]'s [Tutorial on Packaging and Distributing
Projects][distribution tutorial].

This project does not aim to cover best practices for Python project
development as a whole. For example, it does not provide guidance or tool
recommendations for version control, documentation, or testing.

[The source for this project is available here][src].

The metadata for a Python project is defined in the `pyproject.toml` file,
an example of which is included in this project. You should edit this file
accordingly to adapt this sample project to your needs.

----

This is the README file for the project.

The file should use UTF-8 encoding and can be written using
[reStructuredText][rst] or [markdown][md use] with the appropriate [key set][md
use]. It will be used to generate the project webpage on PyPI and will be
displayed as the project homepage on common code-hosting services, and should be
written for that purpose.

Typical contents for this file would include an overview of the project, basic
usage examples, etc. Generally, including the project changelog in here is not a
good idea, although a simple “What's New” section for the most recent version
may be appropriate.

[packaging guide]: https://packaging.python.org
[distribution tutorial]: https://packaging.python.org/tutorials/packaging-projects/
[src]: https://github.com/pypa/sampleproject
[rst]: http://docutils.sourceforge.net/rst.html
[md]: https://tools.ietf.org/html/rfc7764#section-3.5 "CommonMark variant"
[md use]: https://packaging.python.org/specifications/core-metadata/#description-content-type-optional

<!--intro-end-->
3 changes: 3 additions & 0 deletions cubao_pypi_example/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def main():
"""Entry point for the application script"""
print("Call your main application code here")
29 changes: 29 additions & 0 deletions cubao_pypi_example/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import os
from pprint import pprint

from loguru import logger


def hello_world(*args, **kwargs):
print("hello world")
pprint(args)
pprint(kwargs)


def list_files(dir: str = None):
if dir is None:
dir = os.path.abspath(os.path.dirname(__file__))
logger.info(f"ls {dir}")
pprint(os.listdir(dir))


if __name__ == "__main__":
import fire

fire.core.Display = lambda lines, out: print(*lines, file=out)
fire.Fire(
{
"hello_world": hello_world,
"list_files": list_files,
}
)
1 change: 1 addition & 0 deletions cubao_pypi_example/package_data.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
some data
2 changes: 2 additions & 0 deletions cubao_pypi_example/simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def add_one(number):
return number + 1
11 changes: 11 additions & 0 deletions data/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
all:
@echo use "make pull" to pull data
@echo use "make clean" to clean data

.PHONY: all pull clean
clean:
@find . -maxdepth 1 ! -name Makefile ! -name . ! -name .. -exec rm -rf {} +

eigen.png:
curl -L -o $@ https://eigen.tuxfamily.org/dox/Eigen_Silly_Professor_64x64.png
pull: eigen.png
14 changes: 14 additions & 0 deletions docs/about/license.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# License

The legal stuff.

---

## Included projects

* [pybind/pybind11](https://github.com/pybind/pybind11/blob/master/LICENSE) (BSD)
* [pybind/cmake_example](https://github.com/pybind/cmake_example/blob/master/LICENSE) (BSD)

## License (BSD)

See <https://github.com/cubao/fast-crossing/blob/master/LICENSE>.
26 changes: 26 additions & 0 deletions docs/about/release-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Release Notes

---

## Upgrading

To upgrade `cubao-pypi-example` to the latest version, use pip:

```bash
pip install -U cubao-pypi-example
```

## Version 0.0.3 (2023-04-15)

* Use flat-layout

## Version 0.0.2 (2023-04-15)

* Initial release

---

You can also checkout releases on:

- GitHub: <https://github.com/cubao/cubao-pypi-example/releases>
- PyPi: <https://pypi.org/project/cubao-pypi-example>
1 change: 1 addition & 0 deletions docs/css/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* add your css here */
Loading

0 comments on commit 968083f

Please sign in to comment.