-
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.
refactored to be able to install package
Signed-off-by: Marcel Müller <[email protected]>
- Loading branch information
Showing
7 changed files
with
164 additions
and
45 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[build-system] | ||
requires = ["setuptools"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.mypy] | ||
check_untyped_defs = true | ||
disallow_any_generics = true | ||
disallow_incomplete_defs = true | ||
disallow_untyped_defs = true | ||
warn_redundant_casts = true | ||
warn_unreachable = true | ||
warn_unused_ignores = true |
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,41 @@ | ||
[metadata] | ||
name = getrandompcmol | ||
version = attr: getrandompcmol.__version__.__version__ | ||
long_description = file: README.md | ||
long_description_content_type = text/markdown | ||
author = "Marcel Müller" | ||
license = GPL-3.0 | ||
license_files = LICENSE | ||
classifiers = | ||
License :: OSI Approved :: GNU General Public License v3 (GPLv3) | ||
Programming Language :: Python | ||
Programming Language :: Python :: 3 | ||
Programming Language :: Python :: 3 :: Only | ||
Programming Language :: Python :: 3.8 | ||
Programming Language :: Python :: 3.9 | ||
Programming Language :: Python :: 3.10 | ||
Programming Language :: Python :: 3.11 | ||
Topic :: Scientific/Engineering | ||
Typing :: Typed | ||
|
||
[options] | ||
packages = find: | ||
install_requires = | ||
numpy | ||
python_requires = >=3.8 | ||
include_package_data = True | ||
package_dir = | ||
=src | ||
|
||
[options.packages.find] | ||
where = src | ||
|
||
[options.entry_points] | ||
console_scripts = | ||
getrandompcmol = getrandompcmol:console_entry_point | ||
|
||
[options.extras_require] | ||
dev = | ||
black | ||
pre-commit | ||
pylint |
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,4 @@ | ||
from setuptools import setup | ||
|
||
if __name__ == "__main__": | ||
setup() |
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,10 @@ | ||
""" | ||
GetRandomPCMol | ||
======= | ||
Dummy command line tool to square a number. | ||
""" | ||
|
||
from .__version__ import __version__ | ||
from .miscelleanous import chdir, create_directory | ||
from .randommols import console_entry_point, 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,5 @@ | ||
""" | ||
Module containing the version string. | ||
""" | ||
|
||
__version__ = "0.1.0" |
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,46 @@ | ||
""" | ||
Miscelleanous functions that are used in the project. | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import os | ||
|
||
|
||
def create_directory(name: str) -> bool: | ||
""" | ||
Creates a directory with the given name if it does not exist already. | ||
""" | ||
if not os.path.exists(name): | ||
os.mkdir(name) | ||
exist = False | ||
else: | ||
print(f"Directory {name} already exists.") | ||
exist = True | ||
|
||
# check if the new directory exists and raise an error and stop execution if not | ||
try: | ||
if not os.path.exists(name): | ||
raise FileNotFoundError(f"Directory {name} does not exist.") | ||
except FileNotFoundError as e: | ||
print(f"Error: {e}") | ||
raise SystemExit(1) from e | ||
return exist | ||
|
||
|
||
# define a function which goes back to the original working directory if it is called | ||
def chdir(dirname: str) -> None: | ||
""" | ||
Change the active directory. | ||
""" | ||
try: | ||
os.chdir(str(dirname)) | ||
# print("Current working directory: {0}".format(os.getcwd())) | ||
except FileNotFoundError: | ||
print(f"Directory: {dirname} does not exist") | ||
except NotADirectoryError: | ||
print(f"{dirname} is not a directory") | ||
except PermissionError: | ||
print(f"You do not have permissions to change to {dirname}") | ||
|
||
return None |
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