-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Implement extended install option #4740
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
Implement extended install option #4740
Conversation
I think this is ready for review, I have tested it with some projects locally. The got a little big, but mostly because of the tests. What I did:
|
64d39db
to
f99afe4
Compare
readthedocs/config/models.py
Outdated
@@ -11,11 +11,24 @@ | |||
'Python', | |||
[ | |||
'version', | |||
'install', |
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.
This is a list, not completely satisfy with this name, any suggestion for rename or if it's fine to let that name are welcome p:
readthedocs/config/config.py
Outdated
if raw_install: | ||
# Transform to a dict, so it's easy to validate extra keys. | ||
self.raw_config.setdefault('python', {})['install'] = ( | ||
_list_to_dict(raw_install) |
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.
^ what my comment says
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 think it's not a good idea to change the raw_config
object. By doing this, it won't be "raw" anymore and it will bring potential confusions.
I understand that the raw_config
is the user's YAML parsed into a Python object (without being touched by us).
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.
Also, checking the validate_python_install
I think this can be accessed by an index instead of a key without need to modify the original config object.
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.
We can't access by the index because of pop_config, it needs to pop recursively, and we need to keep the track of the index (if index 3 is deleted, the index 4 passes to be 3, we don't want that). I guess I could create a copy.
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.
OK. I see what you mean.
I don't really like the solution because it modifies the original structure and it's confusing to me but on the other hand, I don't have a better idea in my mind at the moment :(
@@ -63,13 +68,27 @@ def delete_existing_venv_dir(self): | |||
)) | |||
shutil.rmtree(venv_dir) | |||
|
|||
def install_package(self): | |||
if (self.config.python.install_with_pip or | |||
getattr(settings, 'USE_PIP_INSTALL', False)): |
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 almost forgot I removed this (it wasn't correctly setup there anyway). We have the config file v1 and v2 to install using pip, not sure if this is used, we can remove this (there are some docs that need to be updated too)
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.
It's not clear why this can be removed, could you expand on this?
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.
We have https://docs.readthedocs.io/en/latest/settings.html#use-pip-install, but the logic wasn't correct, I mean, I think this was used when we didn't have a config object, and this will change the behavior of the config from the web Install project using setup
to use pip instead. So, this will invert that setting, but now we have the two settings, install with pip or setup, so, we can't guess or rely on install_with_setup
or whatever to invert the meaning.
I think the logic before the refactor to support v2 was correct and was inverting the behavior if the user has the config from the web marked as install with setup
that should work.
This looks like something not so useful now, and if someone was relying on it it was only on a custom installation. If you think this is still useful and the logic should be fixed, I can check for this flag when setting the defaults (here we can distingue the configs from the web)
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 don't think we need the setting, we're not using this in production.
Regarding the database setting, I think we should be using this. As far as I can tell we aren't using that in this PR?
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.
We are passig the value as default for v1 here https://github.com/rtfd/readthedocs.org/blob/4031b9078efba9948301e89c948a236671086d26/readthedocs/doc_builder/config.py#L49-L49
Ans v1 is setting that value here
Codecov Report
@@ Coverage Diff @@
## master #4740 +/- ##
==========================================
- Coverage 77.01% 76.93% -0.08%
==========================================
Files 158 159 +1
Lines 10082 10004 -78
Branches 1267 1257 -10
==========================================
- Hits 7765 7697 -68
+ Misses 1988 1973 -15
- Partials 329 334 +5
|
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.
This code looks good to me and I think we can merge it.
Although, I'd like to have another member of the @rtfd/core to review it since its a good amount of code and having more eyes on it would be good.
Also, I left some opinions on things that I don't like too much and suggestions to improve the code but I don't think they are 100% strict to be done right now.
There is only one thing missing discussing here
Issue #2776 Actually we could just address this later, but just in case. |
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.
This looks good to me. I don't fully follow the validation changes, but the tests seem to prove it works :)
with self.catch_validation_error(key): | ||
validate_dict(raw_install) | ||
|
||
if 'requirements' in raw_install: |
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.
We could likely use constants for requirements
and path
, but not worth blocking this PR on.
Can I merge this after today's deploy? |
@stsewd I'm +1 on merging, after fixing conflicts. |
This implements the schema change of #4732
Ref #4354
TODO