Skip to content

Commit

Permalink
Use setuptools instead of distutils
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzhen committed Dec 2, 2023
1 parent 882310d commit 7c78e61
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 32 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,17 @@ https://aur.archlinux.org/packages/xfce4-dockbarx-plugin/
## Manual Installation

1. Following dependencies needs to be installed (many of them might be installed already on your system):
- gir1.2-gtk-3.0 (>= 3.22), gir1.2-glib-2.0 (>= 1.40), gir1.2-keybinder-3.0, gir1.2-pango-1.0, gir1.2-wnck-3.0, python3 (>= 3.5), python3-cairo (>= 1.11.0), python3-dbus, python3-distutils, python3-gi, python3-gi-cairo, python3-pil, python3-polib, python3-xdg and python3-xlib.
- gir1.2-gtk-3.0 (>= 3.22), gir1.2-glib-2.0 (>= 1.40), gir1.2-keybinder-3.0, gir1.2-pango-1.0, gir1.2-wnck-3.0, python3 (>= 3.5), python3-cairo (>= 1.11.0), python3-dbus, python3-gi, python3-gi-cairo, python3-pil, python3-xdg and python3-xlib.
- (Only for build) python3-pip, python3-polib, python3-setuptools
- (Optional) gir1.2-zeitgeist-2.0 and zeitgeist, to access latest and most used documents.
- (Optional) indicator-application or ayatana-indicator-application, to use the appindicator applet with DockX
- (Optional) python3-pyudev (>= 0.15), to use the battery status applet with DockX
- (Optional) python3-lxml, to use the settings migrating tool
2. Extract dockbarx. Change directory to where you extracted dockbarx and run the setup.py install `$ sudo ./setup.py install`
2. Extract dockbarx. Change directory to where you extracted dockbarx and run the following commands:
```
sudo pip install --prefix=/usr .
sudo glib-compile-schemas /usr/share/glib-2.0/schemas/
```

## Usage
To run DockbarX as a stand alone dock use the command `dockx`.
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools", "polib"]
build-backend = "setuptools.build_meta"
42 changes: 12 additions & 30 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,18 @@
# You should have received a copy of the GNU General Public License
# along with dockbar. If not, see <http://www.gnu.org/licenses/>.

from distutils.core import setup
from distutils.core import setup
from distutils import cmd
from distutils.command.install_data import install_data as _install_data
from distutils.command.build import build as _build
from setuptools import setup
from setuptools import Command
from setuptools.command.install import install as _install
from setuptools.command.build import build as _build

import polib
import os
import sys
import stat

VERSION = "1.0-beta3"

class build_trans(cmd.Command):
class build_trans(Command):
description = "Compile .po files into .mo files"
def initialize_options(self):
pass
Expand Down Expand Up @@ -70,7 +68,7 @@ class build(_build):
def run(self):
_build.run(self)

class install_data(_install_data):
class install(_install):

def run(self):
for lang in os.listdir("build/locale/"):
Expand All @@ -85,14 +83,14 @@ def run(self):
lang_files.append(d_file)
if os.path.exists(dt_file):
lang_files.append(dt_file)
self.data_files.append( (lang_dir, lang_files) )
self.distribution.data_files.append( (lang_dir, lang_files) )
# Scan folders for the right files
self.scan_path("/usr/share/dockbarx/themes", "themes", ext=".tar.gz")
self.scan_path("share/dockbarx/themes", "themes", ext=".tar.gz")
self.scan_path("share/icons/", "icons", ext=".png")
self.scan_path("share/dockbarx/applets/namebar_themes",
"dockx_applets/namebar_themes",
ext=".tar.gz")
_install_data.run(self)
_install.run(self)

def scan_path(self, install_path, base_path, path="", ext=""):
files = []
Expand All @@ -104,13 +102,13 @@ def scan_path(self, install_path, base_path, path="", ext=""):
elif os.path.isfile(fpath) and fpath.endswith(ext):
files.append(fpath)
if files:
self.data_files.append((os.path.join(install_path, path), files))
self.distribution.data_files.append((os.path.join(install_path, path), files))


cmdclass = {
"build": build,
"build_trans": build_trans,
"install_data": install_data,
"install": install,
}

data_files=[
Expand Down Expand Up @@ -142,7 +140,7 @@ def scan_path(self, install_path, base_path, path="", ext=""):
("share/mate-panel/ui/", ["mate_panel_applet/dockbarx-applet-menu.xml"]),
]

s = setup(name="Dockbarx",
setup(name="Dockbarx",
version=VERSION,
description="A dock-ish gnome-applet",
author="Aleksey Shaferov and Matias Sars",
Expand All @@ -153,19 +151,3 @@ def scan_path(self, install_path, base_path, path="", ext=""):
)



if len(sys.argv) == 2 and sys.argv[1] == "install":
install_data_path = s.command_obj['install'].install_data
schema_path = os.path.join(install_data_path, "share/glib-2.0/schemas")
os.system("glib-compile-schemas %s" % schema_path)
# create sudo policy file for battery_status_helper.sh
helper_file = os.path.join(install_data_path, 'share/dockbarx/applets/battery_status_helper.sh')
sudo_policy_file = '/etc/sudoers.d/dockbarx-applet-battery-status-helper'
try:
f = open(sudo_policy_file, 'w')
f.write('ALL ALL=(root) NOPASSWD:%s\n' % helper_file)
f.close()
os.chmod(sudo_policy_file, stat.S_IRUSR | stat.S_IRGRP)
except:
pass

0 comments on commit 7c78e61

Please sign in to comment.