-
-
Notifications
You must be signed in to change notification settings - Fork 328
Projectfile #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Projectfile #39
Conversation
I'll fix the conflicts and make the tests pass. |
Thanks! I'll look this over later after I fix master. My initial impression though is I would prefer to enable interactivity with an |
I think you make a good point. Except the package name and the description all the other questions are pretty static and it can be supplied by the config file. I'll change the behavior to add a |
The tests are now passing. But I haven't added new tests to cover the code that I have added. I'll work on adding tests tomorrow. In the meantime, I welcome any comments or suggestions. |
I've added tests to the interactive init command. I have also fixed the failing tests. The PR is pretty big. I'm happy to do a screen share and walk you through the main points if you're interested. I'll add more tests to the interactive new command as well, but I think this PR is ready for your review. |
hatch/commands/init.py
Outdated
@@ -14,7 +14,7 @@ | |||
|
|||
@click.command(context_settings=CONTEXT_SETTINGS, | |||
short_help='Creates a new Python project in the current directory') | |||
@click.argument('name') | |||
@click.argument('name', nargs=-1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required=False
hatch/commands/new.py
Outdated
@@ -15,7 +15,7 @@ | |||
|
|||
@click.command(context_settings=CONTEXT_SETTINGS, | |||
short_help='Creates a new Python project') | |||
@click.argument('name') | |||
@click.argument('name', nargs=-1, default=None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required=False
hatch/commands/init.py
Outdated
package_name = name[0] | ||
|
||
if interactive or not name: | ||
pname = os.path.split(cwd)[-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use basepath
from hatch.utils
hatch/files/vc/git.py
Outdated
shell=NEED_SUBPROCESS_SHELL) | ||
return email.strip().decode('utf-8') | ||
except: | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! Just return
instead of return None
and add # no cov
to each function definition.
hatch/settings.py
Outdated
@@ -19,8 +20,8 @@ | |||
('build', ''), | |||
])), | |||
('pypi_username', ''), | |||
('name', 'U.N. Owen'), | |||
('email', '[email protected]'), | |||
('author', get_user() or 'U.N. Owen'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the decision here, but can we please keep it as before? It would be a breaking change.
In init and new command files can you please change You can then use the default settings in the functions. |
After those changes, we also need to make ourselves the Here are some examples I've found:
|
tests/files/licenses/test_apache2.py
Outdated
@@ -25,7 +25,7 @@ def test_name(): | |||
with temp_chdir() as d: | |||
settings = copy_default_settings() | |||
settings['licenses'] = ['apache2'] | |||
settings['name'] = 'Don Quixote' | |||
settings['author'] = 'Don Quixote' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too
tests/files/licenses/test_cc0.py
Outdated
@@ -25,7 +25,7 @@ def test_name(): | |||
with temp_chdir() as d: | |||
settings = copy_default_settings() | |||
settings['licenses'] = ['cc0'] | |||
settings['name'] = 'Guy Fawkes' | |||
settings['author'] = 'Guy Fawkes' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too
tests/files/licenses/test_mit.py
Outdated
@@ -25,7 +25,7 @@ def test_name(): | |||
with temp_chdir() as d: | |||
settings = copy_default_settings() | |||
settings['licenses'] = ['mit'] | |||
settings['name'] = 'Don Quixote' | |||
settings['author'] = 'Don Quixote' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too
tests/files/licenses/test_mpl.py
Outdated
@@ -25,7 +25,7 @@ def test_name(): | |||
with temp_chdir() as d: | |||
settings = copy_default_settings() | |||
settings['licenses'] = ['mpl'] | |||
settings['name'] = 'Red Panda' | |||
settings['author'] = 'Red Panda' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too
Sorry, I missed a few. |
Looks great! We just need to change the So, initially I was thinking we could have metadata and commands, but exclude packages for when Hatch supports Pipfiles. Sound good? |
Looks like one test is failing on one Python36-x64 Appveyor. Looks to me it's a timeout failure. Can you take a look? |
That's just virtualenv being slow, it happens sometimes :/ |
hatch/commands/new.py
Outdated
|
||
if os.path.exists(d): | ||
echo_failure('Directory `{}` already exists.'.format(d)) | ||
sys.exit(1) | ||
|
||
if licenses: | ||
settings['licenses'] = map(str.strip, licenses.split(',')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In init
this comes after the interactive branch. What do you want to give precedence?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user runs this:
hatch init -i -l 'mit,mpl'
Hatch will use the mit,mpl
as the default value during the interactive mode. If the user chooses to override it during the interactive mode then the overridden value from the interactive mode will be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now the thing is that in new
the if licenses
comes before the if interactive
but in init
it's the opposite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. They were functionally equivalent. But I've changed the code to match the same pattern in both files.
tests/commands/test_init.py
Outdated
runner.invoke(hatch, ['init', '-i', '--basic', '-ne'], input='ok\n0.1.0\nTest Description\nPicard\[email protected]\nmpl\n') | ||
|
||
assert os.path.exists(os.path.join(d, 'ok', '__init__.py')) | ||
assert "__version__ = '0.1.0'\n" == open(os.path.join(d, 'ok', '__init__.py')).read() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests/commands/test_new.py
Outdated
runner.invoke(hatch, ['new', '-i', '--basic', '-ne'], input='ok\n0.1.0\nTest Description\nPicard\[email protected]\nmpl\n') | ||
|
||
assert os.path.exists(os.path.join(d, 'ok', 'ok', '__init__.py')) | ||
assert "__version__ = '0.1.0'\n" == open(os.path.join(d, 'ok', 'ok', '__init__.py')).read() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks great except the [build-system]
requires = ["setuptools", "wheel"] and put metadata right under |
Tests failing due to source -> metadata change. |
WooHoo!! 🎉 |
Description
This will make the
init
command and thenew
command interactive.Checklist