diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 9b41d4e..ba186cf 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -73,7 +73,7 @@ jobs: continue-on-error: true #unit tests using pytest, unittest, flake8 and bandit frameworks - - name: Testing with unittest + - name: Running unit tests env: GOOGLE_MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY }} run: | @@ -82,6 +82,7 @@ jobs: #create coverage report using pytest package - name: Generate Coverage Report + if: ${{ matrix.python-version == '3.9' }} env: GOOGLE_MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY }} run: | diff --git a/.github/workflows/deploy_pypi.yml b/.github/workflows/deploy_pypi.yml index 52b853a..56e3eda 100644 --- a/.github/workflows/deploy_pypi.yml +++ b/.github/workflows/deploy_pypi.yml @@ -24,24 +24,21 @@ jobs: with: python-version: ${{ matrix.python-version }} - # install all required modules and dependancies using pip and setup.py installation + # install all required modules and dependancies using pip and pyproject.toml installation - name: Install dependencies run: | - python -m pip install --upgrade pip - python3 setup.py install - pip install build + python -m pip install --upgrade pip twine build - # Build package - - name: Build package + # build distribution package of software and upload to the PYPi server + - name: Build and Upload to PyPI run: | - python -m build - - # publish to pypi - - name: Publish package - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 - with: - user: __token__ - password: ${{ secrets.PYPI_TOKEN }} + python3 -m build + twine check dist/* + python3 -m twine upload dist/* --verbose + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + TWINE_REPOSITORY: pypi #sleep for 30 seconds to ensure that distribution package has finised uploading to Test PyPI - name: Wait / Sleep diff --git a/.github/workflows/deploy_test_pypi.yml b/.github/workflows/deploy_test_pypi.yml index 709d9f5..88097f8 100644 --- a/.github/workflows/deploy_test_pypi.yml +++ b/.github/workflows/deploy_test_pypi.yml @@ -26,19 +26,19 @@ jobs: with: python-version: ${{ matrix.python-version }} - # install all required modules and dependancies using pip and setup.py installation + # install all required modules and dependancies using pip and pyproject.toml installation - name: Install dependencies run: | python -m pip install --upgrade pip - python3 -m pip install setuptools wheel twine + python3 -m pip install setuptools wheel twine build python3 setup.py install # build distribution package of software and upload to the test PYPi server - name: Build and Upload to TestPyPI run: | - python3 setup.py sdist bdist_wheel + python3 -m build twine check dist/* - twine upload --repository testpypi dist/* --verbose + python3 -m twine upload --repository testpypi dist/* --verbose env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TEST }} diff --git a/MANIFEST.in b/MANIFEST.in index 10dda40..9110799 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ -graft iso3166_2/iso3166-2-data* +graft iso3166_2/iso3166_2_data* include README.md recursive-exclude __pycache__ * exclude API.md diff --git a/ToDo.md b/ToDo.md index 24f7581..a20aa51 100644 --- a/ToDo.md +++ b/ToDo.md @@ -224,7 +224,9 @@ https://iso3166-updates.com/api/year/2020 : up-to-date. - [X] Update /docs - [X] In api docs, put API funcs all into one section. - [X] Check order of sections in readme. -- [ ] In workflows, change "Testing with unittest" to "Running unit tests" +- [X] In workflows, change "Testing with unittest" to "Running unit tests" +- [X] Change setup.py to pyprojet.tml - https://packaging.python.org/en/latest/tutorials/packaging-projects/ - swap for setup.cfg +- [X] /iso3166_2_data not being included in package - incorrect filename in MANIFEST file. Future Additions ---------------- diff --git a/docs/conf.py b/docs/conf.py index 739912a..b11da7c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -9,7 +9,7 @@ project = 'iso3166-2' copyright = '2024, AJ McKenna' author = 'AJ McKenna' -release = '1.5.0' +release = '1.5.2' # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/docs/requirements.txt b/docs/requirements.txt index 567697c..ae25e90 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,4 +1,4 @@ -sphinx==3.4.3 +sphinx sphinx_autodoc_typehints==1.12.0 sphinx_autodoc_defaultargs==0.1.2 sphinx-rtd-theme diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..20aecdf --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,38 @@ + +[project] +name = "iso3166-2" +version = "1.5.2" +description = "A lightweight Python package, and accompanying API, that can be used to access all of the world's most up-to-date and accurate ISO 3166-2 subdivision data, including: name, local name, code, parent code, type, latitude/longitude and flag." +authors = [ + { name="AJ McKenna", email="amckenna41@qub.ac.uk" }, +] +maintainers = "AJ McKenna " +license = "MIT" +readme = "README.md" +requires-python = ">=3.8" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Intended Audience :: Information Technology", + "License :: OSI Approved :: MIT License", + "License :: Free For Educational Use", + "Natural Language :: English", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10"', + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: PyPy", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Information Analysis", + "Topic :: Software Development :: Libraries :: Python Modules" +] +keywords = ["iso", "iso3166", "beautifulsoup", "python", "pypi", "countries", "country codes", "iso3166-2", "iso3166-1", "alpha-2", "iso3166-updates", "subdivisions", "regions"] +dependancies = ["iso3166", "natsort", "thefuzz", "unidecode"] + +[project.urls] +homepage = "https://iso3166-2-api.vercel.app/api" +repository = "https://github.com/amckenna41/iso3166-2" +documentation = "https://iso3166-2.readthedocs.io/en/latest/" \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 0e575c7..0000000 --- a/setup.cfg +++ /dev/null @@ -1,71 +0,0 @@ -[metadata] -name = iso3166-2 -version = 1.5.1 -description = A lightweight Python package, and accompanying API, that can be used to access all of the worlds most up-to-date and accurate ISO 3166-2 subdivision data, including: name, local name, code, parent code, type, latitude/longitude and flag. -author = AJ McKenna -author_email = amckenna41@qub.ac.uk -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/amckenna41/iso3166-2 -download_url = https://github.com/amckenna41/iso3166-2/archive/refs/heads/main.zip -license = MIT -maintainer = AJ McKenna -status = Production -keywords = - iso - iso3166 - beautifulsoup - python - pypi - countries - country codes - iso3166-2 - iso3166-1 - alpha-2 - iso3166-updates - subdivisions - regions - -# https://pypi.org/pypi?%3Aaction=list_classifiers -classifiers = - Development Status :: 5 - Production/Stable, - Environment :: Console, - Intended Audience :: Developers, - Intended Audience :: Science/Research, - Intended Audience :: Information Technology, - License :: OSI Approved :: MIT License, - License :: Free For Educational Use, - Natural Language :: English, - Programming Language :: Python :: 3.8, - Programming Language :: Python :: 3.9, - Programming Language :: Python :: 3.10, - Programming Language :: Python :: 3.11, - Programming Language :: Python :: Implementation :: PyPy, - Programming Language :: Python :: 3 :: Only, - Topic :: Scientific/Engineering, - Topic :: Scientific/Engineering :: Information Analysis, - Topic :: Software Development :: Libraries :: Python Modules - -[options] -python_requires = >=3.8 -zip_safe = False -include_package_data = True -packages = find: - -install_requies = - iso3166 - natsort - thefuzz - unidecode - -[options.extras_require] -test = - pytest - pytest-cov - pytest-flake8 - pytest-timeout -docs = - sphinx - -[tool:pytest] -norecursedirs = /docs/_build/* diff --git a/setup.py b/setup.py deleted file mode 100644 index d304520..0000000 --- a/setup.py +++ /dev/null @@ -1,67 +0,0 @@ -############################################################################### -##### Setup.py - installs all the required packages and dependancies ##### -############################################################################### - -import pathlib -from setuptools import setup, find_packages - -#software metadata -__name__ = 'iso3166-2' -__version__ = "1.5.1" -__description__ = "A lightweight Python package, and accompanying API, that can be used to access all of the world's most up-to-date and accurate ISO 3166-2 subdivision data, including: name, local name, code, parent code, type, latitude/longitude and flag." -__author__ = 'AJ McKenna, https://github.com/amckenna41' -__authorEmail__ = 'amckenna41@qub.ac.uk' -__maintainer__ = "AJ McKenna" -__license__ = 'MIT' -__url__ = 'https://github.com/amckenna41/iso3166-2' -__download_url__ = "https://github.com/amckenna41/iso3166-2/archive/refs/heads/main.zip" -__status__ = 'Production' -__keywords__ = ["iso", "iso3166", "beautifulsoup", "python", "pypi", "countries", "country codes", \ - "iso3166-2", "iso3166-1", "alpha-2", "iso3166-updates", "subdivisions", "regions"] -__test_suite__ = "tests" - -#get path to README file -HERE = pathlib.Path(__file__).parent -README = (HERE / 'README.md').read_text() - -setup(name=__name__, - version=__version__, - description=__description__, - long_description = README, - long_description_content_type = "text/markdown", - author=__author__, - author_email=__authorEmail__, - maintainer=__maintainer__, - license=__license__, - url=__url__, - download_url=__download_url__, - keywords=__keywords__, - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'Intended Audience :: Science/Research', - 'Intended Audience :: Information Technology', - 'License :: OSI Approved :: MIT License', - 'License :: Free For Educational Use', - 'Natural Language :: English', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: Implementation :: PyPy', - 'Programming Language :: Python :: 3 :: Only', - 'Topic :: Scientific/Engineering', - 'Topic :: Scientific/Engineering :: Information Analysis', - 'Topic :: Software Development :: Libraries :: Python Modules' - ], - install_requires=[ - 'iso3166', - 'natsort', - 'thefuzz', - 'unidecode' - ], - test_suite=__test_suite__, - packages=find_packages(), - include_package_data=True, - zip_safe=False)