Skip to content

Commit

Permalink
Migrate to pyproject.toml with hatchling build system
Browse files Browse the repository at this point in the history
  • Loading branch information
dogukancagatay committed Mar 9, 2024
1 parent 5bfa9ba commit 01022c6
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: pip install -r requirements-dev.txt
run: pip install '.[dev]'

- name: Run checks
run: make validate-style
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run: sudo ./ci/install.sh

- name: Install dependencies
run: pip install -r requirements-dev.txt
run: pip install '.[dev]'

- name: Execute unit-tests
run: make test
29 changes: 23 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@

PYTHON ?= python3
PYTHON_SOURCE_DIRS = aiven_db_migrate/ test/
PG_VERSIONS = 10 11 12 13 14
VERSION = $(shell hatch version)
RELEASE = 1

generated = aiven_db_migrate/migrate/version.py


all: $(generated)

aiven_db_migrate/migrate/version.py:
echo "__version__ = \"$(shell git describe)\"" > $@
echo "__version__ = \"$(VERSION)\"" > $@


build-dep-fedora:
sudo dnf -y install --best --allowerasing \
$(foreach ver,$(PG_VERSIONS),postgresql$(ver)-server) \
python3-devel \
python3-wheel \
python3-flake8 \
python3-isort \
python3-mypy \
python3-psycopg2 \
python3-pylint \
python3-pytest \
python3-yapf \
rpm-build
python3-hatch-vcs \
hatch \
rpmdevtools \
tar

flake8: $(generated)
$(PYTHON) -m flake8 $(PYTHON_SOURCE_DIRS)
Expand Down Expand Up @@ -49,12 +56,22 @@ validate-style:
diff $(CHANGES_BEFORE) $(CHANGES_AFTER)
-rm $(CHANGES_BEFORE) $(CHANGES_AFTER)

.PHONY: test
test: $(generated)
$(PYTHON) -m pytest -v -r test

clean:
$(RM) aiven_db_migrate/migrate/version.py
$(RM) $(generated)
$(RM) aiven_db_migrate-*.tar.gz
$(RM) -r dist

rpm:
sudo $(PYTHON) setup.py bdist_rpm && rm -rf build/
hatch build
rpmbuild -bb aiven-db-migrate.spec \
--define '_sourcedir $(CURDIR)/dist' \
--define '_topdir $(CURDIR)/dist/rpmbuild' \
--define '_rpmdir $(CURDIR)/dist/rpms' \
--define 'source_dist $(PWD)/dist/aiven_db_migrate-$(VERSION).tar.gz' \
--define 'major_version $(VERSION)' \
--define 'release_number $(RELEASE)'

.PHONY: build-dep-fedora test clean flake8 pylint mypy isort yapf static-checks validate-style rpm
49 changes: 49 additions & 0 deletions aiven-db-migrate.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
%global project aiven-db-migrate

Name: %{project}
Version: %{major_version}
Release: %{release_number}%{?dist}
Url: https://github.com/aiven/%{project}
Source0: %{source_dist}
Summary: Aiven database migration tool
License: ASL 2.0
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: python3dist(wheel)
BuildRequires: python3dist(hatch-vcs)
BuildRequires: python3dist(packaging)
BuildRequires: python3dist(psycopg2)

%description
Aiven is a next-generation managed cloud services. Its focus is in ease of
adoption, high fault resilience, customer's peace of mind and advanced
features at competitive price points.

Aiven database migration tool. This tool is meant for easy migration of databases from some database service
provider, such AWS RDS, or on premises data center, to [Aiven Database as a Service](https://aiven.io/).
However, it's not limited for Aiven services and it might be useful as a generic database migration tool.

%prep
%autosetup -n aiven_db_migrate-%{version}

%generate_buildrequires
%pyproject_buildrequires

%build
%pyproject_wheel

%install
%pyproject_install
%pyproject_save_files aiven_db_migrate

%check
%pyproject_check_import

%files -n %{name} -f %{pyproject_files}
%license LICENSE
%doc README.md
%{_bindir}/pg_migrate

%changelog
* Wed Dec 08 2024 Aiven Support <[email protected]>
- Initial
49 changes: 49 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "aiven-db-migrate"
dynamic = ["version"]
description = "Aiven database migration tool"
readme = "README.md"
license = { text = "Apache License 2.0" }
requires-python = ">=3.9"
authors = [{ name = "Aiven", email = "[email protected]" }]
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = ["psycopg2==2.9.6"]
[project.optional-dependencies]
dev = [
"flake8==6.0.0",
"hatch==1.9.3",
"isort==5.12.0",
"mypy==1.3.0",
"pylint==2.17.4",
"pytest==7.3.1",
"yapf==0.33.0",
]

[project.scripts]
pg_migrate = "aiven_db_migrate.migrate.pgmigrate:main"

[project.urls]
Homepage = "https://aiven.io/"
Issues = "https://github.com/aiven/aiven-db-migrate/issues"
Documentation = "https://aiven.io/docs/products/postgresql/howto/run-aiven-db-migrate-python"

[tool.hatch.version]
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "aiven_db_migrate/migrate/version.py"

[tool.hatch.build.targets.sdist]
include = ["/aiven_db_migrate"]
7 changes: 0 additions & 7 deletions requirements-dev.txt

This file was deleted.

42 changes: 0 additions & 42 deletions setup.py

This file was deleted.

0 comments on commit 01022c6

Please sign in to comment.