Add Python package#87
Conversation
|
@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this in D84891338. (Because this pull request was imported automatically, there will not be any future comments.) |
I have accepted this invitation, but I won't complete the ownership transfer until this gets merged in. I am pretty happy with how this looks at a quick glance, but I will do a more thorough review next week. I will probably open a PR on your fork to address some of the devcontainer stuff I see that should be addressed with this as well. |
|
Thanks, sounds good! I pushed some final cleanup changes like making sure the licenses are shipped with each wheel. |
sdwilsh
left a comment
There was a problem hiding this comment.
back to you for mostly minor stuff. This is great, and thanks for putting it together!
| line-length = 120 | ||
|
|
||
| [lint.flake8-tidy-imports] | ||
| ban-relative-imports = "all" | ||
|
|
||
| [lint.isort] | ||
| known-first-party = ["dotslash"] |
There was a problem hiding this comment.
Annoyingly, we don't seem to have a global ruff.toml file that I can just have included by default. Internal linters are not upset with the formatting here, so it's fine, but something for me to look into in the future I guess -_-
There was a problem hiding this comment.
We should enable ufmt: https://ufmt.omnilib.dev/en/stable/
(unfortunately, private wiki links follow)
@sdwilsh see: https://www.internalfb.com/wiki/Python/code_formatting/ruff/
We should follow this wiki: https://www.internalfb.com/wiki/Python/code_formatting/pyfmt/#replicating-pyfmt-in-ope
Which will require updating the imported Diff a bit. @sdwilsh do you have capacity to go do that?
There was a problem hiding this comment.
Is Ruff unsupported internally i.e. you must use ufmt?
There was a problem hiding this comment.
Ah, this makes sense. All the ruff things I saw were for other open source projects.
There was a problem hiding this comment.
I will see if I can get this working today. I'm unfortunately off tomorrow, so if it doesn't happen today, I'll get it resolved on Monday.
There was a problem hiding this comment.
It looks like ufmt can use ruff, if I'm reading the internal wiki properly, so I will see about making this work today.
bigfootjon
left a comment
There was a problem hiding this comment.
Looks reasonable, but I think we need to reflect pyfmt correctly. I don't really have capacity right now but Shawn might
(sorry for how long it took to review this PR)
| line-length = 120 | ||
|
|
||
| [lint.flake8-tidy-imports] | ||
| ban-relative-imports = "all" | ||
|
|
||
| [lint.isort] | ||
| known-first-party = ["dotslash"] |
There was a problem hiding this comment.
We should enable ufmt: https://ufmt.omnilib.dev/en/stable/
(unfortunately, private wiki links follow)
@sdwilsh see: https://www.internalfb.com/wiki/Python/code_formatting/ruff/
We should follow this wiki: https://www.internalfb.com/wiki/Python/code_formatting/pyfmt/#replicating-pyfmt-in-ope
Which will require updating the imported Diff a bit. @sdwilsh do you have capacity to go do that?
|
Okay, I think I addressed everything now! The only exception is the Ruff/ufmt feedback but as you know I don't have access to the documentation on what needs doing. |
|
@sdwilsh can you re-review? And message me internally about what to do about the formatter stuff? |
We need these to properly format Python code in #87.
Co-authored-by: Ofek Lev <ofekmeister@gmail.com>
|
My TODO list is longer than I have time left today, but I should be able to get this wrapped up tomorrow. I'll have to make one additional internal change to land this to get the formatting internally to not fight with the external formatter. |
| @@ -0,0 +1,44 @@ | |||
| --- | |||
| name: Test Python | |||
There was a problem hiding this comment.
I'm somewhat partial to doing this in the devcontainer workflow, but I'm not going to block merging this on that.
| [](https://pypi.org/project/dotslash/) | ||
| [](https://pypi.org/project/dotslash/) | ||
| [](https://github.com/pypa/hatch) | ||
| [](https://github.com/astral-sh/ruff) |
There was a problem hiding this comment.
This isn't right anymore, is it? I guess technically we kinda do use ruff via ufmt, so maybe it sorta is? I won't block on this; we can fix it post merge.
There was a problem hiding this comment.
I don't think the badge requires the direct use of the CLI, as long as the tool is used.
|
Despite my best efforts, the internal linter still changed two pieces of python code. I'm going to land it internally anyway, and I'll debug what setting we need to fix externally once this is merged. |
|
I guess the good news is that the GitHub lint is also happy with the changes the internal linter made. Hurray? That will probably be a problem for future me at some point, but it's good enough for now :D Thanks for this contribution, @ofek! And thanks to both @di and @amyreese for helping along the way! |
|
Thanks a lot everyone! |
Hello again! This is the second half of what we require in order to start using DotSlash.
This moves over the code for the
dotslashPython package I created over the weekend. The ownership transfer on PyPI is in progress.The package serves a similar purpose to the existing
fb-dotslashNode.js package stored in the top levelnodedirectory. Some notes:locatefunction for finding the path to the binary that was installed by the installation. The logic was adapted from equivalents like UV's finder. I optimized the path resolution to perform as little work as necessary and to do so lazily.python -m dotslash. If there ever is a desire to represent paths as anything other than strings in the implementation, please don't.DOTSLASH_VERSIONenvironment variable to the desired release tag of DotSlash (thevis optional). This will be used as the package version and, by default, for fetching the appropriate release artifact.DOTSLASH_SOURCEenvironment variable to the path to a directory containing the release artifacts. I strongly recommend that the release process uses that eventually (and the Node.js package's build script gains support).release-downstream.ymlworkflow from this repository. You might find hazy details about their support for reusable workflows but this comment provides the full picture. Basically, the claim they chose happens to work for the most nested called workflow when using reusable workflows but not the top level one. Whenever support for that happens there will be no user impact for existing supported scenarios.cc @sdwilsh @bigfootjon for review as requested
Also, it's worth noting that PyPI was blocking the name
dotslashdue to certain rules and @di very graciously provided the override 🙇♂️