-
Notifications
You must be signed in to change notification settings - Fork 650
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
Improve package layout #37
Conversation
description="OpenTelemetry Python SDK", | ||
include_package_data=True, | ||
long_description=open("README.rst").read(), | ||
install_requires=[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opentelemetry-sdk
will have dependency on opentelemetry-api
, this will be a separate PR (we need to figure out how to install from local).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was skeptical of src/
, but this looks good and the setuptools docs confirm that this is the best way to do this.
You'll have to change the paths in tox.ini
to get the tests to pass.
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from .version import __version__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about troubleshooting scenario, where we want to see which version of the SDK customers are using, we do need to distinguish SDK versions versus API versions.
For example, if the queue for traces are full, I'd expect we log something like:
2019-06-27T22:36:59Z OpenTelemetry API loaded (version=1.0.0)
2019-06-27T22:37:15Z OpenTelemetry SDK loaded (version=1.0.3)
2019-06-27T22:38:30Z traces queue full, started to drop spans
2019-06-27T22:38:50Z traces queue recovered
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean why do you need to import it here instead of in whatever module uses it (the trace queue in your example)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, my intent was to save some typing, so we can import sdk.__version__
instead of sdk.version.__version__
. Later we can probably rename version.py
to package_info.py
if we have more stuff to put here.
|
||
package_info = {} | ||
with open(os.path.join(base_dir, "src", "opentelemetry", "sdk", "version.py")) as f: | ||
exec(f.read(), package_info) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use package_info
instead of read/exec-ing right into globals
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To prevent bad thing inside the version.py
(later we might add more stuff such like SDK vendor info and rename the file to package_info.py) from polluting globals.
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
__version__ = "0.1.dev0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should you move the API version file out of internal/
to match?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean something like opentelemetry/api/version.py
? We decided to put version.py
in internal since there is no public interface. I'm open to suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take #19 (review) to mean that we can't have a single top-level version file, but separate files under api/
and sdk/
should be fine.
@@ -8,5 +8,5 @@ deps = | |||
py37-mypy: mypy | |||
|
|||
commands = | |||
py37-lint: pylint opentelemetry-api/opentelemetry/ | |||
py37-mypy: mypy opentelemetry-api/opentelemetry/ | |||
py37-lint: pylint opentelemetry-api/src/opentelemetry/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@c24t do you think it's good idea to run lint on opentelemetry-api
(which includes setup.py
, tests, examples)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, if it ends up being easier to blacklist dirs that shouldn't be linted than to whitelist every one that should.
I noticed that we got some trouble here. The reason why Travis + Tox work for us is because we have the file For this PR, I reverted the |
@@ -8,5 +8,5 @@ deps = | |||
py37-mypy: mypy | |||
|
|||
commands = | |||
py37-lint: pylint opentelemetry-api/opentelemetry/ | |||
py37-mypy: mypy opentelemetry-api/opentelemetry/ | |||
py37-lint: pylint opentelemetry-api/src/opentelemetry/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, if it ends up being easier to blacklist dirs that shouldn't be linted than to whitelist every one that should.
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from .version import __version__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean why do you need to import it here instead of in whatever module uses it (the trace queue in your example)?
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
__version__ = "0.1.dev0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take #19 (review) to mean that we can't have a single top-level version file, but separate files under api/
and sdk/
should be fine.
where="src"
approach as demonstrated https://setuptools.readthedocs.io/en/latest/setuptools.html#find-namespace-packages.The reason for introducing
src
folder:tests/foo/bar/opentelemetry/
as well, which we want to avoid. The name filter in setuptools is implemented usingfnmatchcase
, which doesn't provide a good way to workaround this.setup.py
under theopentelemetry-api
folder, it will generate temporary folder structurebuild/lib/opentelemetry/
, which will be accidentally included in the package.