diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9c996431eae76239abd0f64c3e49aa3cfe596630..186863219d37791a5955304bb31589e4f87053f4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,9 +28,9 @@ before_script: inquisitor: stage: test script: - - mwmerge.py --sync + - omwmerge --sync - cd ~/.local/share/portmod/openmw - - inquisitor.py + - inquisitor install: stage: build diff --git a/README.md b/README.md index 5d1adf6a185107ff5b4d2eafd211da09c70aeaa9..59426b486fc5f75633c6a757ce26c5de1c2d3832 100644 --- a/README.md +++ b/README.md @@ -21,10 +21,22 @@ https://gitlab.com/bmwinger/omwcmd ## Installing on Linux To install into `/usr/bin` (requires root), run -```sudo ./setup.py install``` + + git clone https://gitlab.com/portmod/portmod + sudo pip3 install /path/to/portmod + +Or, directly from Gitlab: + + sudo pip3 install git+https://gitlab.com/portmod/portmod To install into `~/.local/bin`, run -```./setup.py install --user``` + + git clone https://gitlab.com/portmod/portmod + pip3 install --user --upgrade /path/to/portmod + +Or, directly from Gitlab: + + pip3 install --user --upgrade git+https://gitlab.com/portmod/portmod You will want to create a config file in ~/.config/portmod/portmod.cfg. A sample is included in the root of the repository. Primarily you will want to set the USE variable and the ARCH variable to reflect your openmw setup. @@ -41,11 +53,11 @@ https://git-scm.com/download/win Before installing other mods, you should explicitly install the morrowind mod. This pybuild automatically detects the location of your morrowind installation and "installs it" by creating a softlink to this installation. This is done so that the morrowind data files can be treated just like other data files. You may also want to install omwllf to merge levelled lists. Mods can be installed by passing the relevant atoms as command line arguments. E.g.: -`mwmerge morrowind omwllf` +`omwmerge morrowind omwllf` You can search for mods using the `--search`/`-s` (searches name only) and `--searchdesc`/`-S` (searches name and description) options. -Specific versions of mods can be installed by including the version number: `mwmerge abandoned-flat-2.0` +Specific versions of mods can be installed by including the version number: `omwmerge abandoned-flat-2.0` Specified mods will be automatically be downloaded, configured and installed. diff --git a/bin/inquisitor b/bin/inquisitor new file mode 100755 index 0000000000000000000000000000000000000000..c99f8dec90c1a7ccc9f3cbe2f4eb91a80b4c2084 --- /dev/null +++ b/bin/inquisitor @@ -0,0 +1,20 @@ +#!/usr/bin/python3 + +# Copyright 2019 Portmod Authors +# Distributed under the terms of the GNU General Public License v3 + +import sys +from os import path as osp + + +if __name__ == "__main__": + if osp.isfile( + osp.join( + osp.dirname(osp.dirname(osp.realpath(__file__))), ".portmod_not_installed" + ) + ): + sys.path.insert(0, osp.dirname(osp.dirname(osp.realpath(__file__)))) + + from portmod.inquisitor import main + + main() diff --git a/bin/omwmerge b/bin/omwmerge new file mode 100755 index 0000000000000000000000000000000000000000..e2c67bb975b8dff6a2462fad50f42b183b2f1754 --- /dev/null +++ b/bin/omwmerge @@ -0,0 +1,20 @@ +#!/usr/bin/python3 + +# Copyright 2019 Portmod Authors +# Distributed under the terms of the GNU General Public License v3 + +import sys +from os import path as osp + + +if __name__ == "__main__": + if osp.isfile( + osp.join( + osp.dirname(osp.dirname(osp.realpath(__file__))), ".portmod_not_installed" + ) + ): + sys.path.insert(0, osp.dirname(osp.dirname(osp.realpath(__file__)))) + + from portmod.omwmerge import main + + main() diff --git a/bin/mwmigrate.py b/bin/omwmigrate similarity index 99% rename from bin/mwmigrate.py rename to bin/omwmigrate index cc923d0aa3beafaa8090ad2ad49165fa596c340b..a8871aa2d5b9bfb58afe05509c8bb14d5d819793 100755 --- a/bin/mwmigrate.py +++ b/bin/omwmigrate @@ -6,6 +6,7 @@ import sys from os import path as osp + if __name__ == "__main__": if osp.isfile( osp.join( diff --git a/bin/mwmirror.py b/bin/omwmirror similarity index 99% rename from bin/mwmirror.py rename to bin/omwmirror index 2c5449fa263db660d3f65315631ab01d71eceace..f4e182e7bd1db3e46e106caf334c502cb0774539 100755 --- a/bin/mwmirror.py +++ b/bin/omwmirror @@ -6,6 +6,7 @@ import sys from os import path as osp + if __name__ == "__main__": if osp.isfile( osp.join( diff --git a/bin/omwuse b/bin/omwuse new file mode 100755 index 0000000000000000000000000000000000000000..9641996bd499ccee587352c21ecb7a8083f62d98 --- /dev/null +++ b/bin/omwuse @@ -0,0 +1,20 @@ +#!/usr/bin/python3 + +# Copyright 2019 Portmod Authors +# Distributed under the terms of the GNU General Public License v3 + +import sys +from os import path as osp + + +if __name__ == "__main__": + if osp.isfile( + osp.join( + osp.dirname(osp.dirname(osp.realpath(__file__))), ".portmod_not_installed" + ) + ): + sys.path.insert(0, osp.dirname(osp.dirname(osp.realpath(__file__)))) + + from portmod.omwuse import main + + main() diff --git a/bin/openmw-conflicts b/bin/openmw-conflicts index f187de3dea888f723a114fc874300c932acb62b9..fe46893b05ec6d974ed12cc28f79b19c32c13d54 100755 --- a/bin/openmw-conflicts +++ b/bin/openmw-conflicts @@ -1,13 +1,12 @@ -#!/usr/bin/python +#!/usr/bin/python3 # Copyright 2019 Portmod Authors # Distributed under the terms of the GNU General Public License v3 -import shutil -import subprocess import sys from os import path as osp + if __name__ == "__main__": if osp.isfile( osp.join( @@ -16,16 +15,6 @@ if __name__ == "__main__": ): sys.path.insert(0, osp.dirname(osp.dirname(osp.realpath(__file__)))) - from portmod.config import find_config, read_config - - config = read_config() - - mod_dirs = [directory for (index, directory) in find_config(config, "data", "*")] - - args = ["dcv"] - args.extend(mod_dirs) + from portmod.openmw_conflicts import main - if shutil.which("dcv"): - subprocess.Popen(args).wait() - else: - print('Error: Could not find "dcv"') + main() diff --git a/bin/pybuild b/bin/pybuild new file mode 100755 index 0000000000000000000000000000000000000000..3e643bbd07485c9094125fcf855e8228c75f977b --- /dev/null +++ b/bin/pybuild @@ -0,0 +1,20 @@ +#!/usr/bin/python3 + +# Copyright 2019 Portmod Authors +# Distributed under the terms of the GNU General Public License v3 + +import sys +from os import path as osp + + +if __name__ == "__main__": + if osp.isfile( + osp.join( + osp.dirname(osp.dirname(osp.realpath(__file__))), ".portmod_not_installed" + ) + ): + sys.path.insert(0, osp.dirname(osp.dirname(osp.realpath(__file__)))) + + from portmod.omwpybuild import main + + main() diff --git a/portmod/config.py b/portmod/config.py index 7cd6743c0777ebf17aaa9c51f32e0be3d36560df..479e9430efe2a9970df1b86d1019785ba05bfc15 100644 --- a/portmod/config.py +++ b/portmod/config.py @@ -1,7 +1,7 @@ # Copyright 2019 Portmod Authors # Distributed under the terms of the GNU General Public License v3 -from portmod.globals import OPENMW_CONFIG, OPENMW_CONFIG_DIR +from .globals import OPENMW_CONFIG, OPENMW_CONFIG_DIR import fnmatch import shutil import re diff --git a/bin/inquisitor.py b/portmod/inquisitor.py old mode 100755 new mode 100644 similarity index 99% rename from bin/inquisitor.py rename to portmod/inquisitor.py index e264821a746d807251192ee0ebc6bcb61b2eb30b..f070ec695a981b231aecf5d1d9b0d47fddec8ae9 --- a/bin/inquisitor.py +++ b/portmod/inquisitor.py @@ -8,7 +8,8 @@ import sys import argparse from os import path as osp -if __name__ == "__main__": + +def main(): if osp.isfile( osp.join( osp.dirname(osp.dirname(osp.realpath(__file__))), ".portmod_not_installed" @@ -179,3 +180,7 @@ if __name__ == "__main__": if error: exit(1) + + +if __name__ == "__main__": + main() diff --git a/bin/mwmerge.py b/portmod/omwmerge.py old mode 100755 new mode 100644 similarity index 86% rename from bin/mwmerge.py rename to portmod/omwmerge.py index 25ac781268607dc095fd7822ea20c4a0124bf3f0..f5263c6aa7d8e06ca34a3bcfb24a50489605821e --- a/bin/mwmerge.py +++ b/portmod/omwmerge.py @@ -7,7 +7,8 @@ import sys import os from os import path as osp -if __name__ == "__main__": + +def main(): if osp.isfile( osp.join( osp.dirname(osp.dirname(osp.realpath(__file__))), ".portmod_not_installed" @@ -18,6 +19,10 @@ if __name__ == "__main__": # Avoid buffering so that we can read from other processes as they output os.environ["PYTHONUNBUFFERED"] = "1" - from portmod.main import main + from portmod.main import main as portmod_main + + portmod_main() + +if __name__ == "__main__": main() diff --git a/bin/pybuild.py b/portmod/omwpybuild.py old mode 100755 new mode 100644 similarity index 98% rename from bin/pybuild.py rename to portmod/omwpybuild.py index 7c723bfb50b21f48c105020f1db1dc8f85391cbf..83b3cec4987cc000f780a51a5922bda9adff4cee --- a/bin/pybuild.py +++ b/portmod/omwpybuild.py @@ -7,7 +7,8 @@ import sys import argparse from os import path as osp -if __name__ == "__main__": + +def main(): if osp.isfile( osp.join( osp.dirname(osp.dirname(osp.realpath(__file__))), ".portmod_not_installed" @@ -19,9 +20,9 @@ if __name__ == "__main__": import portmod.globals from portmod.repo.loader import load_file from portmod.repo.download import download_mod + from portmod.log import err from portmod.mod import install_mod, remove_mod from portmod.main import pybuild_validate, pybuild_manifest - from portmod.log import err parser = argparse.ArgumentParser( description="Command line interface to interact with pybuilds" @@ -72,3 +73,7 @@ if __name__ == "__main__": if args.debug: traceback.print_exc() err("{}".format(e)) + + +if __name__ == "__main__": + main() diff --git a/bin/mwuse.py b/portmod/omwuse.py old mode 100755 new mode 100644 similarity index 98% rename from bin/mwuse.py rename to portmod/omwuse.py index 2c77ff6c45c78275acc9e7d991853fe0217b6c61..f29ae195ade08cb4aa6d1f8cf27c2013b515c3bb --- a/bin/mwuse.py +++ b/portmod/omwuse.py @@ -7,7 +7,8 @@ import sys import argparse from os import path as osp -if __name__ == "__main__": + +def main(): if osp.isfile( osp.join( osp.dirname(osp.dirname(osp.realpath(__file__))), ".portmod_not_installed" @@ -63,3 +64,7 @@ if __name__ == "__main__": if args.debug: traceback.print_exc() err("{}".format(e)) + + +if __name__ == "__main__": + main() diff --git a/portmod/openmw_conflicts.py b/portmod/openmw_conflicts.py new file mode 100644 index 0000000000000000000000000000000000000000..ad30e0add6683589c4c33c3dfe117bfe9f174a5b --- /dev/null +++ b/portmod/openmw_conflicts.py @@ -0,0 +1,26 @@ +#!/usr/bin/python + +# Copyright 2019 Portmod Authors +# Distributed under the terms of the GNU General Public License v3 + +import shutil +import subprocess +from portmod.config import find_config, read_config + + +def main(): + config = read_config() + + mod_dirs = [directory for (index, directory) in find_config(config, "data", "*")] + + args = ["dcv"] + args.extend(mod_dirs) + + if shutil.which("dcv"): + subprocess.Popen(args).wait() + else: + print('Error: Could not find "dcv"') + + +if __name__ == "__main__": + main() diff --git a/portmod/repo/__init__.py b/portmod/repo/__init__.py index 1d80707f2049b7e9390fe4eef144fc7714279b93..1843c046874e7ff17e215646dfb33713dc91578d 100644 --- a/portmod/repo/__init__.py +++ b/portmod/repo/__init__.py @@ -1,4 +1,4 @@ # Copyright 2019 Portmod Authors # Distributed under the terms of the GNU General Public License v3 -from portmod.repo.atom import Atom # noqa # pylint: disable=unused-import +from .atom import Atom # noqa # pylint: disable=unused-import diff --git a/portmod/repo/use.py b/portmod/repo/use.py index a38f97b48449ca61744bfe8900f558924662d6ce..a6a40737a4cdcb3aea569ca08452c346e030d7e5 100644 --- a/portmod/repo/use.py +++ b/portmod/repo/use.py @@ -6,8 +6,8 @@ from typing import AbstractSet, Any, Callable, List, Optional, Type import os import configparser from portmod.globals import GLOBAL_USE, PORTMOD_CONFIG_DIR, PORTMOD_CONFIG -import portmod.repo.loader as loader from portmod.repo.util import select_mod +from portmod.repo import loader from portmod.repo.flags import get_flags, add_flag, remove_flag from portmod.repo.textures import select_texture_size from portmod.repo.atom import Atom, InvalidAtom, useflag_re diff --git a/pyproject.toml b/pyproject.toml index 53f900bfc24efa5f33ba0e76d975f0554eeac219..21efbd77443866fd8df4e9df3e2e3e6bcd444773 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] # Minimum requirements for the build system to execute. -requires = [] +requires = ["setuptools", "wheel"] [tool.black] line-length = 88 diff --git a/setup.py b/setup.py index ee40c7ed566ca3bef2409e16a7565898d39e899a..bdbacbbe662a174cdbc4feea2b406eb2d3dd3e5d 100755 --- a/setup.py +++ b/setup.py @@ -4,20 +4,28 @@ # Distributed under the terms of the GNU General Public License v3 -from distutils.core import setup +from setuptools import setup setup( name="portmod", version="1.0", + author="Portmod Authors", + description="https://gitlab.com/portmod/portmod", + download_url="A CLI tool to manage mods for OpenMW", + license="GPLv3", url="https://gitlab.com/portmod/portmod", - scripts=[ - "bin/inquisitor.py", - "bin/mwmerge.py", - "bin/mwuse.py", - "bin/openmw-conflicts", - "bin/pybuild.py", - "bin/mwmirror.py", - "bin/mwmigrate.py", - ], packages=["portmod", "portmod.repo", "portmod.pybuild"], + entry_points=( + { + "console_scripts": [ + "inquisitor = portmod.inquisitor:main", + "omwmerge = portmod.omwmerge:main", + "omwmigrate = portmod.migrate:migrate", + "omwmirror = portmod.mirror:mirror", + "omwuse = portmod.omwuse:main", + "openmw-conflicts = portmod.openmw_conflicts:main", + "pybuild = portmod.omwpybuild:main", + ] + } + ), )