Skip to content

Commit

Permalink
Update package build process (#1020)
Browse files Browse the repository at this point in the history
* Update package build process.
Fix source distribution file list.

* Add docs, tests.
  • Loading branch information
arkid15r committed Mar 14, 2023
1 parent 6f94281 commit daef1b1
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 48 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ jobs:
- name: Set Up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: requirements/dev.txt
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install -U pip wheel 'coveralls>=3'
python -m pip install -U -r requirements/dev.txt
python -m pip install -e .
python -m pip install --upgrade 'coveralls>=3' pip
python -m pip install --upgrade --requirement requirements/dev.txt
python -m pip install --editable .
- name: Run Tests
run: |
make test
Expand All @@ -58,7 +58,7 @@ jobs:
steps:
- name: Finished
run: |
pip3 install -U 'coveralls>=3'
python -m pip install --upgrade 'coveralls>=3' pip
coveralls --finish --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -75,11 +75,11 @@ jobs:
python-version: '3.11'
- name: Install Dependencies
run: |
python -m pip install -U pip wheel
pip install -U .
python -m pip install --upgrade build pip
pip install --upgrade .
- name: Build Distribution
run: |
python setup.py sdist bdist_wheel
make build
- name: Publish Package
uses: pypa/[email protected]
Expand Down
12 changes: 5 additions & 7 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
exclude tests/*
recursive-include holidays/locale *.mo
recursive-include holidays/locale *.po
include *.py
include *.rst
include CHANGES
include holidays/py.typed
include LICENSE
include scripts/l10n/msgfmt.py
recursive-include docs *
recursive-include holidays *.py
recursive-include holidays/locale *.(mp)o
recursive-include scripts/l10n *.py
recursive-include tests *.py
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
help:
@echo "Usage: make <target>"
@echo " build build distribution"
@echo " check run pre-commit and tests"
@echo " coverage identify code not covered with tests"
@echo " help show summary of available commands"
Expand All @@ -9,6 +10,10 @@ help:
@echo " test run tests (in parallel)"
@echo " tox run tox (in parallel)"

build:
scripts/l10n/generate_mo_files.py
python -m build

check:
make pre-commit
make doc
Expand Down
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ chameleon
lingua

# Deployment.
build
pip>=19.2.3
wheel>=0.33.6
8 changes: 3 additions & 5 deletions scripts/l10n/generate_mo_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ class MOGenerator:

def run(self):
"""Runs the .mo files generation process."""
# Delete old files.
for mo_file in Path(os.path.join("holidays", "locale")).rglob("*.mo"):
os.unlink(str(mo_file))

# Create new files.
for po_path in Path(os.path.join("holidays", "locale")).rglob("*.po"):
po_file = str(po_path)
mo_file = po_file.replace(".po", ".mo")

if os.path.exists(mo_file):
os.unlink(mo_file)
subprocess.run(
(
sys.executable,
Expand Down
27 changes: 0 additions & 27 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,7 @@
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

import os
import subprocess
import sys
from pathlib import Path

from setuptools import setup


def generate_mo_files():
"""Looks up for .po files and generates respective .mo files."""
for po_path in Path(os.path.join("holidays", "locale")).rglob("*.po"):
po_file = str(po_path)
mo_file = po_file.replace(".po", ".mo")

if os.path.exists(mo_file):
os.unlink(mo_file)
subprocess.run(
(
sys.executable,
os.path.join("scripts", "l10n", "msgfmt.py"),
"-o",
mo_file,
po_file,
),
check=True,
)


if __name__ == "__main__":
generate_mo_files()
setup()

0 comments on commit daef1b1

Please sign in to comment.