diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e06728f..8e719a4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,12 +1,19 @@ +name: build + on: push: - branches: [ master ] + branches: + - main + - 'dev/**' pull_request: - branches: [ master ] + branches: [ main ] release: types: - published + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + jobs: lint: runs-on: ubuntu-latest @@ -15,7 +22,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: "3.10" - name: Install dependencies run: | @@ -30,10 +37,10 @@ jobs: pylint --rcfile test/pylint.rc gitmetheurl #------------------------------------------------------------------------------- - build_sdist: + build: needs: - lint - name: Build source distribution + name: Build distributions runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -41,21 +48,30 @@ jobs: - uses: actions/setup-python@v4 name: Install Python with: - python-version: 3.8 + python-version: "3.10" + + - name: Install dependencies + run: | + python -m pip install -U build - - name: Build sdist - run: python setup.py sdist + - name: Build + run: python -m build - uses: actions/upload-artifact@v3 with: - path: dist/*.tar.gz + path: | + dist/*.tar.gz + dist/*.whl #------------------------------------------------------------------------------- deploy: needs: - - build_sdist + - build runs-on: ubuntu-latest + environment: release + permissions: + id-token: write # Only publish when a GitHub Release is created. if: github.event_name == 'release' @@ -66,6 +82,3 @@ jobs: path: dist - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.pypi_password }} diff --git a/README.md b/README.md index 6eb8761..5c40623 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/git-me-the-url.svg)](https://pypi.org/project/git-me-the-url) -[![build](https://github.com/amykyta3/git-me-the-url/actions/workflows/build.yml/badge.svg)](https://github.com/amykyta3/git-me-the-url/actions?query=workflow%3Abuild+branch%3Amaster) +[![build](https://github.com/amykyta3/git-me-the-url/actions/workflows/build.yml/badge.svg)](https://github.com/amykyta3/git-me-the-url/actions?query=workflow%3Abuild+branch%3Amain) # Git me the URL! diff --git a/gitmetheurl/base.py b/gitmetheurl/base.py index fe52784..d64299c 100644 --- a/gitmetheurl/base.py +++ b/gitmetheurl/base.py @@ -64,7 +64,7 @@ def get_source_url(self, path: str, line: "Optional[Union[int, Tuple[int, int]]] return translator.get_source_url(remote, info) - @functools.lru_cache(maxsize=None) + @functools.lru_cache() def _get_target_info(self, path:str, exact_commit: bool = False) -> 'Tuple[str, dict]': """ Collects relevant Git information about the target path. @@ -111,7 +111,7 @@ def _get_target_info(self, path:str, exact_commit: bool = False) -> 'Tuple[str, return remote, info - @functools.lru_cache(maxsize=None) + @functools.lru_cache() def _lookup_translator(self, remote:str) -> 'Optional[Type[TranslatorSpec]]': for t in self.translators: if t.is_match(remote): diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f2d8ecb --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,47 @@ +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" + +[project] +name = "git-me-the-url" +dynamic = ["version"] +requires-python = ">=3.5" +dependencies = [ + "gitpython", +] + +authors = [ + {name="Alex Mykyta"}, +] +description = "Generate sharable links to your Git source" +readme = "README.md" +license = {file = "LICENSE"} +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3 :: Only", + "Intended Audience :: Developers", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Operating System :: OS Independent", + "Topic :: Software Development :: Version Control :: Git", +] + +[project.urls] +Source = "https://github.com/amykyta3/git-me-the-url" +Tracker = "https://github.com/amykyta3/git-me-the-url/issues" +Changelog = "https://github.com/amykyta3/git-me-the-url/releases" + +[tool.setuptools.dynamic] +version = {attr = "gitmetheurl.__about__.__version__"} + +[project.scripts] +gitmetheurl = "gitmetheurl.cmd:main" diff --git a/setup.py b/setup.py deleted file mode 100644 index e760132..0000000 --- a/setup.py +++ /dev/null @@ -1,54 +0,0 @@ -import os -import setuptools - -with open("README.md", "r") as fh: - long_description = fh.read() - -# Replace relative image path with github-hosted one -long_description = long_description.replace( - "docs/cmd-example.gif", - "https://github.com/raw/amykyta3/git-me-the-url/master/docs/cmd-example.gif?sanitize=true" -) - -with open(os.path.join("gitmetheurl", "__about__.py")) as f: - v_dict = {} - exec(f.read(), v_dict) - version = v_dict['__version__'] - -setuptools.setup( - name="git-me-the-url", - version=version, - author="Alex Mykyta", - author_email="amykyta3@github.com", - description="Generate sharable links to your Git source", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/amykyta3/git-me-the-url", - packages=setuptools.find_packages(), - entry_points = { - "console_scripts": ['gitmetheurl = gitmetheurl.cmd:main'] - }, - include_package_data=True, - install_requires=[ - "gitpython", - ], - classifiers=( - "Development Status :: 5 - Production/Stable", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3 :: Only", - "Intended Audience :: Developers", - "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", - "Operating System :: OS Independent", - "Topic :: Software Development :: Version Control :: Git", - ), - project_urls={ - "Source": "https://github.com/amykyta3/git-me-the-url", - "Tracker": "https://github.com/amykyta3/git-me-the-url/issues", - }, -) diff --git a/test/pylint.rc b/test/pylint.rc index e8319e8..585f072 100644 --- a/test/pylint.rc +++ b/test/pylint.rc @@ -99,15 +99,11 @@ disable= protected-access, duplicate-code, cyclic-import, + eval-used, + wrong-import-position, # Can't do until py35 support is dropped - consider-using-f-string, - - # User ignored - wrong-import-position, - eval-used, - import-outside-toplevel, - method-cache-max-size-none + consider-using-f-string # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option @@ -575,5 +571,5 @@ preferred-modules= # Exceptions that will emit a warning when being caught. Defaults to # "BaseException, Exception". -overgeneral-exceptions=BaseException, - Exception +overgeneral-exceptions=builtins.BaseException, + builtins.Exception