Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize packaging setup #50

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

33 changes: 32 additions & 1 deletion lyrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,38 @@

__version__ = '1.7.0'

if not CONFIG_PATH.exists():
if CONFIG_PATH.exists():
# Update the config file with any missing keys from the defaults.
from configparser import ConfigParser

old_config = ConfigParser()
old_config.read(CONFIG_PATH)

new_config = ConfigParser()
new_config.read('lyrics/lyrics.cfg')

skip = True

for section in old_config.sections():
old_keys = {o for o in old_config[section]}
new_keys = {n for n in new_config[section]}
changes = new_keys ^ old_keys

if len(changes) == 0:
continue
else:
skip = False

for option in new_keys:
fallback = new_config[section].get(option)
new_config[section][option] = old_config[section].get(option, fallback)

if not skip:
with open(CONFIG_PATH, 'w') as file:
new_config.write(file)

else:
# create a new config file.
from shutil import copy
import os

Expand Down
56 changes: 56 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[project]
name = "lyrics-in-terminal"
# Indicate that the version will be determined "dynamically" by setuptools.
dynamic = [ "version" ]
description = "Command Line Lyrics fetcher from mpris media player like Spotify, VLC, Audacious"
# When PEP 639 is fully implemented, this can become simply `license = "MIT"`.
license = { file = "LICENSE" }
# As long as the README file is valid UTF-8, this suffices to fill in the
# old `long_description` and `long_description_content_type` values:
readme = "README.md"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX :: Linux",
]
requires-python = ">=3.7"
# Analogous to `install_requires`.
dependencies = [ "dbus-python", "requests" ]

# Analogous to `extras_require`.
[project.optional-dependencies]
mpd = [ "python-mpd2" ]
full = [ "python-mpd2" ]

[[project.authors]]
name = 'Samarth Jugran'
email = '[email protected]'

# Analogous to `entry_points['console_scripts']`.
[project.scripts]
lyrics = "lyrics.lyrics_in_terminal:main"
lyt = "lyrics.lyrics_in_terminal:main"

[project.urls]
homepage = "https://github.com/Jugran/lyrics-in-terminal"

# Setuptools-specific options.
[tool.setuptools]
# Tell Setuptools that the images/ folder isn't a package, although
# it does contain data files for the sdist (only).
packages = [ "lyrics" ]
# Fine-grained control over which files from the sdist go into the wheel.
package-data.lyrics = [ "lyrics.cfg" ]
# This allows Setuptools to extract the version with its own logic
# rather than relying on sys.path being set up to import the local code.
dynamic.version = {attr = "lyrics.__version__"}

# Explicitly request Setuptools (currently unnecessary, but good practice).
[build-system]
# Determining an exact minimum required version might require experimentation.
# However, for a simple pure-Python project there is no good reason for
# even relatively old versions to fail.
# This choice is a common default recommendation due to the timing when
# pyproject.toml was introduced.
requires = ["setuptools>=40.8.0"]
build-backend = "setuptools.build_meta"
86 changes: 0 additions & 86 deletions setup.py

This file was deleted.