From a86c4bdac653b3901ab95939cd866772e78ac84e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Skaza?= Date: Thu, 24 Aug 2023 10:33:06 +0200 Subject: [PATCH] use poetry to build and publish, add entrypoint for pipx and recommend to use it --- .github/workflows/release.yml | 24 +++++++---------- MANIFEST.in | 6 ----- Makefile | 21 +-------------- README.md | 8 +++++- poetry.lock | 18 ++----------- pyproject.toml | 4 ++- requirements.in | 9 ------- setup.py | 49 ----------------------------------- 8 files changed, 23 insertions(+), 116 deletions(-) delete mode 100644 MANIFEST.in delete mode 100644 requirements.in delete mode 100644 setup.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 164261b..fce6723 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,5 @@ -name: Build wheels +--- +name: Build and Publish on: release: @@ -6,9 +7,7 @@ on: pull_request: types: [opened, reopened, edited, synchronize] -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "build" build: # The type of runner that the job will run on runs-on: ubuntu-latest @@ -21,31 +20,28 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - # Set up Python environment - name: Set up Python uses: actions/setup-python@v4 with: python-version: 3.11 - # Install dependencies - name: Install dependencies run: | pip install poetry poetry install - # Build wheels - - name: Build wheels - run: poetry run python setup.py sdist bdist_wheel + - name: Build package + run: poetry build - uses: actions/upload-artifact@v2 with: path: | ./dist/*.tar.gz - # Publish to pypi - - name: Publish to pypi + - name: Publish to PYPI env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - if: ${{ github.event_name == 'release' && env.TWINE_USERNAME != null }} - run: twine upload --repository pypi dist/* + PYPI_TOKEN: ${{ secrets.PYPI_PASSWORD }} + if: ${{ github.event_name == 'release' && env.PYPI_TOKEN != null }} + run: | + poetry config pypi-token.pypi "$PYPI_TOKEN" + poetry publish diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index c02efd7..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -include LICENSE -include README.md -recursive-include ctfcli/templates * -recursive-include ctfcli/utils * -recursive-include ctfcli/spec * -recursive-exclude tests * \ No newline at end of file diff --git a/Makefile b/Makefile index dc11046..2b7b4a2 100644 --- a/Makefile +++ b/Makefile @@ -11,27 +11,8 @@ format: test: pytest --cov=ctfcli tests -install: - python3 setup.py install - -build: - python3 setup.py sdist bdist_wheel - clean: - rm -rf build/ rm -rf dist/ - rm -rf ctfcli.egg-info/ rm -rf .ruff_cache + rm -rf .pytest_cache rm -f .coverage - -publish-test: - @echo "Publishing to TestPyPI" - @echo "Are you sure? [y/N] " && read ans && [ $${ans:-N} == y ] - python3 setup.py sdist bdist_wheel - twine upload --repository test dist/* - -publish-pypi: - @echo "Publishing to PyPI" - @echo "ARE YOU ABSOLUTELY SURE? [y/N] " && read ans && [ $${ans:-N} == y ] - python3 setup.py sdist bdist_wheel - twine upload --repository pypi dist/* diff --git a/README.md b/README.md index a3e08d3..55b0b16 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,13 @@ # Installation and Usage -ctfcli can be installed with `pip install ctfcli` +ctfcli can be installed with [`pipx`](https://github.com/pypa/pipx) as an executable command: + +`pipx install ctfcli` + +Alternatively, you can always install it with `pip` as a python module: + +`pip install ctfcli` ## 1. Create an Event diff --git a/poetry.lock b/poetry.lock index c26e521..598dd2f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.6.0 and should not be changed by hand. [[package]] name = "appdirs" @@ -857,21 +857,7 @@ secure = ["certifi", "cryptography (>=1.9)", "idna (>=2.0.0)", "pyopenssl (>=17. socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] zstd = ["zstandard (>=0.18.0)"] -[[package]] -name = "wheel" -version = "0.41.2" -description = "A built-package format for Python" -optional = false -python-versions = ">=3.7" -files = [ - {file = "wheel-0.41.2-py3-none-any.whl", hash = "sha256:75909db2664838d015e3d9139004ee16711748a52c8f336b52882266540215d8"}, - {file = "wheel-0.41.2.tar.gz", hash = "sha256:0c5ac5ff2afb79ac23ab82bab027a0be7b5dbcf2e54dc50efe4bf507de1f7985"}, -] - -[package.extras] -test = ["pytest (>=6.0.0)", "setuptools (>=65)"] - [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "0ef27b92e77eed597413ec6906f167d178ae6d2455d84b8e26bb1413e54e5315" +content-hash = "c1f14dcf687d5cbb09bb2f7f727befd2c08cfeeb33bb30869046f6c24672807f" diff --git a/pyproject.toml b/pyproject.toml index 1f587ce..25ae0a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,6 +5,9 @@ description = "ctfcli is a tool to manage Capture The Flag events and challenges authors = ["Kevin Chung ", "MiƂosz Skaza "] readme = "README.md" +[tool.poetry.scripts] +ctf = "ctfcli.__main__:main" + [tool.poetry.dependencies] python = "^3.8" python-frontmatter = "^1.0.0" @@ -24,7 +27,6 @@ isort = "^5.12.0" pytest = "^7.4.0" pytest-sugar = "^0.9.7" pytest-cov = "^4.1.0" -wheel = "^0.41.2" [tool.ruff] line-length = 120 diff --git a/requirements.in b/requirements.in deleted file mode 100644 index 391a586..0000000 --- a/requirements.in +++ /dev/null @@ -1,9 +0,0 @@ -cookiecutter==2.1.1 -click==7.0 -fire==0.2.1 -PyYAML>=6.0.1 -Pygments==2.7.4 -requests==2.28.1 -colorama==0.4.6 -appdirs==1.4.3 -python-frontmatter==1.0.0 diff --git a/setup.py b/setup.py deleted file mode 100644 index 5bd6f9d..0000000 --- a/setup.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- -import os -import re - -try: - from setuptools import find_packages, setup -except ImportError: - from distutils.core import find_packages, setup - - -with open("ctfcli/__init__.py") as f: - version = re.search(r'__version__ = "(.*?)"', f.read()).group(1) - - -def read(fname): - try: - with open(os.path.join(os.path.dirname(__file__), fname), "r") as fp: - return fp.read().strip() - except IOError: - return "" - - -setup( - name="ctfcli", - version=version, - author="Kevin Chung", - author_email="kchung@ctfd.io", - license="Apache 2.0", - description="Tool for creating and running Capture The Flag competitions", - long_description=read("README.md"), - long_description_content_type="text/markdown", - keywords=["ctf"], - classifiers=[], - zip_safe=False, - install_requires=[ - "cookiecutter==2.3.0", - "click==8.1.6", - "fire==0.5.0", - "pyyaml==6.0.1", - "Pygments==2.16.1", - "requests==2.31.0", - "colorama==0.4.6", - "appdirs==1.4.4", - "python-frontmatter==1.0.0", - ], - packages=find_packages(exclude=["tests", "tests.*"]), - include_package_data=True, - entry_points={"console_scripts": ["ctf = ctfcli.__main__:main"]}, -)