Skip to content

[v7r2] Fully support setuptools#4865

Merged
atsareg merged 27 commits into
DIRACGrid:integrationfrom
chrisburr:support-setuptools
Jan 19, 2021
Merged

[v7r2] Fully support setuptools#4865
atsareg merged 27 commits into
DIRACGrid:integrationfrom
chrisburr:support-setuptools

Conversation

@chrisburr

Copy link
Copy Markdown
Member

Closes #4774

BEGINRELEASENOTES

*Core
NEW: Fully support installation with setuptools

ENDRELEASENOTES

@chrisburr chrisburr force-pushed the support-setuptools branch 5 times, most recently from f4b010e to 27ca8d8 Compare December 10, 2020 16:00

@chrisburr chrisburr left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is ready for feedback before I convert all the scripts. I've added some comments in a review to try and explain what is going on.

Comment thread setup.cfg
package_dir=
=src
packages = find:
install_requires =

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It would be useful if someone can take a look at the dependencies and see if I've missed anything or got the client/server/testing split wrong.

Version constraints should also be added before the first non-pre release but that can wait for a little while.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just as a precision after discussion: only minimal version constraint is envisaged (e.g. M2Crypto>=0.36)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The stability will come from the fact that a given DIRACOS(2) version maps to a single set of packages. Adding restrictive versions here will just add a maintaince burdon and make it harder for people to actually install DIRAC alongside other things.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We have several of these lists now (environment.yml, environment-py3.yml, requirements.txt), would it be possible to reduce the number?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

environment-py3.yml, requirements.txt, docs/requirements.txt and docs/requirements_py3.txt will disappear relatively soon. We will then be left with only three places:

  • setup.cfg: Runtime dependencies of DIRAC that are Python packages themselves, validated whenever DIRAC is installed
  • environment.yml: Any packages that need to be available to run the tests (excluding integration for now, though that's not actually a problem now as everything is available from conda-forge), i.e. not limited to just Python packages so this can included singularity/python itself/openssl/...
  • constructor.yml in DIRACOS2: Packages which will be included in the DIRACOS2 tarball
  • meta.yaml: Allows a conda package to be built for DIRAC, not a big deal as it can be automatically generated from the PyPI metadata, that is itself generated from the setup.cfg file.

While there will be some duplication between the above they each serve distinct roles any any effort to de-duplicate them further will be more work than it's worth.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

constructor.yml will be a subset of environment.yml, right? And setup.cfg will also be a (different) subset of environment.yml.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes though package names in setup.cfg will be the names on PyPI which might differ slightly from the name of the conda-package. For example graphviz is the Python bindings on PyPI but the CLI application on conda-forge (python-graphviz is the conda-forge name for the Python bindings).

from DIRAC import gLogger


class DIRACScript(object):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is the class that does the magic for replacing console_scripts functions with the highest priority extension. It does nothing when installed with Python 2 (under the assumption that it's a legacy install using PYTHONPATH).

All console-scripts entrypoints in DIRAC and downstream extensions should be
wrapped in this decorator to allow extensions to override any entry_point.
"""
def __init__(self):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This constructor could be useful for allowing something like below. It's not strictly needed though so it can be deferred to another release if we want (or never). I'll wait for opinions before implementing it.

@DiracScript(
    switches=[
        ("f:", "file=", "File to use as user key"),
        ("i", "version", "Print version"),
        ("n", "novoms", "Disable VOMS"),
        ("v", "checkvalid", "Return error if the proxy is invalid"),
        ("x", "nocs", "Disable CS"),
        ("e", "steps", "Show steps info"),
        ("j", "noclockcheck", "Disable checking if time is ok"),
        ("m", "uploadedinfo", "Show uploaded proxies info"),
    ],
    requriesProxy=False,
)
def proxy_info(*args, **kwargs):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's hardly any CLI not needed a proxy. But I admit that checking it before hand would give much more meaningfull messages. But that's maybe not the place to do it.
For the switches, maybe we could maybe look at something like click ? Anyway, I would differ it to later

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I would imagine requriesProxy=True would be the default if we did this.

For the switches, maybe we could maybe look at something like click ? Anyway, I would differ it to later

I think the current parsing is too inconsistent to repliment using click so while it would be nice we need to be prepared to a single big backwards-incompatible break or, more likely, a transisition to a new CLI.

Anyway, I would differ it to later

In hindsight I agree that it's best left out of this PR to ensure the diff is reviewable.

@@ -1,72 +0,0 @@
#!/usr/bin/env python

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've only modified three scripts for now as an example so people can give feedback without needing to duplicate the work. While the diff looks scary the actual change is:

  • Rename dirac-info.py to dirac_info.py so it's a valid Python module. This is safe as dirac-install already replaces _ with - when generating the wrapper scripts. (I was going to suggest implementing this but it was already there.)
  • Indent almost all lines so they can exist in a main() function
  • Add if __name__ == "__main__": main() to the end so the script can still be ran directly

Comment thread src/DIRAC/__init__.py Outdated
Comment thread src/DIRAC/__init__.py Outdated
return {
"priority": 0,
"setups": {
"DIRAC-Certification": {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This isn't used yet but it will be in my follow up PR to this one. I didn't mean to include it here but I see no harm in leaving it.

@chrisburr chrisburr requested review from andresailer, chaen and fstagni and removed request for andresailer, chaen and fstagni December 11, 2020 10:33

@chaen chaen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In general, I am extremely pleased by all that (although not very surprised since we did talked about it :D )

However, I would advocate for more explanations, not necessarily yet in the official wiki/ existing rst (this can come once everything is consolidated) but at least in a document that explains the different bits and pieces of the whole mechanism, with links to various documents (PEP or others). This is for the sake of keeping the global picture accessible to everybody

I would also keep somewhere (maybe this time in the official instructions) what needs to be done already (for example the double tagging), such that it is not overlooked

Thanks for the tedious work :-)

Comment thread setup.cfg
Comment thread docs/diracdoctools/cmd/commandReference.py
Comment thread pyproject.toml
Comment thread setup.cfg
sqlalchemy
stomp.py
suds-jurko
tornado

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess we need to specify the repo here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I hope we can require the local version segment and use something like tornado =*+dirac.* but I'm not sure if that actually works properly. I need to do some tests here but in practice pip install DIRAC[server] is not going to work without some help from outside (i.e. DIRACOS2) as some of these packages don't even exist on PyPI and many don't provide wheels/robust enough build systems. Regardless I think including the git repo here is a bad idea.

Comment thread setup.cfg Outdated
Comment thread src/DIRAC/Core/Utilities/DIRACScript.py Outdated
All console-scripts entrypoints in DIRAC and downstream extensions should be
wrapped in this decorator to allow extensions to override any entry_point.
"""
def __init__(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's hardly any CLI not needed a proxy. But I admit that checking it before hand would give much more meaningfull messages. But that's maybe not the place to do it.
For the switches, maybe we could maybe look at something like click ? Anyway, I would differ it to later

Comment thread src/DIRAC/Core/Utilities/DIRACScript.py Outdated
Comment thread src/DIRAC/__init__.py Outdated
Comment thread src/DIRAC/__init__.py Outdated
Comment thread src/DIRAC/__init__.py Outdated
Comment thread src/DIRAC/__init__.py
Comment thread setup.cfg
Comment thread setup.cfg
package_dir=
=src
packages = find:
install_requires =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We have several of these lists now (environment.yml, environment-py3.yml, requirements.txt), would it be possible to reduce the number?

Comment thread setup.cfg
parameterized
pytest

[options.entry_points]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add some comments here?
e.g. "what to do if you have a script with the same name in the extension"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've added documentation in 905965f and a comment in the setup.cfg referencing it.

Comment thread pyproject.toml
@chrisburr chrisburr force-pushed the support-setuptools branch 4 times, most recently from cf15fa3 to aacc335 Compare January 13, 2021 14:15
@chrisburr

Copy link
Copy Markdown
Member Author

I think everything has been dealt with here and it's now ready for all of the scripts to be converted.

@chrisburr

Copy link
Copy Markdown
Member Author

@chaen Can you look at 7de4904 to see if it's okay for the tornado scripts? If it isn't I'm going to have to add a hack in the DIRACScript() to make it work.

@chrisburr chrisburr force-pushed the support-setuptools branch 2 times, most recently from 9edd08a to 9292153 Compare January 14, 2021 09:37
@fstagni fstagni requested review from chaen and removed request for andresailer January 14, 2021 09:46
@chrisburr

Copy link
Copy Markdown
Member Author

@chaen @fstagni Is there anything else to do before this can be approved/merged?

@fstagni fstagni left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think I can approve, now it's about testing.

@andresailer

Copy link
Copy Markdown
Contributor

I am wondering if there are going to be conflicts because of the changes in many scripts in #4853

@chrisburr

Copy link
Copy Markdown
Member Author

I am wondering if there are going to be conflicts because of the changes in many scripts in #4853

It will be okay with the module docstring changes as those haven't moved. I suspect the code changes will basically need to be re-done from scratch in one of the PRs.


__RCSID__ = "$Id$"

# Must be define BEFORE any dirac import

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment belongs to the os.environ below


print("NOTE:", __file__, "is deprecated and will be removed in v7r3, for details see",
"https://github.com/DIRACGrid/DIRAC/wiki/DIRAC-v7r2#rename-of-scripts")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why isn't the main() from dirac_agent.py called here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This (i.e. copying the entire thing) was what we talked about during the BiLD but yeah I see no reason not to import instead 👍

@atsareg atsareg merged commit e2b3b61 into DIRACGrid:integration Jan 19, 2021
chrisburr added a commit to chrisburr/DIRAC that referenced this pull request Jan 20, 2021
chrisburr added a commit to chrisburr/DIRAC that referenced this pull request Jan 20, 2021
chrisburr added a commit to chrisburr/DIRAC that referenced this pull request Jan 20, 2021
chrisburr added a commit to chrisburr/DIRAC that referenced this pull request Jan 20, 2021
atsareg pushed a commit that referenced this pull request Jan 20, 2021
@chrisburr chrisburr deleted the support-setuptools branch January 21, 2021 06:54
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.

Fix setuptools installation

5 participants