Removing cookiecutter-generated requirements
This commit is contained in:
parent
1d3a943e74
commit
91b31d9d51
|
@ -1,10 +0,0 @@
|
||||||
pip==8.1.2
|
|
||||||
bumpversion==0.5.3
|
|
||||||
wheel==0.29.0
|
|
||||||
watchdog==0.8.3
|
|
||||||
flake8==2.6.0
|
|
||||||
tox==2.3.1
|
|
||||||
coverage==4.1
|
|
||||||
Sphinx==1.4.8
|
|
||||||
|
|
||||||
|
|
43
setup.py
43
setup.py
|
@ -21,10 +21,11 @@ import zipfile
|
||||||
|
|
||||||
|
|
||||||
GECKO_RELEASE_PATH = "https://github.com/mozilla/geckodriver"
|
GECKO_RELEASE_PATH = "https://github.com/mozilla/geckodriver"
|
||||||
PKG_NAME = "bot_z"
|
PKG_NAME = 'bot_z'
|
||||||
VERSION = "0.1.0"
|
VERSION = '0.1.0'
|
||||||
AUTHOR = "blallo"
|
AUTHOR = 'blallo'
|
||||||
AUTHOR_EMAIL = "blallo@autistici.org"
|
AUTHOR_EMAIL = 'blallo@autistici.org'
|
||||||
|
BIN_PATH = 'bin/geckodriver'
|
||||||
|
|
||||||
with open("README.md") as readme_file:
|
with open("README.md") as readme_file:
|
||||||
readme = readme_file.read()
|
readme = readme_file.read()
|
||||||
|
@ -93,11 +94,13 @@ def verify_if_superuser() -> bool:
|
||||||
return _uid == 0 or _euid == 0
|
return _uid == 0 or _euid == 0
|
||||||
|
|
||||||
|
|
||||||
def create_local_folder() -> None:
|
def ensure_local_folder() -> None:
|
||||||
"""
|
"""
|
||||||
Create a bin/ folder in the current package installation path.
|
Create a bin/ folder in the current package installation path.
|
||||||
"""
|
"""
|
||||||
bin_path = pkg_resources.resource_filename(PKG_NAME, BIN_PATH)
|
bin_path = pkg_resources.resource_filename(PKG_NAME, BIN_PATH)
|
||||||
|
print("[LOCAL_FOLDER] ensuring local folder: {}".format(bin_path))
|
||||||
|
pkg_resources.ensure_directory(bin_path)
|
||||||
|
|
||||||
|
|
||||||
def assemble_driver_uri(
|
def assemble_driver_uri(
|
||||||
|
@ -148,15 +151,15 @@ def download_driver_bin(uri: str, path: str) -> None:
|
||||||
os.remove(filepath)
|
os.remove(filepath)
|
||||||
|
|
||||||
|
|
||||||
def postinstall(platform: T.Optional[str] = None) -> None:
|
def preinstall(platform: T.Optional[str]=None) -> None:
|
||||||
"""
|
"""
|
||||||
Performs all the postintallation flow, donwloading in the
|
Performs all the postintallation flow, donwloading in the
|
||||||
right place the geckodriver binary.
|
right place the geckodriver binary.
|
||||||
"""
|
"""
|
||||||
# target_path = os.path.join(os.path.abspath(os.path.curdir), 'bot_z', 'bin')
|
# target_path = os.path.join(os.path.abspath(os.path.curdir), 'bot_z', 'bin')
|
||||||
target_path = pkg_resources.resource_filename("bot_z", "bin")
|
target_path = pkg_resources.resource_filename('bot_z', 'bin')
|
||||||
pkg_resources.ensure_directory(os.path.join(target_path, "target"))
|
ensure_local_folder()
|
||||||
version = os.environ.get("BOTZ_GECKO_VERSION")
|
version = os.environ.get('BOTZ_GECKO_VERSION')
|
||||||
gecko_uri = assemble_driver_uri(version, platform)
|
gecko_uri = assemble_driver_uri(version, platform)
|
||||||
print("[POSTINSTALL] gecko_uri: {}".format(gecko_uri))
|
print("[POSTINSTALL] gecko_uri: {}".format(gecko_uri))
|
||||||
download_driver_bin(gecko_uri, target_path)
|
download_driver_bin(gecko_uri, target_path)
|
||||||
|
@ -167,6 +170,9 @@ def translate_platform_to_gecko_vers(plat: str) -> str:
|
||||||
Map appropriately the platform provided on the command line
|
Map appropriately the platform provided on the command line
|
||||||
to the one used by PEP 513.
|
to the one used by PEP 513.
|
||||||
"""
|
"""
|
||||||
|
if plat is None:
|
||||||
|
return None
|
||||||
|
|
||||||
PLATS = {
|
PLATS = {
|
||||||
"win32": "win32",
|
"win32": "win32",
|
||||||
"win-amd64": "win64",
|
"win-amd64": "win64",
|
||||||
|
@ -186,22 +192,23 @@ class CustomDevelopCommand(develop):
|
||||||
"""Custom installation for development mode."""
|
"""Custom installation for development mode."""
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
super().run()
|
|
||||||
print("POSTINSTALL")
|
print("POSTINSTALL")
|
||||||
postinstall()
|
preinstall()
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
class CustomInstallCommand(install):
|
class CustomInstallCommand(install):
|
||||||
"""Custom installation for installation mode."""
|
"""Custom installation for installation mode."""
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
super().run()
|
|
||||||
opts = self.distribution.get_cmdline_options()
|
opts = self.distribution.get_cmdline_options()
|
||||||
if "bdist_wheel" in opts:
|
platform = None
|
||||||
|
if 'bdist_wheel' in opts:
|
||||||
platform = translate_platform_to_gecko_vers(
|
platform = translate_platform_to_gecko_vers(
|
||||||
opts["bdist_wheel"].get("plat-name")
|
opts["bdist_wheel"].get("plat-name")
|
||||||
)
|
)
|
||||||
postinstall(platform)
|
preinstall(platform)
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
# From: https://stackoverflow.com/a/45150383
|
# From: https://stackoverflow.com/a/45150383
|
||||||
|
@ -235,8 +242,12 @@ setup(
|
||||||
"install": CustomInstallCommand,
|
"install": CustomInstallCommand,
|
||||||
"bdist_wheel": CustomBDistWheel,
|
"bdist_wheel": CustomBDistWheel,
|
||||||
},
|
},
|
||||||
entry_points={"console_scripts": ["bot_z=bot_z.cli:main"]},
|
entry_points={
|
||||||
package_data={"bot_z": ["bot_z/bin/geckodriver"]},
|
'console_scripts': [
|
||||||
|
'bot_z=bot_z.cli:main'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
package_data = {'bot_z': ['bin/geckodriver']},
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
install_requires=requirements,
|
install_requires=requirements,
|
||||||
license="GLWTS Public Licence",
|
license="GLWTS Public Licence",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user