Skip to content

Commit

Permalink
fix(entry): Do not modify PYTHONPATH externally to run envprobe
Browse files Browse the repository at this point in the history
  • Loading branch information
whisperity committed May 7, 2022
1 parent 7746d1e commit d7263f3
Show file tree
Hide file tree
Showing 33 changed files with 237 additions and 198 deletions.
42 changes: 0 additions & 42 deletions commands/__init__.py

This file was deleted.

4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Sphinx==3.4.0
sphinx_rtd_theme>=0.5.0
Sphinx==4.2.0
sphinx_rtd_theme==1.0.0
6 changes: 3 additions & 3 deletions envprobe
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import os
import sys

abs_path = os.path.dirname(os.path.abspath(__file__)) # .../
envprobe_root = os.path.join(abs_path, "src")
sys.path.insert(0, envprobe_root)
envprobe_root = os.path.join(abs_path, "src") # .../src
sys.path.insert(0, envprobe_root) # .../src/envprobe is the package's main.

from envprobe import main # noqa

if __name__ == '__main__':
ret = main.handle_mode(envprobe_root)
ret = main.handle_mode(os.path.dirname(envprobe_root))
sys.exit(ret)
40 changes: 0 additions & 40 deletions envprobe-config.py

This file was deleted.

39 changes: 0 additions & 39 deletions envprobe-entrypoint.py

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ console_output_style = "count"
testpaths = ["src",
"test/unit",
"test/integration",
"test/functional"
"test/system"
]

[tool.coverage.run]
Expand Down
102 changes: 102 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Copyright (C) 2020 Whisperity
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import subprocess

try:
from setuptools import setup
except ImportError:
from distutils.core import setup

with open("README.md", encoding="utf-8", errors="ignore") as md:
long_description = md.read()

try:
commit = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
commit = commit.decode().strip()
except subprocess.CalledProcessError:
commit = "0000000"
except OSError:
commit = "0000000"

try:
version = subprocess.check_output(["git", "describe", "--tags",
"--dirty=\"-dirty\""])
version = version.decode().strip()
if version[0] == "v":
version = version[1:]
version = version.replace("-dirty", "dev")
version_parts = version.split("-")
if len(version_parts) == 1:
version = version_parts[0]
else:
# Skip the commit count and inject the hash only.
version = version_parts[0] + "+" + version_parts[2]
except subprocess.CalledProcessError:
# No version tag found.
version = "0.0.0+" + commit
except OSError:
version = "0.0.0"


setup(
name="envprobe",
description="Overlaying pluggable environment setter: modules reimagined + toggleable direnv on the shell, rather than the directory level.",
version=version,
author="Whisperity",
author_email="whisperity-packages@protonmail.com",
long_description=long_description,
long_description_content_type='text/markdown',
url="http://github.com/whisperity/envprobe",
license="GPLv3+",
keywords="shell environment environment-variables bash zsh",
classifiers=[
"Development Status :: 3 - Alpha",
"Environment :: Console",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Information Technology",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: GNU General Public License v3 or "
"later (GPLv3+)",
"Operating System :: MacOS",
"Operating System :: POSIX :: Linux",
"Operating System :: Unix",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Software Development",
"Topic :: System :: Shells"
],
python_requires=">=3.6",

packages=["envprobe",
"envprobe.commands",
"envprobe.community_descriptions",
"envprobe.settings",
"envprobe.shell",
"envprobe.vartypes"
],
package_dir={
"envprobe": "src/envprobe"
},

entry_points={
"console_scripts": [
"envprobe=envprobe.setupped_main:main",
"envprobe-main=envprobe.setupped_main:main_mode",
"envprobe-config=envprobe.setupped_main:config_mode"
]
}
)
9 changes: 6 additions & 3 deletions src/envprobe/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
import os
import sys

from .main import handle_mode
abs_path = os.path.dirname(os.path.abspath(__file__)) # .../src/envprobe
envprobe_root = os.path.dirname(abs_path) # .../src
sys.path.insert(0, envprobe_root) # .../src/envprobe is the package's main.

from envprobe import main # noqa

if __name__ == '__main__':
abs_path = os.path.dirname(os.path.abspath(__file__)) # .../src/envprobe
ret = handle_mode(os.path.dirname(abs_path)) # .../src
ret = main.handle_mode(os.path.dirname(envprobe_root))
sys.exit(ret)
4 changes: 2 additions & 2 deletions src/envprobe/commands/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import os
import sys

from ..settings import get_configuration_directory
from ..settings.snapshot import get_snapshot_directory_name, \
from envprobe.settings import get_configuration_directory
from envprobe.settings.snapshot import get_snapshot_directory_name, \
get_snapshot_file_name


Expand Down
4 changes: 2 additions & 2 deletions src/envprobe/commands/descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import sys
import tempfile

from ..community_descriptions import downloader, local_data
from ..vartypes import EnvVarExtendedInformation
from envprobe.community_descriptions import downloader, local_data
from envprobe.vartypes import EnvVarExtendedInformation


name = 'descriptions'
Expand Down
2 changes: 1 addition & 1 deletion src/envprobe/commands/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from enum import Enum

from ..environment import VariableDifferenceKind
from envprobe.environment import VariableDifferenceKind


name = 'diff'
Expand Down
4 changes: 2 additions & 2 deletions src/envprobe/commands/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import shlex
import sys

from ..vartypes import get_kind
from ..vartypes.array import Array
from envprobe.vartypes import get_kind
from envprobe.vartypes.array import Array


name = 'get'
Expand Down
6 changes: 3 additions & 3 deletions src/envprobe/commands/hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import stat
import tempfile

from ..environment import Environment
from ..settings import get_runtime_directory
from ..shell import load, load_all, get_known_kinds
from envprobe.environment import Environment
from envprobe.settings import get_runtime_directory
from envprobe.shell import load, load_all, get_known_kinds


name = 'hook'
Expand Down
5 changes: 3 additions & 2 deletions src/envprobe/commands/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os

from ..settings import get_configuration_directory
from ..settings.snapshot import get_snapshot_directory_name, get_snapshot_name
from envprobe.settings import get_configuration_directory
from envprobe.settings.snapshot import get_snapshot_directory_name, \
get_snapshot_name


name = 'list'
Expand Down
2 changes: 1 addition & 1 deletion src/envprobe/commands/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from ..library import get_snapshot
from envprobe.library import get_snapshot


name = 'load'
Expand Down
2 changes: 1 addition & 1 deletion src/envprobe/commands/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from ..library import get_snapshot
from envprobe.library import get_snapshot


name = 'save'
Expand Down
6 changes: 3 additions & 3 deletions src/envprobe/commands/set_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from ..environment import create_environment_variable
from ..library import get_variable_information_manager
from .. import vartypes
from envprobe.environment import create_environment_variable
from envprobe.library import get_variable_information_manager
from envprobe import vartypes

name = 'set'
description = \
Expand Down
6 changes: 3 additions & 3 deletions src/envprobe/commands/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
from enum import Enum
import os

from ..settings import get_configuration_directory
from ..settings.config_file import ConfigurationFile
from ..settings.variable_tracking import \
from envprobe.settings import get_configuration_directory
from envprobe.settings.config_file import ConfigurationFile
from envprobe.settings.variable_tracking import \
get_tracking_file_name, VariableTracking


Expand Down
2 changes: 1 addition & 1 deletion src/envprobe/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import os
import pickle # nosec: pickle has some issues, we will get back to it later.

from . import vartypes
from envprobe import vartypes


class EnvVarTypeHeuristic:
Expand Down
Loading

0 comments on commit d7263f3

Please sign in to comment.