Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ __pycache__
build/
dist/
*.pyc
/apache_skywalking.egg-info/
/apache_skywalking.egg-info/
**/venv/
17 changes: 17 additions & 0 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,22 @@ with context.new_entry_span(op=str('https://github.com/apache/skywalking')) as s

Check [the FAQ page](docs/FAQ.md) or add the FAQs there.

## For Developers

### Steps to get an operational virtual environment:

1. `git clone https://github.com/apache/skywalking-python.git`
2. `cd skywalking-python/tools/env` (*make sure you actually go into the directory since the scripts use relative paths*)
3. Run the script for your relevant OS to create a virtual environment folder in the project root (*skywalking-python/venv*) and install all the necessary requirements

**Make sure that when the `python` command is executed on your workstation, the binary it references is python 3.5 or newer!**
Copy link
Member

Choose a reason for hiding this comment

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

IIRC this can be automatically determined right?

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'll have to double-check but I think you can determine either python3 or perhaps python37 but IDK about specifically python35-python38. And sometimes python3 is not implemented as an option (on my PC, writing python3 in PowerShell redirects me to the Microsoft Store :D


### Steps after contributing

If your PR introduces the need for a new non-standard library which needs to be pulled via pip or if it removes the need for a previously-used library:
1. navigate to `/path/to/skywalking/agent/tools/env`
2. Execute the `build_requirements` script relevant to your OS.
3. Double check the `requirements.txt` file in the project root to ensure that the changes have been reflected.

## License
Apache 2.0
23 changes: 23 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
blindspin==2.0.1
certifi==2020.6.20
chardet==3.0.4
colorama==0.4.3
crayons==0.3.1
deprecation==2.1.0
docker==4.2.2
grpcio==1.30.0
grpcio-tools==1.30.0
idna==2.10
packaging==20.4
protobuf==3.12.2
PyMySQL==0.9.3
pyparsing==2.4.7
pypiwin32==223
pywin32==228
requests==2.24.0
six==1.15.0
testcontainers==3.0.3
urllib3==1.25.9
websocket-client==0.57.0
Werkzeug==1.0.1
wrapt==1.12.1
Comment on lines +1 to +23
Copy link
Member

Choose a reason for hiding this comment

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

Do you think that we should check in this file? I saw this is Windows-specific, and in my side, it should be Mac-specific, this file keeps changing from developer to developer

Copy link
Member

Choose a reason for hiding this comment

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

And it seems to be created automatically in the script, so don't need to check in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The point of this file is for the build script to work. If you don't have this file, the other 4 scripts are pointless. It tells them what libraries need to be installed in the virtual env so that the dev doesn't have to go file-to-file to see what they need to install

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 we don't check it in, a new developer/user who is just downloading the source will not have a way to set up their venv

Copy link
Member

Choose a reason for hiding this comment

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

According to your doc, if the developers can 2. Execute the build_requirements script relevant to your OS. to generate the requirements.txt, why should we check the requirements.txt in? Other developers can also execute the same script to generate it, right?

13 changes: 8 additions & 5 deletions tools/check-license-header.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import os
import sys

ignored_chars = '#\n \t'
ignored_chars = '#\n \t:'

license_header = ' '.join(
[
Expand All @@ -43,17 +43,20 @@
]
).strip(ignored_chars)

comment_leading_chars = ('#', '::')


def walk_through_dir(d) -> bool:
checked = True
for root, sub_dirs, files in os.walk(d):
for filename in files:
file_path = os.path.join(root, filename)

with open(file_path, 'r') as f:
header = ' '.join([line.strip(ignored_chars) for line in f.readlines() if line.startswith('#')]).strip()
print('%s license header in file: %s' % ('✅' if header == license_header else '❌', file_path))
checked &= header == license_header
header = ' '.join([
line.strip(ignored_chars) for line in f.readlines() if line.startswith(comment_leading_chars)
]).strip()
print('%s license header in file: %s' % ('✅' if license_header in header else '❌', file_path))
checked &= license_header in header
return checked


Expand Down
24 changes: 24 additions & 0 deletions tools/env/build_requirements_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#!/bin/sh

echo "Building requirements.txt"

../../venv/bin /python -m pip freeze > ../../requirements.txt

echo "requirements.txt created"
22 changes: 22 additions & 0 deletions tools/env/build_requirements_windows.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
::
:: Licensed to the Apache Software Foundation (ASF) under one or more
:: contributor license agreements. See the NOTICE file distributed with
:: this work for additional information regarding copyright ownership.
:: The ASF licenses this file to You under the Apache License, Version 2.0
:: (the "License"); you may not use this file except in compliance with
:: the License. You may obtain a copy of the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
::

echo "Building requirements.txt"

..\..\venv\Scripts\python.exe -m pip freeze > ..\..\requirements.txt

echo "requirements.txt created"
26 changes: 26 additions & 0 deletions tools/env/setup_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#!/bin/sh

echo "Creating virtual environment"
python3 -m venv '../../venv'
echo "Virtual env created"

../../venv/bin/python -m pip install --upgrade pip
echo "Pip upgrade complete. Installing packages from requirements.txt"
../../venv/bin/python -m pip install ../../requirements.txt
29 changes: 29 additions & 0 deletions tools/env/setup_windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

Write-Output "Creating virtual environment"

& python -m venv '..\..\venv'

Write-Output "Virtual env created"

$PYEXE= Join-Path -Path $PSScriptRoot -ChildPath '..\..\venv\Scripts\python.exe'
& $PYEXE -m pip install --upgrade pip

Write-Output "Pip upgrade complete. Installing packages from requirements.txt"

& $PYEXE -m pip install -r ..\..\requirements.txt