Skip to content

Commit

Permalink
Feature: Initial command line --version
Browse files Browse the repository at this point in the history
  • Loading branch information
pylover committed Aug 26, 2024
1 parent 9f823d8 commit d84f21a
Show file tree
Hide file tree
Showing 16 changed files with 409 additions and 80 deletions.
8 changes: 8 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[run]
source = yhttp
omit =

[report]
exclude_lines =
raise NotImplementedError
pragma: no cover
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[flake8]
ignore = W503, F811
exclude =
per-file-ignores =
yhttp/markdown/__init__.py: F401
tests/conftest.py: F401
87 changes: 87 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Build

on:
push:
branches: [ master ]
tags: [ 'v*' ]

pull_request:
branches: [ master ]

jobs:
test:
name: Pytest
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']
env:
PREFIX: /usr
FLAKE8: flake8
PYTEST: pytest
COVERAGE: coverage
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo git clone https://github.com/pylover/python-makelib.git /usr/local/lib/python-makelib
make install-common editable-install
sudo cp `which bddcli-bootstrapper` /usr/local/bin
- name: Lint
run: make lint
- name: Test
run: make cover
- name: Coveralls
run: coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

coveralls-finish:
name: Coveralls finish
needs: test
runs-on: ubuntu-latest
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Install dependencies
run: python -m pip install coveralls
- name: Coveralls Finished
run: coveralls --finish
env:
GITHUB_TOKEN: ${{ secrets.PAT }}

release:
name: Github Release
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
28 changes: 28 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Deploy

on:
release:
types: [created]

jobs:
deploypypi:
name: Deploy to PyPI
runs-on: ubuntu-latest
env:
PREFIX: /usr
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Install dependencies
run: |
sudo git clone https://github.com/pylover/python-makelib.git /usr/local/lib/python-makelib
make install-common editable-install
- name: Create distributions
run: make dist
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.9
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
97 changes: 17 additions & 80 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ __pycache__/

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
Expand All @@ -19,12 +20,9 @@ lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
Expand All @@ -39,17 +37,13 @@ pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
*,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
Expand All @@ -58,8 +52,6 @@ cover/
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
Expand All @@ -69,94 +61,39 @@ instance/
.scrapy

# Sphinx documentation
docs/_build/
sphinx/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
# IPython Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid
.python-version

# SageMath parsed files
*.sage.py
# celery beat schedule file
celerybeat-schedule

# Environments
# dotenv
.env
.venv
env/

# virtualenv
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject
.idea

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/
# Vim
.*.sw[po]

# Cython debug symbols
cython_debug/
# pytest
.pytest_cache

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# project specific
apidoc
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
PKG_NAMESPACE = yhttp.markdown
PKG_NAME = yhttp-markdown
PYTEST_FLAGS = -vv
PYDEPS_COMMON = \
'bddrest >= 5.1, < 6' \
'bddcli >= 2.5.1, < 3' \
'yhttp-dev >= 3.1.3'


# Assert the python-makelib version
PYTHON_MAKELIB_VERSION_REQUIRED = 1.5.4


# Ensure the python-makelib is installed
PYTHON_MAKELIB_PATH = /usr/local/lib/python-makelib
ifeq ("", "$(wildcard $(PYTHON_MAKELIB_PATH))")
MAKELIB_URL = https://github.com/pylover/python-makelib
$(error python-makelib is not installed. see "$(MAKELIB_URL)")
endif


# Include a proper bundle rule file.
include $(PYTHON_MAKELIB_PATH)/venv-lint-test-webapi.mk
2 changes: 2 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- pretty fallback page
- github actions
1 change: 1 addition & 0 deletions activate.sh
62 changes: 62 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import os.path
import re

from setuptools import setup, find_namespace_packages


# Reading package's version (same way sqlalchemy does)
with open(
os.path.join(os.path.dirname(__file__), 'yhttp/markdown', '__init__.py')
) as v_file:
package_version = \
re.compile('.*__version__ = \'(.*?)\'', re.S)\
.match(v_file.read())\
.group(1)


dependencies = [
'yhttp >= 5.3, < 6',
'pymlconf',
'easycli'
]


setup(
name='yhttp-markdown',
version=package_version,
author='Vahid Mardani',
url='https://github.com/yhttp/markdown',
description='Markdown to HTML coverter and server with yhttp.',
long_description=open('README.md').read(),
long_description_content_type='text/markdown', # This is important!
license='APLv1',
install_requires=dependencies,
dependency_links=[
],
packages=find_namespace_packages(
where='.',
include=['yhttp.markdown'],
exclude=['tests']
),
entry_points={
'console_scripts': [
'yhttp-markdown = yhttp.markdown.main:Main.quickstart'
]
},
classifiers=[
'Environment :: Console',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'Natural Language :: English',
'Development Status :: 5 - Production/Stable',
'License :: Other/Proprietary License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3.6',
'Topic :: Software Development',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Internet :: WWW/HTTP :: WSGI :: Application',
'Topic :: Software Development :: Libraries',
'Topic :: Software Development :: Libraries :: Python Modules',
]
)
Loading

0 comments on commit d84f21a

Please sign in to comment.