|
1 |
| -# coding: utf-8 |
2 |
| - |
3 |
| -import os |
4 |
| -from setuptools import setup, find_packages |
5 |
| -import importlib |
6 |
| -import re |
7 |
| - |
8 |
| -# Vars to set: |
9 |
| -description = "This project gathers some useful basics Python functions and class." |
10 |
| -author = "hayj" |
11 |
| -author_email = "[email protected]" |
12 |
| -version = None # will be replaced by the version in the main init file if exists |
13 |
| - |
14 |
| -# Current dir: |
15 |
| -thelibFolder = os.path.dirname(os.path.realpath(__file__)) |
16 |
| - |
17 |
| -# We take all requirements from the file or you can set it here : |
18 |
| -requirementPath = thelibFolder + '/requirements.txt' |
19 |
| -install_requires = [] # Example : ["gunicorn", "docutils >= 0.3", "lxml==0.5a7"] |
20 |
| -dependency_links = [] |
21 |
| -if os.path.isfile(requirementPath): |
22 |
| - with open(requirementPath) as f: |
23 |
| - dependency_links = [] |
24 |
| - install_requires = [] |
25 |
| - required = f.read().splitlines() |
26 |
| - for current in required: |
27 |
| - if 'git' in current: |
28 |
| - if "https" not in current: |
29 |
| - current = current.replace("-e git", "https") |
30 |
| - current = current.replace(".git#egg", "/zipball/master#egg") |
31 |
| - dependency_links.append(current) |
32 |
| - else: |
33 |
| - install_requires.append(current) |
34 |
| - |
35 |
| -# dependency_links is deprecated, see https://serverfault.com/questions/608192/pip-install-seems-to-be-ignoring-dependency-links |
36 |
| -dependency_links = [] |
37 |
| - |
38 |
| -# We search a folder containing "__init__.py": |
39 |
| -def walklevel(some_dir, level=1): |
40 |
| - some_dir = some_dir.rstrip(os.path.sep) |
41 |
| - assert os.path.isdir(some_dir) |
42 |
| - num_sep = some_dir.count(os.path.sep) |
43 |
| - for root, dirs, files in os.walk(some_dir): |
44 |
| - yield root, dirs, files |
45 |
| - num_sep_this = root.count(os.path.sep) |
46 |
| - if num_sep + level <= num_sep_this: |
47 |
| - del dirs[:] |
48 |
| -mainPackageName = thelibFolder.lower().split('/')[-1] |
49 |
| -for dirname, dirnames, filenames in walklevel(thelibFolder): |
50 |
| - if "__init__.py" in filenames: |
51 |
| - mainPackageName = dirname.split("/")[-1] |
52 |
| -packagePath = thelibFolder + '/' + mainPackageName |
53 |
| -# Get the version of the lib in the __init__.py: |
54 |
| -initFilePath = packagePath + '/' + "__init__.py" |
55 |
| -if os.path.isdir(packagePath): |
56 |
| - with open(initFilePath, 'r') as f: |
57 |
| - text = f.read() |
58 |
| - result = re.search('^__version__\s*=\s*["\'](.*)["\']', text, flags=re.MULTILINE) |
59 |
| - if result is not None: |
60 |
| - version = result.group(1) |
61 |
| - |
62 |
| -# To import the lib, use: |
63 |
| -# thelib = importlib.import_module(mainPackageName) |
64 |
| - |
65 |
| -# Readme content: |
66 |
| -with open(thelibFolder + '/README.rst', "r") as fh: |
67 |
| - readme = fh.read() |
68 |
| -# readme = None |
69 |
| -# readmePath = thelibFolder + '/README.md' |
70 |
| -# if os.path.isfile(readmePath): |
71 |
| -# try: |
72 |
| -# print("Trying to convert README.md to rst format...") |
73 |
| -# import pypandoc |
74 |
| -# readme = pypandoc.convert(readmePath, 'rst') |
75 |
| -# # with open(readmePath, "r") as fh: |
76 |
| -# # readme = fh.read() |
77 |
| -# except(IOError, ImportError) as e: |
78 |
| -# print(e) |
79 |
| -# print("Cannot use pypandoc to convert the README...") |
80 |
| -# readme = open(readmePath).read() |
81 |
| -# else: |
82 |
| -# print("README.md not found.") |
83 |
| - |
84 |
| -assert version is not None |
85 |
| - |
86 |
| -from pathlib import Path |
87 |
| -this_directory = Path(__file__).parent |
88 |
| -long_description = (this_directory / "README.md").read_text() |
89 |
| - |
90 |
| - |
91 |
| -# The whole setup: |
92 |
| -setup( |
93 |
| - |
94 |
| - # The name for PyPi: |
95 |
| - name="systools", # systemtools, hjsystemtools |
96 |
| - |
97 |
| - # The version of the code which is located in the main __init__.py: |
98 |
| - version=version, |
99 |
| - |
100 |
| - # All packages to add: |
101 |
| - packages=find_packages(), |
102 |
| - |
103 |
| - # About the author: |
104 |
| - author=author, |
105 |
| - author_email=author_email, |
106 |
| - |
107 |
| - # A short desc: |
108 |
| - description=description, |
109 |
| - |
110 |
| - # A long desc with the readme: |
111 |
| - long_description=readme, |
112 |
| - |
113 |
| - # Dependencies: |
114 |
| - install_requires=install_requires, |
115 |
| - dependency_links=dependency_links, |
116 |
| - |
117 |
| - # For handle the MANIFEST.in: |
118 |
| - include_package_data=True, |
119 |
| - |
120 |
| - long_description=long_description, |
121 |
| - long_description_content_type='text/markdown', |
122 |
| - |
123 |
| - # The url to the official repo: |
124 |
| - # url='https://', |
125 |
| - |
126 |
| - # You can choose what you want here : https://pypi.python.org/pypi?%3Aaction=list_classifiers |
127 |
| - classifiers=[ |
128 |
| - "Programming Language :: Python", |
129 |
| - "Development Status :: 1 - Planning", |
130 |
| - "License :: OSI Approved :: MIT License", |
131 |
| - "Natural Language :: English", |
132 |
| - "Operating System :: OS Independent", |
133 |
| - "Programming Language :: Python :: 3.6", |
134 |
| - "Topic :: Utilities", |
135 |
| - ], |
136 |
| - |
137 |
| - # If you want a command line like "do-something", on a specific funct of the package : |
138 |
| -# entry_points = { |
139 |
| -# 'console_scripts': [ |
140 |
| -# 'wm-setup = workspacemanager.setup:generateSetup', |
141 |
| -# 'wm-pew = workspacemanager.venv:generateVenv', |
142 |
| -# 'wm-deps = workspacemanager.deps:installDeps', |
143 |
| -# ], |
144 |
| -# }, |
145 |
| -) |
146 |
| - |
147 |
| - |
148 |
| - |
149 |
| - |
150 |
| - |
151 |
| - |
| 1 | +from setuptools import setup |
152 | 2 |
|
| 3 | +setup() |
0 commit comments