Skip to content

Commit ac374f8

Browse files
author
Peter F
authored
Merge pull request #41 from PFython/feature/name-and-email-not-recalled-when
Improved initial name and folder handling/recall
2 parents b04e8ac + f8e1c38 commit ac374f8

File tree

4 files changed

+41
-13
lines changed

4 files changed

+41
-13
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,3 +397,24 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
397397
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
398398
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
399399
SOFTWARE.
400+
MIT License
401+
402+
Copyright (c) 2021 Peter Fison
403+
404+
Permission is hereby granted, free of charge, to any person obtaining a copy
405+
of this software and associated documentation files (the "Software"), to deal
406+
in the Software without restriction, including without limitation the rights
407+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
408+
copies of the Software, and to permit persons to whom the Software is
409+
furnished to do so, subject to the following conditions:
410+
411+
The above copyright notice and this permission notice shall be included in all
412+
copies or substantial portions of the Software.
413+
414+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
415+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
416+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
417+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
418+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
419+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
420+
SOFTWARE.

easypypi/easypypi.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ def __init__(self, name=None, **kwargs):
5050
super().__init__(**kwargs)
5151
if name:
5252
self.name = name
53-
else:
54-
self.name = sg.popup_get_text(
55-
"Please enter a name for this package (all lowercase, underscores if needed):",
56-
default_text=self.get("name") or "as_easy_as_pie",
57-
**SG_KWARGS,
58-
)
5953
self.load_defaults()
6054
print(
6155
f"\n ⓘ easyPyPI template files are located in:\n {self.__class__.easypypi_dirpath}",
@@ -124,8 +118,19 @@ def load_defaults(self):
124118
Entry point for loading default Package values as attributes.
125119
Choose between last updated JSON config file, and setup.py if it exists.
126120
"""
121+
name = self.get('name')
127122
self.create_skeleton_config_file()
128123
self.load_defaults_from_config_file()
124+
if not name:
125+
# i.e. no name previously saved in config.json and none supplied
126+
self.name = sg.popup_get_text(
127+
"Please enter a name for this package (all lowercase, underscores if needed):",
128+
default_text=self.get("name") or "as_easy_as_pie",
129+
**SG_KWARGS,
130+
)
131+
elif name:
132+
# i.e. name supplied -> use instead of previously saved name
133+
self.name = name
129134
self.create_folder_structure()
130135
if self.setup_filepath.is_file() and self.setup_filepath.stat().st_size:
131136
# If setup.py exists & isn't empty, overwrite default values
@@ -321,11 +326,13 @@ def setup_filepath(self):
321326
return Path(self.setup_filepath_str)
322327

323328
def get_default_filepath(self):
324-
path = Path(self.get("setup_filepath_str") or Path().cwd())
325329
# Default path should be the parent of self.name and not include it
326-
while path.parts[-1] in [self.name, "setup.py"]:
327-
path = Path().joinpath(*path.parts[:-1])
328-
return str(path)
330+
path = self.get("setup_filepath_str")
331+
if path:
332+
return str(Path(self.get("setup_filepath_str")).parent.parent)
333+
else:
334+
return os.getcwd()
335+
329336

330337
def get_default_version(self):
331338
return "0.0.1a1"

easypypi/setup_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ def comma_split(text: str):
4444
keywords=comma_split(KEYWORDS),
4545
install_requires=comma_split(REQUIREMENTS),
4646
classifiers=comma_split(CLASSIFIERS),
47-
package_data={"": ["README.md", "*.png", "*.ico"], NAME: ["*.*"]},
47+
package_data={"": ["*.md", "*.json", "*.png", "*.ico"], NAME: ["*.*"]},
4848
)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
HERE = Path(__file__).parent
99
NAME = "easypypi"
1010
GITHUB_USERNAME = "Pfython"
11-
VERSION = "2.0.4a11"
11+
VERSION = "2.0.4"
1212
DESCRIPTION = "By FAR the easiest and quickest way to publish your Python creations on PyPI so other people can just `pip install your_script`."
1313
LICENSE = "MIT License"
1414
AUTHOR = "Peter Fison"
@@ -45,5 +45,5 @@ def comma_split(text: str):
4545
keywords=comma_split(KEYWORDS),
4646
install_requires=comma_split(REQUIREMENTS),
4747
classifiers=comma_split(CLASSIFIERS),
48-
package_data={"": ["README.md", "*.png", "*.ico"], NAME: ["*.*"]},
48+
package_data={"": ["*.md", "*.json", "*.png", "*.ico"], NAME: ["*.*"]},
4949
)

0 commit comments

Comments
 (0)