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

BF: Do not rely on having sources under ./src and __main__.py to be executable #196

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

yarikoptic
Copy link
Member

@yarikoptic yarikoptic commented Oct 3, 2024

Bad assumption since assumes running tests from the route of source distribution, that the __main__.py is executable and that sources are right nearby. Pretty much all of those assumptions are violated during testing of built python package during debian packaging.

No immediate release necessary -- I will just pickup this patch for now

…xecutable

Bad assumption since assumes running tests from the route of source
distribution, that the __main__.py is executable and that sources are right
nearby.  Pretty much all of those assumptions are violated during testing of
built python package during debian packaging.
@yarikoptic yarikoptic added the semver-patch Increment the patch version when merged label Oct 3, 2024
@yarikoptic yarikoptic requested a review from asmacdo October 3, 2024 00:50
Copy link

codecov bot commented Oct 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.46%. Comparing base (84fb8d2) to head (3b79a6f).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #196   +/-   ##
=======================================
  Coverage   95.46%   95.46%           
=======================================
  Files           1        1           
  Lines         529      529           
  Branches       84       84           
=======================================
  Hits          505      505           
  Misses         12       12           
  Partials       12       12           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -227,6 +229,6 @@ def runner() -> int:


def test_duct_as_executable(temp_output_dir: str) -> None:
ps_command = f"./src/con_duct/__main__.py -p {temp_output_dir} sleep 0.01"
ps_command = f"{sys.executable} {__main__.__file__} -p {temp_output_dir} sleep 0.01"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this the equivalent of 'python thefile.py'?

This makes sense to use the same version of python, but IIUC it doesn't prove the direct executability of the file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this the equivalent of 'python thefile.py'?

yes

This makes sense to use the same version of python, but IIUC it doesn't prove the direct executability of the file.

you are correct if by "executability" you mean an executable permissions/use of shebang. The problem is that AFAIK that executable permission does not get copied while building/deploying con-duct so I had to specify the interpreter (sys.executable) directly to get it running. The main point of the test though IMHO to verify that the script is "self sufficient" and does not rely on imports (ideally we should even copy it outside somewhere and run from there... later)

@yarikoptic yarikoptic merged commit 234d237 into main Oct 3, 2024
15 of 16 checks passed
@asmacdo asmacdo deleted the bf-test-exec branch October 4, 2024 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-patch Increment the patch version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants