-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06c913f
commit 1bab3ea
Showing
6 changed files
with
85 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
.idea | ||
*.iml | ||
*.pyc | ||
/build/ | ||
/dist/ | ||
|
||
*.egg-info | ||
|
||
*.egg | ||
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[bdist_wheel] | ||
universal = 1 | ||
|
||
[metadata] | ||
name = alias-windows | ||
version = attr: alias.__version__ | ||
license = MIT | ||
license_file = LICENSE.md | ||
description = Manage command aliases in Windows | ||
long_description = file: README.md | ||
long_description_content_type = text/markdown | ||
author = alexesprit | ||
url = https://github.com/alexesprit/alias | ||
classifiers = | ||
Programming Language :: Python :: 3 | ||
License :: OSI Approved :: MIT License | ||
Operating System :: Microsoft :: Windows | ||
|
||
[options] | ||
package_dir= | ||
=src | ||
packages = find: | ||
|
||
python_requires = >=3.6 | ||
|
||
[options.packages.find] | ||
where = src | ||
|
||
[options.entry_points] | ||
console_scripts = | ||
alias = alias.alias:main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
import sys | ||
|
||
from setuptools import setup | ||
from setuptools.command.install import install | ||
|
||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src')) | ||
|
||
|
||
from alias import ALIASES_DIR_VAR # noqa: E402 | ||
from alias import get_aliases_dir # noqa: E402 | ||
|
||
|
||
def set_env_var(var, value): | ||
os.system(f'setx {var} "{value}"') | ||
|
||
|
||
class PostInstallCommand(install): | ||
"""Post-installation for installation mode.""" | ||
def run(self): | ||
install.run(self) | ||
|
||
if ALIASES_DIR_VAR not in os.environ: | ||
aliases_dir = get_aliases_dir() | ||
set_env_var(ALIASES_DIR_VAR, aliases_dir) | ||
|
||
|
||
setup( | ||
cmdclass={ | ||
'install': PostInstallCommand, | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import os | ||
|
||
__version__ = '1.0.0' | ||
|
||
ALIASES_DIR_VAR = 'ALIASES_DIR' | ||
ALIASES_DIR_MACRO = '%USERPROFILE%\\Documents\\Scripts\\Aliases' | ||
|
||
|
||
def get_aliases_dir(): | ||
aliases_dir = os.getenv(ALIASES_DIR_VAR) | ||
if not aliases_dir: | ||
aliases_dir = os.path.expandvars(ALIASES_DIR_MACRO) | ||
return aliases_dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters