diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index fe65cb05..349894fb 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -18,25 +18,20 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - # Confirm that the `python` maps to the version we just installed. - # PowerShell on Windows does this differently than the Unix shells. - - run: which python ; python --version ; which pip ; pip --version - if: matrix.os != 'windows-latest' - - run: get-command python ; python --version ; get-command pip ; pip --version - if: matrix.os == 'windows-latest' + - uses: astral-sh/setup-uv@v5 - run: git --version - # Make sure Subversion and Mercurial are installed on Windows and macOS. - - run: sudo apt-get update && sudo apt-get install -y subversion mercurial + # Make sure Subversion (including `svnadmin`) and Mercurial are installed + # on Windows and macOS. I'd prefer `uv tool install mercurial`, but the + # `hg` binary that that installs crashes on Windows for some reason. We + # don't need Mercurial to use the same Python version that we're using. + # Also Choco and WinGet seem to fail to put `hg` in the PATH for some + # reason. + - run: pip install mercurial + - run: sudo apt-get update && sudo apt-get install -y subversion if: matrix.os == 'ubuntu-latest' - - run: brew install subversion mercurial + - run: brew install subversion if: matrix.os == 'macOS-latest' - - run: choco install -y --no-progress sliksvn && pip install mercurial + - run: choco install -y --no-progress sliksvn if: matrix.os == 'windows-latest' - # Install test dependencies, like flake8. - - run: pip install -r ./requirements-dev.txt # Run tests. - - run: python test.py -v + - run: uv run --python ${{ matrix.python-version }} test.py -v diff --git a/.gitignore b/.gitignore index fe7dd1f7..15da050b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ __pycache__ peru.egg-info build/ dist/ +uv.lock diff --git a/peru.py b/peru.py index ce9d36a8..acaddd6c 100755 --- a/peru.py +++ b/peru.py @@ -3,6 +3,8 @@ # This script is for running peru directly from the repo, mainly for # development. This isn't what gets installed when you install peru. That would # be a script generated by setup.py, which calls peru.main.main(). +# +# Update October 2025: `uv run peru` also works. import os import sys diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..b3bbbcac --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,40 @@ +[project] +name = "peru" +dynamic = ["version"] +description = "A tool for fetching code" +readme = "README.md" +license = "MIT" +authors = [ + { name = "Jack O'Connor", email = "oconnor663@gmail.com" }, + { name = "Sean Olson", email = "olson.sean.k@gmail.com" }, +] +requires-python = ">=3.8" +dependencies = [ + "PyYAML", +] + +[project.urls] +Repository = "https://github.com/buildinspace/peru" + +[project.scripts] +peru = "peru.main:main" + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.hatch.build] +include = [ + "peru/**/*.py", + "peru/VERSION", + "peru/resources/**/*", +] + +[tool.hatch.version] +path = "peru/VERSION" +pattern = "(?P.+)" + +[dependency-groups] +dev = [ + "flake8", +] diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 9c4d6cd6..00000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,4 +0,0 @@ -coverage -flake8 - --e . diff --git a/setup.py b/setup.py deleted file mode 100644 index 582f883c..00000000 --- a/setup.py +++ /dev/null @@ -1,59 +0,0 @@ -import os -import setuptools -import sys - -# Written according to the docs at -# https://packaging.python.org/en/latest/distributing.html - -project_root = os.path.dirname(__file__) -readme_file = os.path.join(project_root, 'README.md') -module_root = os.path.join(project_root, 'peru') -version_file = os.path.join(module_root, 'VERSION') - - -def get_version(): - with open(version_file) as f: - return f.read().strip() - - -def get_all_resources_filepaths(): - resources_paths = ['VERSION'] - resources_dir = os.path.join(module_root, 'resources') - for dirpath, dirnames, filenames in os.walk(resources_dir): - relpaths = [ - os.path.relpath(os.path.join(dirpath, f), start=module_root) - for f in filenames - ] - resources_paths.extend(relpaths) - return resources_paths - - -def get_install_requires(): - dependencies = ['PyYAML'] - if sys.version_info < (3, 5): - raise RuntimeError('The minimum supported Python version is 3.5.') - return dependencies - - -def readme_text(): - with open(readme_file) as f: - return f.read().strip() - - -setuptools.setup( - name='peru', - description='A tool for fetching code', - version=get_version(), - url='https://github.com/buildinspace/peru', - author="Jack O'Connor , " - "Sean Olson ", - license='MIT', - packages=['peru', 'peru.docopt'], - package_data={'peru': get_all_resources_filepaths()}, - entry_points={'console_scripts': [ - 'peru=peru.main:main', - ]}, - install_requires=get_install_requires(), - long_description=readme_text(), - long_description_content_type='text/markdown', -)