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

python: Switch to pyproject.toml #290

Closed
wants to merge 13 commits into from
Closed

Conversation

youtux
Copy link
Contributor

@youtux youtux commented Sep 28, 2024

Fixes #289

Notes:
I had to remove the bin/gherkin executable since that doesn't work with pyproject.toml (scripts can only be python entrypoints). But I replaced with the correct annotation in pyproject.toml, so if you install the package, the script will be automatically installed in the venv too

I uploaded the package built using python -m build to https://test.pypi.org/project/youtux.gherkin-official/, in case somebody wants to check how it will look on PyPI or to try it out.

🤔 What's changed?

⚡️ What's your motivation?

🏷️ What kind of change is this?

  • 🏦 Refactoring/debt/DX (improvement to code design, tooling, etc. without changing behaviour)

♻️ Anything particular you want feedback on?

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

This text was originally generated from a template, then edited by hand. You can modify the template here.

I had to remove the `bin/gherkin` executable since that doesn't work with pyproject.toml (scripts can only be python entrypoints). But I replaced with the correct annotation in pyproject.toml, so if you install the package, the script will be automatically installed in the venv too
@jenisys
Copy link
Contributor

jenisys commented Sep 28, 2024

Just a comment:

  • You did not need to remove the bin/gherkin shell script.
  • pyproject.toml just needs to generate a python-script instead (which you did).
  • If it makes sense and is of any use for the local developer, keep the original bin/gherkin script or provide a simple python script (equivalent what is generated by install this package).

@jenisys jenisys self-requested a review September 28, 2024 11:43
@jenisys
Copy link
Contributor

jenisys commented Sep 28, 2024

RELATED TO: pyproject.toml

  • Line: scripts = { gherkin = "gherkin" } is probably wrong, I think.
  • You need a main() function (or another function in gherkin.__main__.py)
  • You need to use instead (and correct the weird double-quotes below):
[project.scripts]
gherkin = “gherkin.__main__:main”

Copy link
Contributor

@jenisys jenisys left a comment

Choose a reason for hiding this comment

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

This line is probably wrong and you need a main() function in gherkin.__main__.py (AFAIK; or any other function that you can refer to).
See comment in the comments section.

@jenisys jenisys self-requested a review September 28, 2024 12:04
We don't need to distribute these scripts as entry points. It's unlikely that any of our users need these, as they are just used internally for acceptance test.

Instead, let's move them to the package `gherkin.scripts`, and invoke them using `python -m gherkin.scripts.xxx`
@youtux
Copy link
Contributor Author

youtux commented Sep 28, 2024

So, given these scripts are only used internally by acceptance tests, I removed them from the entrypoints, so that we wont't try to install the gherkin executable in our users' virtualenv, since it's completely useless to them.

I adjusted our makefile accordingly to instead call python -m gherkin.scripts.gherkin and python -m gherkin.scripts.generate_tokens

@youtux
Copy link
Contributor Author

youtux commented Sep 28, 2024

@jenisys can you review again?

@jenisys
Copy link
Contributor

jenisys commented Sep 29, 2024

REVIEWED AGAIN: see the comments.

@jenisys jenisys marked this pull request as draft September 29, 2024 07:18
@jenisys jenisys assigned jenisys and unassigned jenisys Sep 29, 2024
Copy link
Contributor

@jenisys jenisys left a comment

Choose a reason for hiding this comment

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

See comments:

  • Package name was corrected to original package name.
  • Specify package scripts in pyproject.toml instead of leaving the user alone.
  • gherkin/__main__.py should be kept as natural choice for the main program.
    NOTE: You may refer to the main() function in gherkin.scripts.gherkin if you prefer that and keep the logic there.
  • Find package mechanism that should fix that subpackages are left out (currently the case)
  • Replace raise SystemExit(main()) with sys.exit(main())

python/pyproject.toml Show resolved Hide resolved
@@ -22,6 +22,7 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt

### Removed
- [Python] Drop compatibility for python 2. Supported python versions are 3.8, 3.9, 3.10, 3.12
- [Python] Removed installation of `gherkin` script. It was used for internal acceptance tests only.
Copy link
Contributor

Choose a reason for hiding this comment

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

BAD IDEA: Removing the scripts from the package description

  • The user of this package wants to use the scripts and not some module statements that he/she does not know
  • Using gherkin/__main__.py should be kept because that is the natural choice for the main program
  • Usability for the user sucks if you do that
  • It might be OK for the repo development in Makefile but even there, it is rather suboptimal (IMHO).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually, I'm even more inclined to not include the scripts/ folder in the distribution at all.

The reason is that these scripts are only used internally, as there is absolutely no API or documentation about these. Hell, I can't even figure out what the gherkin script does at all, since there is no documentation.

I really doubt that any downstream user is using these. If anything, we are just polluting their PATH with this irrelevant gherkin executable.

In the remote hypothesis that a downstream user was relying on this, we can always release a hotfix with the script included in the distribution.

Copy link
Contributor

@jsa34 jsa34 Sep 29, 2024

Choose a reason for hiding this comment

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

If the executable is needed for the purposes of the user to understand how to run main, wouldn't this be better handled with documentation?

I may have missed something, but I didn't use this executable or use it to understand how to use gherkin when I implemented it in pytest-bdd. I'm not entirely sure how useful it for including downstream from personal experience, unless I've missed a point.

Copy link
Contributor

Choose a reason for hiding this comment

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

If these scripts/executables are only for internal use, then why put them in the Python package and not put the in bin/ directory where they were before (at least one of them).

In addition, the gherkin script is provided in the current package version and before. Therefore, the script was part of the “API” of this package. By removing them you basically break this API in the next version. And you should be aware of that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If these scripts/executables are only for internal use, then why put them in the Python package and not put the in bin/ directory where they were before (at least one of them

I can put them out of the gherkin package, so that they will automatically be out of the distributed package.

In addition, the gherkin script is provided in the current package version and before. Therefore, the script was part of the “API” of this package. By removing them you basically break this API in the next version. And you should be aware of that.

yes I know, but every release is a major release it seems, so semver semantics allow this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can put them out of the gherkin package, so that they will automatically be out of the distributed package.

Done in b94911b



if __name__ == "__main__":
raise SystemExit(main())
Copy link
Contributor

Choose a reason for hiding this comment

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

BAD IDEA: raise SystemExit(main()) — Raising an exception and calling the main() function as side-effect

  • Use sys.exit(main()) instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sys.exit(...) and raise SystemExit(...) are completely equivalent, so this is only about style.

I prefer the latter just because it avoids an import. Wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

calling the main() function as side-effect

This is not really a side-effect. You may argue that also in sys.exit(main()) it is a side effect.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed this is mainly a styling thing from what I can see, unless I am mistaken?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, it is not. It is the difference between using the official API for something and programming by side-effects.

  • Show me one example in https://docs.python.org where your idiom is used in the context of a __main__ section
  • Show me one example why packaging generates scripts the way I describe instead of how you use it

SEE ALSO:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How is this programming by side effect? Where is the side effect here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

anyway, I removed raise SystemExit in 5405b62 to make everyone happy



if __name__ == "__main__":
raise SystemExit(main())
Copy link
Contributor

Choose a reason for hiding this comment

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

BAD IDEA: raise SystemExit(main()) — Explanation, see above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed in 5405b62

gherkin = ["gherkin-languages.json"]

[tool.setuptools.packages.find]
include = ["gherkin", "gherkin.pickles", "gherkin.stream"]
Copy link
Contributor

Choose a reason for hiding this comment

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

BETTER: Use the find mechanism that is described in setuptools docs: Find simple packages

  • BLOCKER: In your case the gherkin/scripts/ directory would have been missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in d992ac4

No need to distribute them, as they are for internal tests
@youtux youtux marked this pull request as ready for review September 30, 2024 18:21
@jenisys
Copy link
Contributor

jenisys commented Oct 1, 2024

I looked over the current state again.
Unfortunately I stumbled over one major problem (and a few minors):

MAJOR:

  • The "build"/installed Python package does not contain gherkin/gherkin-languages.json file. Therefore, internationalisation for Gherkin keywords will not work when the Python package is installed.

MINOR:

  • OOPS: Makefile: make clean-generate removes your gherkin script.
  • The scripts/ directory is not a Python package and therefore needs no __init__.py.
    BUT: If you do that -- Rename "gherkin.py" to "gherkin" to avoid name-clash with gherkin package (ImportErrors occur). In addition, add she-bang #!/usr/bin/env python3 and executable flags. ALTERNATIVE: Move scrips/ directory back into the package.
  • OLD "MANIFEST" file is checked into repository -> SHOULD BE: Removed (clean up prior problem).

@youtux
Copy link
Contributor Author

youtux commented Oct 1, 2024

The "build"/installed Python package does not contain gherkin/gherkin-languages.json file. Therefore, internationalisation for Gherkin keywords will not work when the Python package is installed.

it does:

$ python -m build
❯ python -m build                                                                          
* Creating isolated environment: venv+pip...
* Installing packages in isolated environment:
  - setuptools>=61.0
  - wheel
* Getting build dependencies for sdist...
running egg_info
writing gherkin_official.egg-info/PKG-INFO
writing dependency_links to gherkin_official.egg-info/dependency_links.txt
writing requirements to gherkin_official.egg-info/requires.txt
writing top-level names to gherkin_official.egg-info/top_level.txt
reading manifest file 'gherkin_official.egg-info/SOURCES.txt'
adding license file 'LICENSE'
writing manifest file 'gherkin_official.egg-info/SOURCES.txt'
* Building sdist...
running sdist
running egg_info
writing gherkin_official.egg-info/PKG-INFO
writing dependency_links to gherkin_official.egg-info/dependency_links.txt
writing requirements to gherkin_official.egg-info/requires.txt
writing top-level names to gherkin_official.egg-info/top_level.txt
reading manifest file 'gherkin_official.egg-info/SOURCES.txt'
adding license file 'LICENSE'
writing manifest file 'gherkin_official.egg-info/SOURCES.txt'
running check
creating gherkin_official-29.0.0
creating gherkin_official-29.0.0/gherkin
creating gherkin_official-29.0.0/gherkin/pickles
creating gherkin_official-29.0.0/gherkin/stream
creating gherkin_official-29.0.0/gherkin/stream/asd
creating gherkin_official-29.0.0/gherkin_official.egg-info
copying files to gherkin_official-29.0.0...
copying LICENSE -> gherkin_official-29.0.0
copying README.md -> gherkin_official-29.0.0
copying pyproject.toml -> gherkin_official-29.0.0
copying gherkin/__init__.py -> gherkin_official-29.0.0/gherkin
copying gherkin/ast_builder.py -> gherkin_official-29.0.0/gherkin
copying gherkin/ast_node.py -> gherkin_official-29.0.0/gherkin
copying gherkin/dialect.py -> gherkin_official-29.0.0/gherkin
copying gherkin/errors.py -> gherkin_official-29.0.0/gherkin
copying gherkin/gherkin-languages.json -> gherkin_official-29.0.0/gherkin
copying gherkin/gherkin_line.py -> gherkin_official-29.0.0/gherkin
copying gherkin/inout.py -> gherkin_official-29.0.0/gherkin
copying gherkin/parser.py -> gherkin_official-29.0.0/gherkin
copying gherkin/parser_types.py -> gherkin_official-29.0.0/gherkin
copying gherkin/py.typed -> gherkin_official-29.0.0/gherkin
copying gherkin/token.py -> gherkin_official-29.0.0/gherkin
copying gherkin/token_formatter_builder.py -> gherkin_official-29.0.0/gherkin
copying gherkin/token_matcher.py -> gherkin_official-29.0.0/gherkin
copying gherkin/token_matcher_markdown.py -> gherkin_official-29.0.0/gherkin
copying gherkin/token_scanner.py -> gherkin_official-29.0.0/gherkin
copying gherkin/pickles/__init__.py -> gherkin_official-29.0.0/gherkin/pickles
copying gherkin/pickles/compiler.py -> gherkin_official-29.0.0/gherkin/pickles
copying gherkin/stream/__init__.py -> gherkin_official-29.0.0/gherkin/stream
copying gherkin/stream/gherkin_events.py -> gherkin_official-29.0.0/gherkin/stream
copying gherkin/stream/id_generator.py -> gherkin_official-29.0.0/gherkin/stream
copying gherkin/stream/source_events.py -> gherkin_official-29.0.0/gherkin/stream
copying gherkin/stream/asd/__init__.py -> gherkin_official-29.0.0/gherkin/stream/asd
copying gherkin_official.egg-info/PKG-INFO -> gherkin_official-29.0.0/gherkin_official.egg-info
copying gherkin_official.egg-info/SOURCES.txt -> gherkin_official-29.0.0/gherkin_official.egg-info
copying gherkin_official.egg-info/dependency_links.txt -> gherkin_official-29.0.0/gherkin_official.egg-info
copying gherkin_official.egg-info/requires.txt -> gherkin_official-29.0.0/gherkin_official.egg-info
copying gherkin_official.egg-info/top_level.txt -> gherkin_official-29.0.0/gherkin_official.egg-info
copying gherkin_official.egg-info/SOURCES.txt -> gherkin_official-29.0.0/gherkin_official.egg-info
Writing gherkin_official-29.0.0/setup.cfg
Creating tar archive
removing 'gherkin_official-29.0.0' (and everything under it)
* Building wheel from sdist
* Creating isolated environment: venv+pip...
* Installing packages in isolated environment:
  - setuptools>=61.0
  - wheel
* Getting build dependencies for wheel...
running egg_info
writing gherkin_official.egg-info/PKG-INFO
writing dependency_links to gherkin_official.egg-info/dependency_links.txt
writing requirements to gherkin_official.egg-info/requires.txt
writing top-level names to gherkin_official.egg-info/top_level.txt
reading manifest file 'gherkin_official.egg-info/SOURCES.txt'
adding license file 'LICENSE'
writing manifest file 'gherkin_official.egg-info/SOURCES.txt'
* Building wheel...
running bdist_wheel
running build
running build_py
creating build/lib/gherkin
copying gherkin/gherkin_line.py -> build/lib/gherkin
copying gherkin/ast_builder.py -> build/lib/gherkin
copying gherkin/token.py -> build/lib/gherkin
copying gherkin/dialect.py -> build/lib/gherkin
copying gherkin/__init__.py -> build/lib/gherkin
copying gherkin/token_matcher_markdown.py -> build/lib/gherkin
copying gherkin/parser.py -> build/lib/gherkin
copying gherkin/token_formatter_builder.py -> build/lib/gherkin
copying gherkin/parser_types.py -> build/lib/gherkin
copying gherkin/errors.py -> build/lib/gherkin
copying gherkin/token_scanner.py -> build/lib/gherkin
copying gherkin/inout.py -> build/lib/gherkin
copying gherkin/ast_node.py -> build/lib/gherkin
copying gherkin/token_matcher.py -> build/lib/gherkin
creating build/lib/gherkin/pickles
copying gherkin/pickles/compiler.py -> build/lib/gherkin/pickles
copying gherkin/pickles/__init__.py -> build/lib/gherkin/pickles
creating build/lib/gherkin/stream
copying gherkin/stream/id_generator.py -> build/lib/gherkin/stream
copying gherkin/stream/__init__.py -> build/lib/gherkin/stream
copying gherkin/stream/gherkin_events.py -> build/lib/gherkin/stream
copying gherkin/stream/source_events.py -> build/lib/gherkin/stream
creating build/lib/gherkin/stream/asd
copying gherkin/stream/asd/__init__.py -> build/lib/gherkin/stream/asd
running egg_info
writing gherkin_official.egg-info/PKG-INFO
writing dependency_links to gherkin_official.egg-info/dependency_links.txt
writing requirements to gherkin_official.egg-info/requires.txt
writing top-level names to gherkin_official.egg-info/top_level.txt
reading manifest file 'gherkin_official.egg-info/SOURCES.txt'
adding license file 'LICENSE'
writing manifest file 'gherkin_official.egg-info/SOURCES.txt'
copying gherkin/gherkin-languages.json -> build/lib/gherkin
copying gherkin/py.typed -> build/lib/gherkin
installing to build/bdist.macosx-14.6-arm64/wheel
running install
running install_lib
creating build/bdist.macosx-14.6-arm64/wheel
creating build/bdist.macosx-14.6-arm64/wheel/gherkin
copying build/lib/gherkin/gherkin_line.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin
copying build/lib/gherkin/ast_builder.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin
copying build/lib/gherkin/token.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin
copying build/lib/gherkin/dialect.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin
creating build/bdist.macosx-14.6-arm64/wheel/gherkin/pickles
copying build/lib/gherkin/pickles/compiler.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin/pickles
copying build/lib/gherkin/pickles/__init__.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin/pickles
creating build/bdist.macosx-14.6-arm64/wheel/gherkin/stream
copying build/lib/gherkin/stream/id_generator.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin/stream
creating build/bdist.macosx-14.6-arm64/wheel/gherkin/stream/asd
copying build/lib/gherkin/stream/asd/__init__.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin/stream/asd
copying build/lib/gherkin/stream/__init__.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin/stream
copying build/lib/gherkin/stream/gherkin_events.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin/stream
copying build/lib/gherkin/stream/source_events.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin/stream
copying build/lib/gherkin/__init__.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin
copying build/lib/gherkin/token_matcher_markdown.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin
copying build/lib/gherkin/parser.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin
copying build/lib/gherkin/token_formatter_builder.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin
copying build/lib/gherkin/parser_types.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin
copying build/lib/gherkin/py.typed -> build/bdist.macosx-14.6-arm64/wheel/./gherkin
copying build/lib/gherkin/gherkin-languages.json -> build/bdist.macosx-14.6-arm64/wheel/./gherkin
copying build/lib/gherkin/errors.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin
copying build/lib/gherkin/token_scanner.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin
copying build/lib/gherkin/inout.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin
copying build/lib/gherkin/ast_node.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin
copying build/lib/gherkin/token_matcher.py -> build/bdist.macosx-14.6-arm64/wheel/./gherkin
running install_egg_info
Copying gherkin_official.egg-info to build/bdist.macosx-14.6-arm64/wheel/./gherkin_official-29.0.0-py3.8.egg-info
running install_scripts
creating build/bdist.macosx-14.6-arm64/wheel/gherkin_official-29.0.0.dist-info/WHEEL
creating '/Users/youtux/Developer/gherkin/python/dist/.tmp-tzhl9qus/gherkin_official-29.0.0-py3-none-any.whl' and adding 'build/bdist.macosx-14.6-arm64/wheel' to it
adding 'gherkin/__init__.py'
adding 'gherkin/ast_builder.py'
adding 'gherkin/ast_node.py'
adding 'gherkin/dialect.py'
adding 'gherkin/errors.py'
adding 'gherkin/gherkin-languages.json'
adding 'gherkin/gherkin_line.py'
adding 'gherkin/inout.py'
adding 'gherkin/parser.py'
adding 'gherkin/parser_types.py'
adding 'gherkin/py.typed'
adding 'gherkin/token.py'
adding 'gherkin/token_formatter_builder.py'
adding 'gherkin/token_matcher.py'
adding 'gherkin/token_matcher_markdown.py'
adding 'gherkin/token_scanner.py'
adding 'gherkin/pickles/__init__.py'
adding 'gherkin/pickles/compiler.py'
adding 'gherkin/stream/__init__.py'
adding 'gherkin/stream/gherkin_events.py'
adding 'gherkin/stream/id_generator.py'
adding 'gherkin/stream/source_events.py'
adding 'gherkin/stream/asd/__init__.py'
adding 'gherkin_official-29.0.0.dist-info/LICENSE'
adding 'gherkin_official-29.0.0.dist-info/METADATA'
adding 'gherkin_official-29.0.0.dist-info/WHEEL'
adding 'gherkin_official-29.0.0.dist-info/top_level.txt'
adding 'gherkin_official-29.0.0.dist-info/RECORD'
removing build/bdist.macosx-14.6-arm64/wheel
Successfully built gherkin_official-29.0.0.tar.gz and gherkin_official-29.0.0-py3-none-any.whl

@youtux
Copy link
Contributor Author

youtux commented Oct 1, 2024

OLD "MANIFEST" file is checked into repository -> SHOULD BE: Removed (clean up prior problem).

good one, deleted in 987e836

@youtux
Copy link
Contributor Author

youtux commented Oct 1, 2024

OOPS: Makefile: make clean-generate removes your gherkin script.

It always did. That's the expected behaviour.

@youtux
Copy link
Contributor Author

youtux commented Oct 1, 2024

The scripts/ directory is not a Python package and therefore needs no init.py.
BUT: If you do that -- Rename "gherkin.py" to "gherkin" to avoid name-clash with gherkin package (ImportErrors occur). In addition, add she-bang #!/usr/bin/env python3 and executable flags. ALTERNATIVE: Move scrips/ directory back into the package.

Removed __init__.py in dc520a1. It actually didn't cause any import issue. But to be safe, I renamed it to generate_events to be consistent with the other file. 3ed84b3

@youtux
Copy link
Contributor Author

youtux commented Oct 1, 2024

@jenisys please review again

@jenisys
Copy link
Contributor

jenisys commented Oct 2, 2024

RELATED TO: gherkin-languages.json

I must have been mistaken yesterday:

  • I build the sdist package and unpacked it in another directory
  • I was trying to use tests and the scripts and ran into a FileNotFoundError related to gherkin-languages.json

Everything seems to be OK now.

Makefile

After you removed scripts/__init__.py, you should basically use python $SCRIPT_PATH instead of python -m $SCRIPT_MODULE in the Makefile.
Weird that the module-syntax seems to be working if you run make acceptance.

# -- FILE: python/Makefile
...
# ORIGINAL: GHERKIN_GENERATE_EVENTS = python -m scripts.generate_events
# ORIGINAL: GHERKIN_GENERATE_TOKENS = python -m scripts.generate_tokens
GHERKIN_GENERATE_EVENTS = python scripts/generate_events.py
GHERKIN_GENERATE_TOKENS = python scripts/generate_tokens.py
...

Python Source-Code Package (sdist)

Normally, the source code package (aka: sdist) as TARGZ/ZIP archive should contain the complete contents of the source code repository (without the VCS details and temporary directory/files). If this is the case, you can unpack this archive and run the tests in your workspace (for example).

Currently, the following directories/files are missing:

  • test/ subdirectory
  • scripts/ subdirectory
  • Makefile (questionable if this should be included because ../testdata/ is missing)
  • gherkin-python.razor (questionable if this should be included because ../gherkin-berp is missing)

I would include the test/ directory at least.
Think about it and make a decision.

Otherwise

  • gherkin-python.razor has executable permissions (same as in the other directories, like: ../javascript/gherkin-javascript.razor). This is not needed (IMHO). But such a clean up should occur for all languages.
  • ADDRESSED IN: Issue *.razor files have executable permissions #291

Copy link
Contributor

@jenisys jenisys left a comment

Choose a reason for hiding this comment

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

DONE: See comments.

@youtux
Copy link
Contributor Author

youtux commented Oct 2, 2024

Weird that the module-syntax seems to be working if you run make acceptance.

Why is it weird? scripts.generate_tokens is a valid module name from the cwd.

Normally, the source code package (aka: sdist) as TARGZ/ZIP archive should contain the complete contents of the source code repository

An source for this? To me, the sdist should just contain enough info to build the package, not to test it. If we want to make the sdist testable, we should include all the testdata from upper level too. Otherwise it would just be half done.

jenisys pushed a commit that referenced this pull request Oct 4, 2024
* Provide "pyproject.toml" that supersedes "setup.py"
* Moved scripts from "bin/" to "scripts" directory
* CHANGELOG: Add mention of pull #290 for Python change.

CLEANUP:

* Delete leftover `MANIFEST`, which is not necessary anymore
* Remove "setup.py"
@jenisys
Copy link
Contributor

jenisys commented Oct 4, 2024

MERGED INTO: main (manually and squashed commits, shortened commit-message)

@jenisys jenisys closed this Oct 4, 2024
@jenisys jenisys deleted the python/switch-to-pyroject branch October 4, 2024 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python does not keep version in pyproject.toml
3 participants