Skip to content
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

Add support for output_path in project file #695

Open
wants to merge 2 commits into
base: master
from

Conversation

@georgeyk
Copy link

commented Oct 3, 2019

Issue(s) Resolved

Fixes #688

Description of Changes

  • Wrote at least one-line docstrings (for any new functions)
  • Added unit test(s) covering the changes (if testable)
  • Included a screenshot or animation (if affecting the UI, see Licecap)
  • Link to corresponding documentation pull request for getlektor.com

Lektor project file now supports "output_path" key.
The preference order will look like:

  • Values set via cli -O/--output-path
  • LEKTOR_OUTPUT_PATH environment variable
  • output_path in lektor project file
  • default cache folder (os-specific)

I haven't found any similar tests in the codebase, so it would be helpful if I get some direction here.

@runfalk

This comment has been minimized.

Copy link
Contributor

commented Oct 4, 2019

Thank you for your contribution!

I haven't tested this yet, but I have a question. How does this work with relative files? Will it depend on where the lektor command is launched, or will it always be relative to the project file?

I think it makes more sense to make it relative to the project file for predictability.

@georgeyk

This comment has been minimized.

Copy link
Author

commented Oct 4, 2019

hey @runfalk
I did some tests using output_path = _build in the project file and invoking lektor inside templates/ folder (for example) and it worked as expected.
Maybe I could add something like:

if not os.path.isabs(output_path):
    output_path = os.path.join(self.project_path, output_path)

It is more explicit, imo.

@runfalk

This comment has been minimized.

Copy link
Contributor

commented Oct 7, 2019

I guess Lektor always changes it's working directory to the project files'. This behavior will likely never change as it could break things. Is this consistent for both lektor server and lektor build?

I like your proposed fix as it is a bit more explicit. I think you don't even need the isabs-check:

>>> os.path.join("/some/abs/path", "/another/abs/path/here")
'/another/abs/path/here'
@georgeyk

This comment has been minimized.

Copy link
Author

commented Oct 8, 2019

Is this consistent for both lektor server and lektor build?

I've played around a bit after the last commit and I think so.
I've configured output_path to a nested folder relative to project-root and also absolute paths nested and on `/tmp/blabla' (build, serve and clean commands).

@runfalk

This comment has been minimized.

Copy link
Contributor

commented Oct 9, 2019

I think this is fine now. I was a bit concerned about the usage of self.open_config() since it makes it impossible to have projects without a project file. However, that functionality seems to have been broken since February 2016 (3 months after the initial commit).

I will merge this after testing it.

@georgeyk

This comment has been minimized.

Copy link
Author

commented Oct 9, 2019

Ok. I'll try to update docs right after.

@georgeyk georgeyk marked this pull request as ready for review Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.